Repository navigation
fix(media): skip the RIFF pad byte after odd-sized WAV chunks - #315
Merged
Merged
Conversation
WavReader moved on by exactly the declared chunk size, so one odd-sized chunk before the data chunk shifted the rest of the walk by a byte and the file was rejected with "No data chunk found in WAV file".
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.
WavReadermoves past a chunk by exactly its declared size. RIFF chunks are word-aligned, so an odd-sized chunk is followed by a pad byte that the size doesn't count. One such chunk beforedatashifts the rest of the walk by a byte and the file is rejected withNo data chunk found in WAV file:FileAudioSource::newfails, andestimate_audio_durationfalls back to 5 s.load_wav_pcm16(hold music) already rounds the size up, so the same file works there.Example, with a 627-byte
bextchunk:Before: the error above. After: 4000 samples, 500 ms.
The byte is only consumed when it is there (zero), so files written without it, which the reader accepts today (
test_list_and_fact_chunks), still parse.Two new tests fail without the change.
cargo test -p rustpbx-media --lib: 457 passed, 9 ignored.cargo test --workspace --lib: 3138 passed.e2e_core: 578 passed, withRUST_MIN_STACK=67108864, because the debug build aborts on my Mac without it (on main too).