refactor(tts): TTS 四层架构彻底重构(Coordinator + SegmentPlanner) - #692
Open
codedogQBY wants to merge 3 commits into
Open
refactor(tts): TTS 四层架构彻底重构(Coordinator + SegmentPlanner)#692codedogQBY wants to merge 3 commits into
codedogQBY wants to merge 3 commits into
Conversation
- TTSCoordinator:状态机(idle/loading/playing/paused/stopping/error)+ sessionId/AbortController 隔离 - 旧回调一律通过 isCurrent 校验忽略,根治竞态类 bug - SegmentPlanner:分段、字符偏移、CFI 查找、跳转定位 - LegacyPlayerProvider 适配器保留旧播放器兼容 - 统一错误上下文(sessionId/segment/provider/state) - 新增测试:状态机转移、session 隔离、自动下一段、分段/偏移/CFI - 全部测试 588 个通过 - store 切换待下一步(契约差异需先扩展适配器)
- 删除 startPlayback、_sessionGeneration、detachAndStopAllPlayers 等旧逻辑 - 播放/暂停/恢复/停止/跳转/定位全部走 TTSCoordinator - 保留 TTSPlayerFactories 通过 LegacyPlayerProvider 提供底层播放器 - 对外 store API 不变,UI 无感知 - 全部测试 588 个通过
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
TTS 模块长期积累 7 个相关 bug(#683/#682/#681/#675/#634/#627/#626),根因是架构边界不清:tts-players.ts 单文件 1257 行塞了多供应商+音频解码+流式队列+播放控制+错误恢复,tts-store.ts 又管配置+播放器实例+会话+跳转+生命周期,导致大量回调竞态和隐式状态问题,打补丁无法根治。
重构方案(四层架构)
核心机制
改动
coordinator.ts(238 行)、segment-planner.ts(73 行)+ 专项测试tts-store.ts(-140 行旧编排:删除 startPlayback/_sessionGeneration/detachAndStopAllPlayers)Issue 关联
Closes #683 #682 #681 #675 #634 #626(#627 需安卓真机验证 codec 兼容性)
验证
风险