Skip to content

avm1: implement Sound getBytesTotal(), getBytesLoaded() #20235

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

InvoxiPlayGames
Copy link
Contributor

This PR adds more correct functionality to getBytesLoaded() and getBytesTotal() - returning the actual number of bytes loaded from the network / from disk rather than always returning 1, as well as returning undefined on getBytesLoaded when loadSound has not been called and on getBytesTotal when the total length is unknown (request not completed).

This fixes https://old.homestarrunner.com/qod.swf - with extra debug logging added to aforementioned Flash file, the trace output between Ruffle and Flash matches with this PR applied.

@Lord-McSweeney Lord-McSweeney added A-avm1 Area: AVM1 (ActionScript 1 & 2) T-fix Type: Bug fix (in something that's supposed to work already) labels Apr 21, 2025
@kjarosh kjarosh added T-compat Type: Compatibility with Flash Player and removed T-fix Type: Bug fix (in something that's supposed to work already) labels Apr 21, 2025
@n0samu
Copy link
Member

n0samu commented Apr 23, 2025

Could someone test #12685? This is a very exciting development, thank you!!

@InvoxiPlayGames
Copy link
Contributor Author

That game (fl0w) is able to stream its audio without starting it prematurely with this PR but it doesn't play it back. :/

Copy link
Collaborator

@adrian17 adrian17 left a comment

Choose a reason for hiding this comment

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

The code looks fine - that said, couldn't we mirror what AVM2 does here? As in, in avm2 sound.bytesLoaded/bytesTotal, we obtain the SoundHandle from the object and call audio.get_sound_size. Does this make any difference in behavior vs storing the state up front?

@InvoxiPlayGames
Copy link
Contributor Author

Does this make any difference in behavior vs storing the state up front?

I'm unsure - I did it this way due to the way the function call returns undefined in different scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-avm1 Area: AVM1 (ActionScript 1 & 2) newsworthy T-compat Type: Compatibility with Flash Player
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants