mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
parent
71e307a2fc
commit
514904392c
@ -168,9 +168,6 @@ func (p *writerPlayer) loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *writerPlayer) read() ([]byte, bool) {
|
func (p *writerPlayer) read() ([]byte, bool) {
|
||||||
p.m.Lock()
|
|
||||||
defer p.m.Unlock()
|
|
||||||
|
|
||||||
if p.context.hasError() {
|
if p.context.hasError() {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
@ -179,18 +176,20 @@ func (p *writerPlayer) read() ([]byte, bool) {
|
|||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.context.acquireSemaphore()
|
||||||
|
defer func() {
|
||||||
|
p.context.releaseSemaphore()
|
||||||
|
}()
|
||||||
|
|
||||||
|
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.acquireSemaphore()
|
|
||||||
defer func() {
|
|
||||||
p.context.releaseSemaphore()
|
|
||||||
}()
|
|
||||||
|
|
||||||
if p.readbuf == nil {
|
if p.readbuf == nil {
|
||||||
p.readbuf = make([]byte, bufSize)
|
p.readbuf = make([]byte, bufSize)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user