changeset 995:73f5e44d20d2 trunk

[svn] - add tuple handling, but i don't think i'm doing it right...
author nenolod
date Tue, 01 May 2007 08:54:31 -0700
parents 91f9925d88f1
children 34da98fd7d26
files ChangeLog src/filewriter/flac.c
diffstat 2 files changed, 39 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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 <nenolod@sacredspiral.co.uk>
+  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 <ralf@skytale.net>
   revision [2126]
   
--- 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 <FLAC/stream_encoder.h>
+#include <FLAC/all.h>
 #include <stdlib.h>
 
 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;
 }