Skip to content

web/audio: Dynamic buffer size #9671

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

Merged

Conversation

torokati44
Copy link
Member

@torokati44 torokati44 commented Feb 22, 2023

This is not done yet, just pushing for visibility.

The goal is to:

  • Make demanding content (especially on mobile) as stutter-free as possible
  • Reduce latency on lighter content (or on powerful hardware) as much as possible

@ousia
Copy link
Contributor

ousia commented Feb 23, 2023

@torokati44,

I wonder whether the SWF mentioned in #7532 (https://www.free-culture.tk/lfc-presentation.swf) could be a good test case.

That issue describes that playing the animation at full screen (it is actually a presentation) without hardware acceleration causes suboptimal audio playing (display is a 27″-screen).

What I also accidentally discovered some days ago is that Ruffle has problems playing sound from https://www.free-culture.tk/lfc-presentation.swf, but not from https://www.free-culture.tk/free_culture.swf.

The second link in last paragraph points to the original presentation (made with Macromedia Flash 8 [to the best of my knowledge]) and the first link points to a version made with SWFTools from the same sources.

I’m going to investigate the issue further. Many thanks for your help.

@torokati44
Copy link
Member Author

Thank you for the suggestions @ousia! Once I get something that actually works, I might test those too!

@ousia
Copy link
Contributor

ousia commented Feb 24, 2023

Many thanks for your work on this PR, @torokati44.

BTW, if you feel in the mood, it would be great to have Sound.duration() info for non-standard frame rates (#6673).

@torokati44 torokati44 force-pushed the web-audio-dynamic-buffer-size branch from 5884e55 to 9f8e8ae Compare February 26, 2023 00:24
@torokati44
Copy link
Member Author

At least in my limited testing, this now appears to do what it's supposed to:

  • z0r.de/690 no longer stutters sometimes
  • z0r.de/6268 now feels more "responsive" to music

More investigation is needed though, to make sure.

@torokati44 torokati44 force-pushed the web-audio-dynamic-buffer-size branch 2 times, most recently from 726abdd to 634008f Compare February 26, 2023 14:08
@torokati44 torokati44 changed the title RFC: WIP: web: audio: Dynamic buffer size web/audio: Dynamic buffer size Feb 26, 2023
@torokati44 torokati44 marked this pull request as ready for review February 26, 2023 14:09
@torokati44 torokati44 force-pushed the web-audio-dynamic-buffer-size branch from 634008f to ec3e18f Compare February 26, 2023 14:20
@ousia
Copy link
Contributor

ousia commented Feb 27, 2023

@torokati44,

I would be more than happy to help, but I don‘t know how to get selfhosted build.

Many thanks for your excellent work.

@torokati44 torokati44 force-pushed the web-audio-dynamic-buffer-size branch 3 times, most recently from 6cf2561 to 6496cce Compare March 1, 2023 08:30
Copy link
Contributor

@Dinnerbone Dinnerbone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me but I'm definitely not an expert in this area :D

@torokati44
Copy link
Member Author

Thanks for checking it out! And, well, neither am I! 😅

@torokati44
Copy link
Member Author

Code is one thing, but it'd be great if this could get some more testing, to make sure it doesn't cause any regressions by being too opportunistic with short buffers.

@Toad06 or @n0samu, could either of you please try it out on some of your content, if you have the time of course?

@Toad06
Copy link
Member

Toad06 commented Mar 3, 2023

Forgot to mention it but I tried the PR right after it was no longer a draft.

I tested many files (including #6611 and #1673 which had issues only affecting the web build) and haven't found any regression. So this looks good to me. 😉

@torokati44
Copy link
Member Author

That's great to hear, thank you! ☺️

@n0samu
Copy link
Member

n0samu commented Mar 4, 2023

I just did a few quick tests and this seems to be working exactly as intended! In Bloons 2, which previously had very choppy audio, now the audio is delayed but mostly smooth, except in the very most demanding sections. And games that ran smoothly seem unchanged, with no additional audio delay introduced. Nicely done! 😃

@torokati44
Copy link
Member Author

Thanks to you too, and also good to hear! ^^

@torokati44 torokati44 force-pushed the web-audio-dynamic-buffer-size branch 3 times, most recently from d809aee to e682898 Compare March 9, 2023 13:06
@Dinnerbone Dinnerbone force-pushed the web-audio-dynamic-buffer-size branch from e682898 to ae7a9f3 Compare March 11, 2023 21:19
@Dinnerbone Dinnerbone merged commit 3a8ee00 into ruffle-rs:master Mar 11, 2023
@ousia
Copy link
Contributor

ousia commented Mar 13, 2023

@torokati44, sorry but I’m afraid that right now I don’t have access to the device that caused #7532.

I hope to have it in a not so distant future and be able to close that issue.

Many thanks for your help and your code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants