# HG changeset patch # User nenolod # Date 1178034871 25200 # Node ID 73f5e44d20d213022be09d6c7db0ed9dfd468a2b # Parent 91f9925d88f15175f0059ea25e62c7ea6846b339 [svn] - add tuple handling, but i don't think i'm doing it right... diff -r 91f9925d88f1 -r 73f5e44d20d2 ChangeLog --- a/ChangeLog Tue May 01 08:33:07 2007 -0700 +++ b/ChangeLog Tue May 01 08:54:31 2007 -0700 @@ -1,3 +1,11 @@ +2007-05-01 15:33:07 +0000 William Pitcock + revision [2128] + - use my version for now as r2126 does not work + + trunk/src/filewriter/flac.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + + 2007-05-01 15:30:24 +0000 Ralf Ertzinger revision [2126] diff -r 91f9925d88f1 -r 73f5e44d20d2 src/filewriter/flac.c --- a/src/filewriter/flac.c Tue May 01 08:33:07 2007 -0700 +++ b/src/filewriter/flac.c Tue May 01 08:54:31 2007 -0700 @@ -20,7 +20,7 @@ */ #include "plugins.h" -#include +#include #include static gint flac_open(void); @@ -74,6 +74,17 @@ return FLAC__STREAM_ENCODER_TELL_STATUS_OK; } +#define INSERT_VORBIS_COMMENT(t, keyword) \ + if (t) \ + { \ + gchar *scratch = g_strdup_printf(keyword, t); \ + comment_entry.length = strlen(scratch); \ + comment_entry.entry = (guchar *) scratch; \ + FLAC__metadata_object_vorbiscomment_insert_comment(meta, \ + meta->data.vorbis_comment.num_comments, comment_entry, TRUE); \ + g_free(scratch); \ + } + static gint flac_open(void) { written = 0; @@ -86,6 +97,25 @@ FLAC__stream_encoder_init_stream(flac_encoder, flac_write_cb, flac_seek_cb, flac_tell_cb, NULL, output_file); + if (tuple) + { + FLAC__StreamMetadata *meta; + FLAC__StreamMetadata_VorbisComment_Entry comment_entry; + + meta = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT); + + INSERT_VORBIS_COMMENT(tuple->track_name, "title=%s"); + INSERT_VORBIS_COMMENT(tuple->performer, "artist=%s"); + INSERT_VORBIS_COMMENT(tuple->album_name, "album=%s"); + INSERT_VORBIS_COMMENT(tuple->genre, "genre=%s"); + INSERT_VORBIS_COMMENT(tuple->comment, "comment=%s"); + INSERT_VORBIS_COMMENT(tuple->date, "date=%s"); + INSERT_VORBIS_COMMENT(tuple->year, "year=%d"); + INSERT_VORBIS_COMMENT(tuple->track_number, "tracknumber=%d"); + + FLAC__stream_encoder_set_metadata(flac_encoder, &meta, 1); + } + return 1; }