]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Fix 切换房间不重新录制
authorqydysky <qydysky@foxmail.com>
Sun, 9 Apr 2023 02:32:44 +0000 (10:32 +0800)
committerqydysky <qydysky@foxmail.com>
Sun, 9 Apr 2023 02:32:44 +0000 (10:32 +0800)
Reply/F.go
Reply/stream.go
bili_danmu.go

index 3b05b7f021cfb9f51a47cf5899f83d5dcb1932ff..39ad905a22f3ae85b98713824ea67bd45454efe5 100644 (file)
@@ -205,12 +205,11 @@ func Ass_f(contextC context.Context, save_path string, filePath string, st time.
        if filePath == "" {
                return
        }
-
+       fl := c.C.Log.Base(`Ass`)
        if rel, err := filepath.Rel(save_path, ass.file); err == nil {
-               c.C.Log.Base(`Ass`).L(`I: `, "保存到", rel+".ass")
+               fl.L(`I: `, "保存到", rel+".ass")
        } else {
-               c.C.Log.Base(`Ass`).L(`I: `, "保存到", ass.file+".ass")
-               c.C.Log.Base(`Ass`).L(`W: `, err)
+               fl.L(`W: `, err)
        }
        f := &file.File{
                Config: file.Config{
@@ -224,6 +223,7 @@ func Ass_f(contextC context.Context, save_path string, filePath string, st time.
 
        <-contextC.Done()
        ass.file = ""
+       fl.L(`I: `, "结束")
 }
 
 // 传入要显示的单条字幕
@@ -1443,15 +1443,14 @@ func init() {
 }
 
 // 弹幕回放
-var Recoder = websocket.Recorder{
-       Server: StreamWs,
-}
-
 func StartRecDanmu(c context.Context, filePath string) {
        if !IsOn(`仅保存当前直播间流`) || !IsOn("弹幕回放") {
                return
        }
        f := flog.Base("弹幕回放")
+       var Recoder = websocket.Recorder{
+               Server: StreamWs,
+       }
        if e := Recoder.Start(filePath); e == nil {
                f.L(`T: `, `开始`)
        } else {
index e695e6bcb6b0c56039dbe6244e0c65530ef5db6d..9bf37057a5b9de96a9b5081574e9c94fa63dff1d 100644 (file)
@@ -1130,11 +1130,26 @@ func (t *M4SStream) Start() bool {
                t.Stream_msg = msgq.NewType[[]byte]()
 
                // 设置事件
+               mainContextC, mainCancle := context.WithCancel(context.Background())
+               if t.Callback_stopRec != nil {
+                       t.msg.Pull_tag_only("stopRec", func(ms *M4SStream) (disable bool) {
+                               ms.Callback_stopRec(ms)
+                               return false
+                       })
+               }
+               t.msg.Pull_tag_only("stop", func(ms *M4SStream) (disable bool) {
+                       if ms.Callback_stop != nil {
+                               ms.Callback_stop(ms)
+                       }
+                       mainCancle()
+                       t.msg.ClearAll()
+                       return true
+               })
                if t.config.save_to_file {
                        var fc funcCtrl.FlashFunc
                        t.msg.Pull_tag_async(map[string]func(*M4SStream) (disable bool){
                                `cut`: func(ms *M4SStream) (disable bool) {
-                                       contextC, cancle := context.WithCancel(context.Background())
+                                       contextC, cancle := context.WithCancel(mainContextC)
                                        fc.FlashWithCallback(cancle)
 
                                        l := ms.log.Base_add(`文件`)
@@ -1156,19 +1171,6 @@ func (t *M4SStream) Start() bool {
                                },
                        })
                }
-               if t.Callback_stopRec != nil {
-                       t.msg.Pull_tag_only("stopRec", func(ms *M4SStream) (disable bool) {
-                               ms.Callback_stopRec(ms)
-                               return false
-                       })
-               }
-               t.msg.Pull_tag_only("stop", func(ms *M4SStream) (disable bool) {
-                       if ms.Callback_stop != nil {
-                               ms.Callback_stop(ms)
-                       }
-                       t.msg.ClearAll()
-                       return true
-               })
 
                defer t.msg.Push_tag(`stop`, t)
 
index c0e5e5d7d937f34170d83ba961c2dcea116908ba..e75183188905adf1dc3144bebd6b82524e481594 100644 (file)
@@ -142,9 +142,6 @@ func Start() {
                                interrupt <- os.Interrupt
                                return false
                        },
-               })
-               //单独,避免队列执行耗时block从而无法接收更多消息
-               c.C.Danmu_Main_mq.Pull_tag(msgq.FuncMap{
                        `pm`: func(data any) bool { //私信
                                if tmp, ok := data.(send.Pm_item); ok {
                                        send.Send_pm(tmp.Uid, tmp.Msg)