From: qydysky Date: Sun, 9 Apr 2023 02:32:44 +0000 (+0800) Subject: Fix 切换房间不重新录制 X-Git-Tag: v0.8.0~3 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=534fd77bf2ffcdfd7f0a3d6e2cd9bfe58782d779;p=bili_danmu%2F.git Fix 切换房间不重新录制 --- diff --git a/Reply/F.go b/Reply/F.go index 3b05b7f..39ad905 100644 --- a/Reply/F.go +++ b/Reply/F.go @@ -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 { diff --git a/Reply/stream.go b/Reply/stream.go index e695e6b..9bf3705 100644 --- a/Reply/stream.go +++ b/Reply/stream.go @@ -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) diff --git a/bili_danmu.go b/bili_danmu.go index c0e5e5d..e751831 100644 --- a/bili_danmu.go +++ b/bili_danmu.go @@ -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)