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:
Hajime Hoshi 2019-04-30 12:51:22 +09:00
parent e19479d243
commit 339e76afec

View File

@ -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