From 541156f255d7e820a6dffd5d15eeeae204bf9107 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 28 May 2021 16:16:56 +0900 Subject: [PATCH] audio/internal/readerdriver: Wait the loop when there is no player (Windows) --- audio/internal/readerdriver/driver_windows.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/audio/internal/readerdriver/driver_windows.go b/audio/internal/readerdriver/driver_windows.go index f78ee85d5..5906859d2 100644 --- a/audio/internal/readerdriver/driver_windows.go +++ b/audio/internal/readerdriver/driver_windows.go @@ -123,6 +123,7 @@ func (p *players) add(player *playerImpl) error { p.players = map[*playerImpl]struct{}{} } p.players[player] = struct{}{} + p.cond.Signal() if p.waveOut != 0 { return nil @@ -183,6 +184,10 @@ func (p *players) removeImpl(player *playerImpl) error { } func (p *players) shouldWait() bool { + if len(p.players) == 0 { + return true + } + if p.waveOut == 0 { return false } @@ -271,6 +276,10 @@ func (p *players) readAndWriteBuffers() error { } func (p *players) readAndWriteBuffersImpl() error { + if len(p.players) == 0 { + return nil + } + headerNum := 0 for _, h := range p.headers { if h.IsQueued() {