Skip to content

Commit

Permalink
feat: don't need retry 5 count to start audio server
Browse files Browse the repository at this point in the history
there is already a retry mechanism for using systemd to start services
so don't need to manual to retry

Log:
  • Loading branch information
dengbo11 committed Jul 18, 2023
1 parent de0ebff commit 84d2dd2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
8 changes: 1 addition & 7 deletions audio1/audio.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func newAudio(service *dbusutil.Service) *Audio {
return a
}

func startAudioServer(count int, service *dbusutil.Service) error {
func startAudioServer(service *dbusutil.Service) error {
var serverPath dbus.ObjectPath
audioServers := []string{"pipewire.service", "pluseaudio.service"}

Expand Down Expand Up @@ -252,12 +252,6 @@ func startAudioServer(count int, service *dbusutil.Service) error {
}

if !has {
if count > 0 {
logger.Debug("retry start audio server after 500ms")

time.Sleep(500 * time.Millisecond)
return startAudioServer(count-1, service)
}
return errors.New("failed to start audio server")
}

Expand Down
4 changes: 2 additions & 2 deletions audio1/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func (*Module) GetDependencies() []string {
func (m *Module) start() error {
service := loader.GetService()

err := startAudioServer(5, service) // 为了保证蓝牙模块依赖audio模块,并且audio模块启动pulseaudio完成.
err := startAudioServer(service) // 为了保证蓝牙模块依赖audio模块,并且audio模块启动音频服务完成.
if err != nil {
err = xerrors.Errorf("failed to start pulseaudio: %w", err)
err = xerrors.Errorf("failed to start audio server: %w", err)
logger.Warning(err)
return err
}
Expand Down

0 comments on commit 84d2dd2

Please sign in to comment.