mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
The `Loader` uses a `Vector<Sample>` to store any samples that the actual audio decoder returned that the loader client did not request yet. However, it did not take that buffer into account when those clients asked for the number of samples loaded. The buffer is an internal implementation detail, and should not be reflected on the external API. This allows LibWeb to keep better track of audio position without any desync caused by the buffer. When using the Serenity `PlaybackStream` implementation as the back end for an `HTMLAudioElement`, this allows us to perfectly stop on the exact last sample of the audio file, so it will not stop before the media element can see that it has finished playback. Note that `Loader::get_more_samples()` also calls `loaded_samples()` to determine how many samples are remaining to load into the output buffer. However, this change appears to be correct even there, given that the samples copied from the internal sample buffer are included in that count.
4.1 KiB
4.1 KiB