-
Notifications
You must be signed in to change notification settings - Fork 135
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
Add Context.SetReadBufferSize. #160
Conversation
This is useful for cases where you may need to sync visuals with audio.
Thanks, but this kind of change requires discussions before the implementation... |
For a real-time streaming, I think it is possible by
and actually Tinne (in Ebiten Discord) created a proof of concept. What do you think? |
Sorry for dropping this code like this, I just wanted a starting point to discuss around! I'm not sure if the suggested solution works, or I'm not sure that I fully understand it. With mGBA it works something like:
I don't think it's possible to adjust the writing pace in this case, because the received audio has to play immediately and the buffer size is fixed. I can return the written buffer size from the io.Reader.Read method, but Oto will cause a significant delay. |
The So, it works, but I admit this is not an elegant solution. It is in theory possible to adjust the amount of writing with I'm OK to give a way to adjust the buffer size. My thoughts are:
Thanks, |
I think that works for me -- do you have a code example for adjusting the pace wth UnplayedBufferSize actually, in case I'm missing something here? Adjusting the buffer size at the per-player level works for me. I'm not sure what the behavior on browsers is, unfortunately. |
This is reference code I used for ebiten. It's admittedly not ideal, and it's ebiten, not oto directly, but it should help you get the idea. I don't know if in oto it's possible to call It's possible to work without unsafe, but I had this in hand. You can go at ~16ms latency with this, which should be at least acceptable for your use-case. Notice that this relies on ebiten's v2.3.0-alpha.5.0.20220321170451-d6596369abc4. |
Thank you so much! I'll close this PR. |
Thanks, it works! |
This is useful for cases where you may need to sync visuals with audio.
The use case I have is with mGBA, where the buffer size needs to be consistent between the emulator and the system sound driver. The automatic sizing from Oto is too large and causes audio delays :(