mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-22 07:50:08 +01:00
parent
f488988384
commit
53c300a93f
@ -439,9 +439,6 @@ func (p *playerImpl) loop() {
|
||||
}
|
||||
|
||||
func (p *playerImpl) read() ([]byte, bool) {
|
||||
p.m.Lock()
|
||||
defer p.m.Unlock()
|
||||
|
||||
if p.context.hasError() {
|
||||
return nil, false
|
||||
}
|
||||
@ -450,18 +447,20 @@ func (p *playerImpl) read() ([]byte, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
p.context.semaphore <- struct{}{}
|
||||
defer func() {
|
||||
<-p.context.semaphore
|
||||
}()
|
||||
|
||||
p.m.Lock()
|
||||
defer p.m.Unlock()
|
||||
|
||||
// playing can be false when pausing.
|
||||
if !p.playing {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
const bufSize = 2048
|
||||
|
||||
p.context.semaphore <- struct{}{}
|
||||
defer func() {
|
||||
<-p.context.semaphore
|
||||
}()
|
||||
|
||||
newBuf := make([]byte, bufSize-len(p.buf))
|
||||
n, err := p.src.Read(newBuf)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user