[Flac-dev] How do you set the Application ID value in an an Application Metadata Block?
Brian Willoughby
brianw at sounds.wa.com
Fri Apr 23 02:47:05 PDT 2010
I believe that you might be over-thinking this one. In a Smalltalk
world, everything would be an object, so you wouldn't need to assign
the Application ID manually. But even in C++ that's not a
requirement. Since you're using C, I'm almost certain that there's
nothing wrong with doing this the way you have.
Think about it this way: No matter what, you're going to have to
manually type in a C string "MYID" or a special 4-char constant
'MYID' or supply the individual characters in the proper order. The
C string would have an extraneous trailing NULL. The 4-char constant
seems to be a Mac thing, and I don't even think it's standard C, but
I could be wrong. That leaves individual characters like you're doing.
Another way to look at it is that even if there were an API, it would
require another struct to be defined so that you could pass in the 4
character ID. It's actually fairly common to use structures to pass
information to and from an API. I believe that you are using the
FLAC library correctly, unless there is an obvious
FLAC__metadata_object_application_set_id() call.
There is one thing I would recommend, though. You should probably
call FLAC__metadata_object_application_set_data() AFTER you set the
Application ID in the structure. That's because passing TRUE instead
of FALSE would copy the data elsewhere, and then your updates would
have no effect. Better to have the code ordered so that changing
that one parameter won't break everything.
Brian Willoughby
Sound Consulting
On Apr 21, 2010, at 12:50, Chris Angelli wrote:
> I have written an application that uses the FLAC C API to insert an
> application metadata block into a FLAC file. Everything appears to
> be working, but I have one nagging issue.
>
> I have used all my best google and source code searching skills and
> I cannot for the life of me find an API call to set the Application
> ID value in my metadata object. I am currently working around the
> issue by setting the value manually, but that hurts my good coding
> sense.
>
> (Note: I have already registered my ID.)
>
> Is there an API call to set the application metadata ID?
>
> Here's what I'm doing:
> myFlacMetadata = FLAC__metadata_object_new
> (FLAC__METADATA_TYPE_APPLICATION);
> FLAC__metadata_object_application_set_data (uitsFlacMetadata,
> myMetadata, myMetadataSize, FALSE);
>
> /* this is a BIG FAT NO NO, but I cannot for the life of me
> find any way in the FLAC API to set */
> /* the Application block application ID, therefore I am going
> rogue and setting it explicitly */
>
> myFlacMetadata->data.application.id[0] = 'M';
> myFlacMetadata->data.application.id[1] = 'Y';
> myFlacMetadata->data.application.id[2] = 'I';
> myFlacMetadata->data.application.id[3] = 'D';
>
>
> Thanks for any help.
>
> -chris
More information about the Flac-dev
mailing list