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()
|
||||
defer p.m.Unlock()
|
||||
|
||||
o := int64(offset) * bytesPerSample * int64(p.sampleRate) / int64(time.Second)
|
||||
o &= mask
|
||||
|
||||
@ -630,12 +628,15 @@ func (p *playerImpl) Seek(offset time.Duration) error {
|
||||
}
|
||||
pos, err := seeker.Seek(o, io.SeekStart)
|
||||
if err != nil {
|
||||
p.m.Unlock()
|
||||
return err
|
||||
}
|
||||
|
||||
p.buf = nil
|
||||
p.pos = pos
|
||||
p.srcEOF = false
|
||||
p.m.Unlock()
|
||||
|
||||
p.seekCh <- struct{}{}
|
||||
<-p.seekedCh
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user