-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
player.IsPlaying()
returns false before hardware finishes playing
#237
Comments
Unfortunately there is no way to detect whether the buffer that is sent to hardware is already played or not. Let me think... |
maybe guss duration of the buffer somehow and use |
I think that's what I meant by "sleeping a duration of BufferSize". Was wondering how it can be done more elegantly upstream. And uh, not really a workaround but setting the buffer size to default does it for me. |
I think it would be interesting to have per-driver guesstimates about the hardware playback position. It could be interesting to figure out what AudioContext.currentTime does. One idea, for example, is that ALSA works with periods. Say that at the moment when we just finished sending a period of audio to ALSA, and given that n periods are filled, we could make an assumption that at that time the speaker is playing sample number x. Using the samplerate we can extrapolate the sample number at later times. But keep updating the measurements. Then if you need the hardware position of the player, just account for the player's buffer size in between. This could later be expanded to allow other scheduling based playback. I don't have time for it right now but I would be happy to make a POC for ALSA at some point, and maybe Windows. I think it would be good to have a difference between |
Oof, my audio keeps getting cut off before the last second.
If I guessed correctly,
player.IsPlaying()
does not account for the hardware and will return false once it has emptied its internal buffer. And makes my program exit prematurely.Apart from sleeping a duration of BufferSize, is there any way to tell if the player really finished playing?
The text was updated successfully, but these errors were encountered: