From 75f89c9ad4aad9934b8368f7cb36f7a7bc8c415c Mon Sep 17 00:00:00 2001 From: langhuihui <178529795@qq.com> Date: Thu, 6 Aug 2020 22:31:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E8=AE=A2=E9=98=85=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E6=84=8F=E5=A4=96=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- subscriber.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/subscriber.go b/subscriber.go index ff54f09..0d6fe2f 100644 --- a/subscriber.go +++ b/subscriber.go @@ -2,7 +2,6 @@ package engine import ( "context" - "fmt" "time" "github.com/Monibuca/engine/v2/avformat" @@ -49,10 +48,13 @@ func (s *Subscriber) Close() { func (s *Subscriber) Subscribe(streamPath string) (err error) { if !config.EnableWaitStream { if _, ok := streamCollection.Load(streamPath); !ok { - return errors.New(fmt.Sprintf("Stream not found:%s", streamPath)) + return errors.Errorf("Stream not found:%s", streamPath) } } GetStream(streamPath).Subscribe(s) + if s.Context == nil { + return errors.Errorf("stream not exist:%s", streamPath) + } defer s.UnSubscribe(s) select { //等待发布者首屏数据,如果发布者尚为发布,则会等待,否则就会往下执行