mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
audio: Bug fix: Dead lock at seeking
When sending something to channels, a lock should not be used, or the receiver side might be using the same lock. Bug: #855
This commit is contained in:
parent
e19479d243
commit
339e76afec
@ -619,8 +619,6 @@ func (p *playerImpl) Seek(offset time.Duration) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
p.m.Lock()
|
p.m.Lock()
|
||||||
defer p.m.Unlock()
|
|
||||||
|
|
||||||
o := int64(offset) * bytesPerSample * int64(p.sampleRate) / int64(time.Second)
|
o := int64(offset) * bytesPerSample * int64(p.sampleRate) / int64(time.Second)
|
||||||
o &= mask
|
o &= mask
|
||||||
|
|
||||||
@ -630,12 +628,15 @@ func (p *playerImpl) Seek(offset time.Duration) error {
|
|||||||
}
|
}
|
||||||
pos, err := seeker.Seek(o, io.SeekStart)
|
pos, err := seeker.Seek(o, io.SeekStart)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
p.m.Unlock()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
p.buf = nil
|
p.buf = nil
|
||||||
p.pos = pos
|
p.pos = pos
|
||||||
p.srcEOF = false
|
p.srcEOF = false
|
||||||
|
p.m.Unlock()
|
||||||
|
|
||||||
p.seekCh <- struct{}{}
|
p.seekCh <- struct{}{}
|
||||||
<-p.seekedCh
|
<-p.seekedCh
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user