mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
audio/internal/readerdriver: Bug fix: some of waveOut* functions should be protected by mutex (Windows)
Updates #1652
This commit is contained in:
parent
100b42513e
commit
43789c72a9
@ -103,7 +103,7 @@ type players struct {
|
|||||||
waveOut uintptr
|
waveOut uintptr
|
||||||
headers []*header
|
headers []*header
|
||||||
|
|
||||||
// cond protects only the member 'players'.
|
// cond protects only the member 'players' and waveOut functions.
|
||||||
// The other members don't have to be protected.
|
// The other members don't have to be protected.
|
||||||
cond *sync.Cond
|
cond *sync.Cond
|
||||||
}
|
}
|
||||||
@ -233,6 +233,9 @@ func (p *players) suspend() error {
|
|||||||
if p.waveOut == 0 {
|
if p.waveOut == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.cond.L.Lock()
|
||||||
|
defer p.cond.L.Unlock()
|
||||||
if err := waveOutPause(p.waveOut); err != nil {
|
if err := waveOutPause(p.waveOut); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -243,6 +246,9 @@ func (p *players) resume() error {
|
|||||||
if p.waveOut == 0 {
|
if p.waveOut == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.cond.L.Lock()
|
||||||
|
defer p.cond.L.Unlock()
|
||||||
if err := waveOutRestart(p.waveOut); err != nil {
|
if err := waveOutRestart(p.waveOut); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -341,6 +347,8 @@ func (p *players) readAndWriteBuffers(players []*playerImpl) error {
|
|||||||
p.buf = append(p.buf, buf...)
|
p.buf = append(p.buf, buf...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.cond.L.Lock()
|
||||||
|
defer p.cond.L.Unlock()
|
||||||
for _, h := range p.headers {
|
for _, h := range p.headers {
|
||||||
if len(p.buf) < headerBufferSize {
|
if len(p.buf) < headerBufferSize {
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user