Fixed wrong sample count being reported for certain ogg audio files. … #3579
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.
Title.
It seems like the vorbis implementation has been somewhat buggy for some time.
After opening an ogg stream and reading its header information with
ov_info(), in certain cases (certain files) the internal stream read position isn't properly reset back to the beginning. This causes a subsequent call toov_pcm_total()to return a wrong total sample count. Reading in sample data usingov_read()based on this incorrect sample count will then return less samples than what was reported leading to the entire file failing to load. Explicitly resetting the stream read position back to the beginning of the file usingov_raw_seek()after callingov_info()seems to work around this problem.Assuming that this bug will realistically never get fixed, I don't have any reservations about building in this workaround. Glancing over the vorbis issue tracker it is unlikely most reported bugs will ever get fixed.
All the information necessary to reproduce the bug and test this fix can be found in #3578.
Fixes #3578