Mercurial > audlegacy-plugins
changeset 1435:654aa79e43ef
flacng: new tuple API
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Fri, 10 Aug 2007 08:42:59 -0500 |
parents | 60305596b899 |
children | 0ff7d08693f6 |
files | src/flacng/flacng.h src/flacng/plugin.c src/flacng/plugin.h src/flacng/tools.c src/flacng/tools.h |
diffstat | 5 files changed, 22 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/src/flacng/flacng.h Fri Aug 10 08:19:51 2007 -0500 +++ b/src/flacng/flacng.h Fri Aug 10 08:42:59 2007 -0500 @@ -21,6 +21,7 @@ #include <glib.h> #include <audacious/plugin.h> +#include <audacious/main.h> #include <audacious/vfs.h> #include <audacious/i18n.h> # include "config.h"
--- a/src/flacng/plugin.c Fri Aug 10 08:19:51 2007 -0500 +++ b/src/flacng/plugin.c Fri Aug 10 08:42:59 2007 -0500 @@ -687,10 +687,10 @@ /* --- */ -TitleInput *flac_get_song_tuple(gchar* filename) { +Tuple *flac_get_song_tuple(gchar* filename) { VFSFile *fd; - TitleInput *tuple; + Tuple *tuple; _ENTER;
--- a/src/flacng/plugin.h Fri Aug 10 08:19:51 2007 -0500 +++ b/src/flacng/plugin.h Fri Aug 10 08:42:59 2007 -0500 @@ -10,6 +10,6 @@ void flac_pause(InputPlayback* input, gshort p); void flac_seek(InputPlayback* input, gint time); void flac_get_song_info(gchar* filename, gchar** title, gint* length); -TitleInput *flac_get_song_tuple(gchar* filename); +Tuple *flac_get_song_tuple(gchar* filename); #endif
--- a/src/flacng/tools.c Fri Aug 10 08:19:51 2007 -0500 +++ b/src/flacng/tools.c Fri Aug 10 08:42:59 2007 -0500 @@ -231,48 +231,36 @@ /* --- */ -static const gchar* get_extension(const gchar* filename) { - - _ENTER; +Tuple* get_tuple(const gchar* filename, callback_info* info) { - const gchar *ext = strrchr(filename, '.'); - _LEAVE ext ? ext + 1 : NULL; -} - -/* --- */ - -TitleInput* get_tuple(const gchar* filename, callback_info* info) { - - TitleInput *out; + Tuple *out; _ENTER; _DEBUG("Using callback_info %s", info->name); - out = bmp_title_input_new(); - - out->file_name = g_path_get_basename(filename); - out->file_ext = get_extension(filename); - out->file_path = g_path_get_dirname(filename); + out = tuple_new_from_filename(filename); - out->performer = g_strdup(info->comment.artist); - out->track_name = g_strdup(info->comment.title); - out->album_name = g_strdup(info->comment.album); - out->genre = g_strdup(info->comment.genre); + tuple_associate_string(out, "artist", info->comment.artist); + tuple_associate_string(out, "title", info->comment.title); + tuple_associate_string(out, "album", info->comment.album); + tuple_associate_string(out, "genre", info->comment.genre); + if (info->comment.tracknumber != NULL) - out->track_number = atoi(info->comment.tracknumber); + tuple_associate_int(out, "track-number", atoi(info->comment.tracknumber)); + if (info->comment.date != NULL) - out->year = atoi(info->comment.date); + tuple_associate_int(out, "year", atoi(info->comment.date)); /* * Calculate the stream length (milliseconds) */ if (0 == info->stream.samplerate) { _ERROR("Invalid sample rate for stream!"); - out->length = -1; + tuple_associate_int(out, "length", -1); } else { - out->length = (info->stream.samples / info->stream.samplerate) * 1000; - _DEBUG("Stream length: %d seconds", out->length / 1000); + tuple_associate_int(out, "length", (info->stream.samples / info->stream.samplerate) * 1000); + _DEBUG("Stream length: %d seconds", tuple_get_int(out, "length")); } _DEBUG("Tuple created: [%p]", out); @@ -284,7 +272,7 @@ gchar* get_title(const gchar* filename, callback_info* info) { - TitleInput *input; + Tuple *input; gchar *title; _ENTER; @@ -293,10 +281,9 @@ input = get_tuple(filename, info); - if (!(title = xmms_get_titlestring(xmms_get_gentitle_format(), input))) - title = g_strdup(input->file_name); + title = tuple_formatter_process_string(input, cfg.gentitle_format); - bmp_title_input_free(input); + mowgli_object_unref(input); _DEBUG("Title created: <%s>", title);
--- a/src/flacng/tools.h Fri Aug 10 08:19:51 2007 -0500 +++ b/src/flacng/tools.h Fri Aug 10 08:42:59 2007 -0500 @@ -42,7 +42,7 @@ callback_info* init_callback_info(gchar* name); void reset_info(callback_info* info, gboolean close_fd); gchar* get_title(const gchar* filename, callback_info* info); -TitleInput *get_tuple(const gchar *filename, callback_info* info); +Tuple *get_tuple(const gchar *filename, callback_info* info); void add_comment(callback_info* info, gchar* key, gchar* value); gboolean read_metadata(VFSFile* fd, FLAC__StreamDecoder* decoder, callback_info* info);