mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 11:12:44 +01:00
audio: Replace 'for' with 'if' as preparation to avoid goroutine
This commit is contained in:
parent
ff8f15a212
commit
2d3c3e361e
@ -100,7 +100,7 @@ func (p *player) proceed() error {
|
|||||||
p.alBuffers = append(p.alBuffers, bufs...)
|
p.alBuffers = append(p.alBuffers, bufs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
for 0 < len(p.alBuffers) {
|
if 0 < len(p.alBuffers) {
|
||||||
n, err := p.source.Read(tmpBuffer)
|
n, err := p.source.Read(tmpBuffer)
|
||||||
if 0 < n {
|
if 0 < n {
|
||||||
buf := p.alBuffers[0]
|
buf := p.alBuffers[0]
|
||||||
@ -130,7 +130,6 @@ func (p *player) proceed() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: When is this called? Can we remove this?
|
|
||||||
func (p *player) close() error {
|
func (p *player) close() error {
|
||||||
if err := al.Error(); err != 0 {
|
if err := al.Error(); err != 0 {
|
||||||
return fmt.Errorf("audio: error before closing: %d", err)
|
return fmt.Errorf("audio: error before closing: %d", err)
|
||||||
|
@ -116,6 +116,7 @@ func newPlayer(src io.Reader, sampleRate int) (*player, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *player) proceed() error {
|
func (p *player) proceed() error {
|
||||||
|
// TODO: Read should be called only when there are buffers available?
|
||||||
b := make([]byte, bufferSize)
|
b := make([]byte, bufferSize)
|
||||||
n, err := p.src.Read(b)
|
n, err := p.src.Read(b)
|
||||||
if 0 < n {
|
if 0 < n {
|
||||||
|
Loading…
Reference in New Issue
Block a user