mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
audio: bug fix: (*Player).Position is not updated correctly
Update might not be called or delayed when the window is in background and invisible on macOS. Let's use a distinct groutine to update the audio player states. Closes #3154
This commit is contained in:
parent
20014ad5bc
commit
7b5054ca3a
@ -143,13 +143,22 @@ func NewContext(sampleRate int) *Context {
|
|||||||
c.setReady()
|
c.setReady()
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.updatePlayers(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// In the current Ebitengine implementation, update might not be called when the window is in background (#3154).
|
||||||
|
// In this case, an audio player position is not updated correctly with AppendHookOnBeforeUpdate.
|
||||||
|
// Use a distinct goroutine to update the player states.
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
if err := c.updatePlayers(); err != nil {
|
||||||
|
c.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
time.Sleep(time.Second / 100)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user