feat(audio): 使用 oto/v3 重构音频播放系统,移除 beep/v2 依赖
核心变更: - 实现全局 oto.Context 单例管理(sync.Once) - 实现一次性播放:PlayWav/PlayMP3(支持 context 取消) - 实现 BGM 循环播放:PlayMP3Loop(atomic.Bool + WaitGroup) - 迁移所有业务层到新 API(TTS/BGM/待机音频) - 添加完整的单元测试(6/6 通过) 技术栈: - oto/v3 v3.3.2(低级音频播放) - hajimehoshi/go-mp3 v0.3.4(MP3 解码) - youpy/go-wav v0.3.2(WAV 解码) 移除依赖: - gopxl/beep/v2 及所有相关依赖 优化: - 流式播放,无需预先加载 - 并发安全,无竞态条件 - 资源管理清晰(defer cleanup) - Sleep 间隔优化(1ms → 10ms,降低 CPU 占用)
This commit is contained in:
9
go.mod
9
go.mod
@@ -5,16 +5,18 @@ go 1.23.2
|
||||
require (
|
||||
github.com/adrg/libvlc-go/v3 v3.1.6
|
||||
github.com/aliyun/alibabacloud-nls-go-sdk v1.1.1
|
||||
github.com/ebitengine/oto/v3 v3.3.2
|
||||
github.com/eclipse/paho.golang v0.22.0
|
||||
github.com/go-pkgz/cronrange v0.2.0
|
||||
github.com/go-rod/rod v0.116.2
|
||||
github.com/gopxl/beep/v2 v2.1.1
|
||||
github.com/grid-x/modbus v0.0.0-20250219144522-2b18d136199f
|
||||
github.com/hajimehoshi/go-mp3 v0.3.4
|
||||
github.com/hypebeast/go-osc v0.0.0-20220308234300-cec5a8a1e5f5
|
||||
github.com/spf13/viper v1.21.0
|
||||
github.com/tencentcloud/tencentcloud-cls-sdk-go v1.0.11
|
||||
github.com/urfave/cli/v3 v3.8.0
|
||||
github.com/warthog618/go-gpiocdev v0.9.1
|
||||
github.com/youpy/go-wav v0.3.2
|
||||
go.uber.org/zap v1.27.0
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||
)
|
||||
@@ -22,14 +24,12 @@ require (
|
||||
require (
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.63.93 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/ebitengine/oto/v3 v3.3.2 // indirect
|
||||
github.com/ebitengine/purego v0.8.2 // indirect
|
||||
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/gorilla/websocket v1.5.3 // indirect
|
||||
github.com/grid-x/serial v0.0.0-20211107191517-583c7356b3aa // indirect
|
||||
github.com/hajimehoshi/go-mp3 v0.3.4 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.18.0 // indirect
|
||||
@@ -38,7 +38,6 @@ require (
|
||||
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/sagikazarmark/locafero v0.11.0 // indirect
|
||||
github.com/satori/go.uuid v1.2.0 // indirect
|
||||
@@ -47,11 +46,13 @@ require (
|
||||
github.com/spf13/cast v1.10.0 // indirect
|
||||
github.com/spf13/pflag v1.0.10 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/youpy/go-riff v0.1.0 // indirect
|
||||
github.com/ysmood/fetchup v0.3.0 // indirect
|
||||
github.com/ysmood/goob v0.4.0 // indirect
|
||||
github.com/ysmood/got v0.40.0 // indirect
|
||||
github.com/ysmood/gson v0.7.3 // indirect
|
||||
github.com/ysmood/leakless v0.9.0 // indirect
|
||||
github.com/zaf/g711 v1.4.0 // indirect
|
||||
go.uber.org/atomic v1.11.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||
|
||||
Reference in New Issue
Block a user