Mercurial > audlegacy-plugins
changeset 1441:1b52e7eacd4c
filewriter: new tuple API
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Fri, 10 Aug 2007 09:47:23 -0500 |
parents | 90af998f55fa |
children | 95b8abed24c7 |
files | src/filewriter/filewriter.c src/filewriter/filewriter.h src/filewriter/flac.c src/filewriter/mp3.c src/filewriter/vorbis.c |
diffstat | 5 files changed, 44 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/src/filewriter/filewriter.c Fri Aug 10 09:30:21 2007 -0500 +++ b/src/filewriter/filewriter.c Fri Aug 10 09:47:23 2007 -0500 @@ -215,7 +215,7 @@ if (filenamefromtags) { - gchar *utf8 = xmms_get_titlestring(xmms_get_gentitle_format(), tuple); + gchar *utf8 = tuple_formatter_process_string(tuple, cfg.gentitle_format); g_strchomp(utf8); //chop trailing ^J --yaz @@ -226,7 +226,7 @@ } if (filename == NULL) { - filename = g_strdup(tuple->file_name); + filename = g_strdup(tuple_get_string(tuple, "file-name")); if (!use_suffix) if ((temp = strrchr(filename, '.')) != NULL) *temp = '\0'; @@ -238,8 +238,8 @@ if (prependnumber) { gint number; - if (tuple && tuple->track_number) - number = tuple->track_number; + if (tuple && tuple_get_int(tuple, "track-number")) + number = tuple_get_int(tuple, "track-number"); else number = pos + 1; @@ -250,7 +250,7 @@ gchar *directory; if (save_original) - directory = g_strdup(tuple->file_path); + directory = g_strdup(tuple_get_string(tuple, "file-path")); else directory = g_strdup(file_path); @@ -665,4 +665,4 @@ VFSFile *output_file = NULL; guint64 written = 0; guint64 offset = 0; -TitleInput *tuple = NULL; +Tuple *tuple = NULL;
--- a/src/filewriter/filewriter.h Fri Aug 10 09:30:21 2007 -0500 +++ b/src/filewriter/filewriter.h Fri Aug 10 09:47:23 2007 -0500 @@ -29,6 +29,7 @@ #include <stdio.h> #include <string.h> +#include <audacious/main.h> #include <audacious/plugin.h> #include <audacious/playlist.h> #include <audacious/configdb.h> @@ -45,7 +46,7 @@ extern VFSFile *output_file; extern guint64 written; extern guint64 offset; -extern TitleInput *tuple; +extern Tuple *tuple; typedef struct _FileWriter FileWriter;
--- a/src/filewriter/flac.c Fri Aug 10 09:30:21 2007 -0500 +++ b/src/filewriter/flac.c Fri Aug 10 09:47:23 2007 -0500 @@ -107,14 +107,14 @@ 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"); + INSERT_VORBIS_COMMENT(tuple_get_string(tuple, "title"), "title=%s"); + INSERT_VORBIS_COMMENT(tuple_get_string(tuple, "artist"), "artist=%s"); + INSERT_VORBIS_COMMENT(tuple_get_string(tuple, "album"), "album=%s"); + INSERT_VORBIS_COMMENT(tuple_get_string(tuple, "genre"), "genre=%s"); + INSERT_VORBIS_COMMENT(tuple_get_string(tuple, "comment"), "comment=%s"); + INSERT_VORBIS_COMMENT(tuple_get_string(tuple, "date"), "date=%s"); + INSERT_VORBIS_COMMENT(tuple_get_int(tuple, "year"), "year=%d"); + INSERT_VORBIS_COMMENT(tuple_get_int(tuple, "track-number"), "tracknumber=%d"); FLAC__stream_encoder_set_metadata(flac_encoder, &meta, 1); }
--- a/src/filewriter/mp3.c Fri Aug 10 09:30:21 2007 -0500 +++ b/src/filewriter/mp3.c Fri Aug 10 09:47:23 2007 -0500 @@ -201,24 +201,24 @@ if (tuple) { /* XXX write UTF-8 even though libmp3lame does id3v2.3. --yaz */ #ifdef DEBUG - g_print("track_name = %s\n", tuple->track_name); + g_print("track_name = %s\n", tuple_get_string(tuple, "title")); #endif - lameid3.track_name = g_strdup(tuple->track_name); + lameid3.track_name = g_strdup(tuple_get_string(tuple, "title")); id3tag_set_title(gfp, lameid3.track_name); - lameid3.performer = g_strdup(tuple->performer); + lameid3.performer = g_strdup(tuple_get_string(tuple, "artist")); id3tag_set_artist(gfp, lameid3.performer); - lameid3.album_name = g_strdup(tuple->album_name); + lameid3.album_name = g_strdup(tuple_get_string(tuple, "album")); id3tag_set_album(gfp, lameid3.album_name); - lameid3.genre = g_strdup(tuple->genre); + lameid3.genre = g_strdup(tuple_get_string(tuple, "genre")); id3tag_set_genre(gfp, lameid3.genre); - lameid3.year = g_strdup_printf("%d", tuple->year); + lameid3.year = g_strdup_printf("%d", tuple_get_int(tuple, "year")); id3tag_set_year(gfp, lameid3.year); - lameid3.track_number = g_strdup_printf("%d", tuple->track_number); + lameid3.track_number = g_strdup_printf("%d", tuple_get_int(tuple, "track-number")); id3tag_set_track(gfp, lameid3.track_number); // id3tag_write_v1(gfp);
--- a/src/filewriter/vorbis.c Fri Aug 10 09:30:21 2007 -0500 +++ b/src/filewriter/vorbis.c Fri Aug 10 09:47:23 2007 -0500 @@ -84,33 +84,33 @@ if (tuple) { - gchar *scratch; + const gchar *scratch; - if (tuple->track_name) - vorbis_comment_add_tag(&vc, "title", tuple->track_name); - if (tuple->performer) - vorbis_comment_add_tag(&vc, "artist", tuple->performer); - if (tuple->album_name) - vorbis_comment_add_tag(&vc, "album", tuple->album_name); - if (tuple->genre) - vorbis_comment_add_tag(&vc, "genre", tuple->genre); - if (tuple->date) - vorbis_comment_add_tag(&vc, "date", tuple->date); - if (tuple->comment) - vorbis_comment_add_tag(&vc, "comment", tuple->comment); + if ((scratch = tuple_get_string(tuple, "title"))) + vorbis_comment_add_tag(&vc, "title", (gchar *) scratch); + if ((scratch = tuple_get_string(tuple, "artist"))) + vorbis_comment_add_tag(&vc, "artist", (gchar *) scratch); + if ((scratch = tuple_get_string(tuple, "album"))) + vorbis_comment_add_tag(&vc, "album", (gchar *) scratch); + if ((scratch = tuple_get_string(tuple, "genre"))) + vorbis_comment_add_tag(&vc, "genre", (gchar *) scratch); + if ((scratch = tuple_get_string(tuple, "date"))) + vorbis_comment_add_tag(&vc, "date", (gchar *) scratch); + if ((scratch = tuple_get_string(tuple, "comment"))) + vorbis_comment_add_tag(&vc, "comment", (gchar *) scratch); - if (tuple->track_number) + if (tuple_get_int(tuple, "track-number")) { - scratch = g_strdup_printf("%d", tuple->track_number); - vorbis_comment_add_tag(&vc, "tracknumber", scratch); - g_free(scratch); + gchar *tmp = g_strdup_printf("%d", tuple_get_int(tuple, "track-number")); + vorbis_comment_add_tag(&vc, "tracknumber", tmp); + g_free(tmp); } - if (tuple->year) + if (tuple_get_int(tuple, "year")) { - scratch = g_strdup_printf("%d", tuple->year); - vorbis_comment_add_tag(&vc, "year", scratch); - g_free(scratch); + gchar *tmp = g_strdup_printf("%d", tuple_get_int(tuple, "year")); + vorbis_comment_add_tag(&vc, "year", tmp); + g_free(tmp); } }