-
Notifications
You must be signed in to change notification settings - Fork 312
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
Chunk with odd-sized length before the data chunk causes the data chunk to never be read #101
Comments
It looks like this is also related to #76 (WAV File Chunk Handling ?PMX). I am sorry I did not find this earlier before making this new issue otherwise I would have posted to it. |
I was able to discover how to fix this with some code I found during a research phase on my project before decided to use TagLib. I found this over a year ago on CodeProject (this code is almost 13 years old). In the The |
Yes, when I picked up and created my fork the WAV implementation is thoroughly broken. The odd chunk size issue has never been implemented meaning that reading and writing WAV files doesn't work reliably. I have been working on this but time has been limited. There is a similar issue inside the process of writing LIST chunks as well. |
Yeah. The checking of the chunk position (odd/even) in the OP should work for both. I know for a fact that it fixes the reading of odd-sized chunks but since I am not doing any modifications to chunks I don't know about writing. |
So has anything been done with this issue? |
As far as I can tell, nothing has unless it was fixed in another branch. |
@decriptor, I just did a PR that address this "oddly" fun little bug. #115 |
All forks of TagLib# do not handle reading a chunk when the position value is odd. This happens especially if
bext
(Broadcast Wave Format) chunks are present.Having a chunk with an odd size before the
data
chunk forces TagLib# to never read thedata
chunk. Therefore the duration is never calculated as well as some other members are not populated. In the case of the audio file that I am trying to read, it has the following chunks:My
axml
chunk's size is an odd value of 495 bytes. In theTagLib.Riff.Read
method, When thewhile
loop goes to read the next chunk (which happens to be thedata
chunk), it reads thefourcc
chunk header name as\0DAT
. TagLib# only (and correctly) acceptsdata
but it is never found in theswitch
as there needs to be a one byte offset.This can easily be fixed with a single line in the
TagLib.Riff
class. In theRead
method where thedo/while
loop is, the code below should be added.I am assuming this can also happen in other formats. The above code should likely be added at least to all other
RIFF
based formats such asAIFF
andAVI
in the same location.Note: @jamsoft in his fork, which he mentions in issue #74, addresses the Broadcast Wave Format but does not take into consideration odd sized chunks (nor does he handle null XML elements but that is a different matter). Otherwise his fork is great as far as I can tell and also cleans up a lot of code style issues with this master repo.
The text was updated successfully, but these errors were encountered: