Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions driver_winmm_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ type winmmContext struct {
err atomicError
loopEndCh chan error

// cond synchronizes completion notifications with entering Wait.
// Its lock must not be held across WinMM calls, which can wait for the callback.
cond *sync.Cond

suspended bool
Expand Down Expand Up @@ -204,7 +206,9 @@ var waveOutOpenCallback = windows.NewCallback(func(hwo, uMsg, dwInstance, dwPara
if uMsg != womDone {
return 0
}
theWinMMContext.cond.L.Lock()
theWinMMContext.cond.Signal()
theWinMMContext.cond.L.Unlock()
return 0
})

Expand Down Expand Up @@ -239,9 +243,6 @@ func (c *winmmContext) loop() {
}

func (c *winmmContext) closeLoop() (ferr error) {
c.cond.L.Lock()
defer c.cond.L.Unlock()

defer func() {
if c.loopEndCh != nil {
if ferr != nil {
Expand All @@ -268,9 +269,6 @@ func (c *winmmContext) closeLoop() (ferr error) {
}

func (c *winmmContext) appendBuffers() {
c.cond.L.Lock()
defer c.cond.L.Unlock()

if c.err.Load() != nil {
return
}
Expand Down
Loading