Repository navigation
fix: seek disk-streamed MP3s from a seek table instead of decoding from the start - #636
Merged
Merged
Conversation
- the table is the sound's and its voices share it: play() no longer reads the whole file twice to start a voice - a table that cannot be built leaves no voice decoder part way through the file - test: starting a voice reads only the head of the file, and a second voice seeks as well - changelog, dartdoc and loading skill
2 of 7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Supersedes #634 by @Fmarschall, whose commit is the first one here, unchanged. Its branch is in a fork owned by an organization, which maintainers cannot push to, so the additions are in this PR.
The change of #634
LoadMode.diskseeks withdrmp3_seek_to_pcm_frame, and no seek table was bound to the decoder. dr_mp3 then seeks backwards by decoding the file from its first frame up to the target, under the audio mutex: a seek near the end of a song read most of the file, a seek slider stuttered and every voice dropped out until the seek finished.drmp3_calculate_seek_pointsfrom the frame headers, is now bound to the decoder. It holds four points a second, at most 16384, 24 bytes each. dr_mp3 itself is unchanged; the change is a marked local patch insoloud_wavstream.cpp/.h.LoadMode.memoryfor MP3s that are sought are removed.Added on top
The table is built once, when the sound is loaded, and its voices share it. In fix: seek disk-streamed MP3s from a seek table instead of decoding from the start #634 every voice built its own when it started, which reads the whole file twice on the thread that calls
play().mainLoading the 170 MB file goes from 42 ms to about 120 ms, in the loader isolate. Measured on an M-series Mac with the files in the page cache.
The table belongs to the sound, so a voice no longer keeps a copy (up to 393 KB), and a table that cannot be built leaves no voice decoder part way through the file.
mainis merged in (web: LoadMode.disk streams the compressed data instead of decoding it whole #635), and the web binaries are rebuilt, in their own commit: with web: LoadMode.disk streams the compressed data instead of decoding it whole #635LoadMode.diskstreams on the web too, so the change is reachable there.Changelog, dartdoc and the loading skill say that the sound, not the voice, builds the table.
Type of Change