mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
parent
d655d5f66c
commit
82050d6ac1
@ -389,9 +389,6 @@ func (p *playerImpl) loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *playerImpl) read() ([]byte, bool) {
|
func (p *playerImpl) read() ([]byte, bool) {
|
||||||
p.m.Lock()
|
|
||||||
defer p.m.Unlock()
|
|
||||||
|
|
||||||
if p.context.hasError() {
|
if p.context.hasError() {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
@ -400,18 +397,20 @@ func (p *playerImpl) read() ([]byte, bool) {
|
|||||||
return nil, false
|
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.
|
// playing can be false when pausing.
|
||||||
if !p.playing {
|
if !p.playing {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
const bufSize = 2048
|
const bufSize = 2048
|
||||||
|
|
||||||
p.context.semaphore <- struct{}{}
|
|
||||||
defer func() {
|
|
||||||
<-p.context.semaphore
|
|
||||||
}()
|
|
||||||
|
|
||||||
newBuf := make([]byte, bufSize-len(p.buf))
|
newBuf := make([]byte, bufSize-len(p.buf))
|
||||||
n, err := p.src.Read(newBuf)
|
n, err := p.src.Read(newBuf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user