Hey!<br><br> So, I'm clearly doing something wrong, because I've
written a program to view and modify the comment tags in a FLAC file,
which appears to be embedded an Ogg stream. This particular file also
has ID3 headers at the beginning, but I was planning on ignoring those
and fixing them up using some ID3 code later on ...<br><br> Now, to read the comments is quite simple:<br><br> FLAC__metadata_get_tags<div>(fileName, &tagData);<br> ...<br> ..<br> .<br> FLAC__metadata_object_delete(tagData);
<br><br><br><br>
For writing to the file, however, I do something along the following
lines (error code stripped out to keep things shorter), this is pretty much as
the flac documentation suggests:
<br><br> result = FLAC__metadata_simple_iterator_init(iterator, fileName, FALSE, FALSE);<br><br> /**<br> * Zip through the file for the vorbis comment section.<br> */<br> while (FLAC__metadata_simple_iterator_get_block_type(iterator) != FLAC__METADATA_TYPE_VORBIS_COMMENT)
<br> {<br> result = FLAC__metadata_simple_iterator_next(iterator);<br> }<br><br> /**<br> * Get the current block and write out the new values for it.<br> */<br> metaData = FLAC__metadata_simple_iterator_get_block(iterator);
<br><br> /**<br> * Save the strings out.<br> */<br> [self saveCommentsToIterator: metaData];<br><br> /**<br> * Now, save out the block.<br> */<br> result = FLAC__metadata_simple_iterator_set_block(iterator, metaData, TRUE);
<br><br> FLAC__metadata_simple_iterator_delete(metaData);<br><br><br>
the saveCommentsToIterator method just updates the "entry" and "length"
fields of those comment entries in the vorbis_comments that have
changed. (is that perhaps not correct?) .... hexdumping the file after
writing seems to show a new comment block with the appropriate new
values in it ... <br><br> The problem, which the docs hinted at:<br><br> - if the comments are shorter or not much longer: everything works great<br>
- if the comments are much longer: the file appears to be rewritten.
hexdump -C shows that the ID3 header is destroyed (not a problem,
really) and the file now has a 'fLaC' binary signature at the top.
(again, no problem -- other FLAC files appear to have this).
<br><br> This new file, however, cannot be read in by the above code
using FLAC__metadata_get_tags. It barfs internally while trying to
read some metadata chunks from the file (not the first one, either).<br><br>
Any idea why the newly written file cannot be read by my program any
more? Programs that play audio, such as VLC, can still play the FLAC
file just fine ....
<br><br> Any pointers to what I'm doing wrong would be greatly appreciated.<br><br> Thanks,<br></div><span class="sg"> marc.</span>