Mercurial > audlegacy-plugins
changeset 1432:e6eab0c725cd
Branch merge madness.
author | Tony Vroon <chainsaw@gentoo.org> |
---|---|
date | Fri, 10 Aug 2007 14:02:18 +0100 |
parents | 6b1f888a4c52 (current diff) b274ac478607 (diff) |
children | 60305596b899 |
files | |
diffstat | 6 files changed, 144 insertions(+), 105 deletions(-) [+] |
line wrap: on
line diff
--- a/src/madplug/configure.c Fri Aug 10 14:01:43 2007 +0100 +++ b/src/madplug/configure.c Fri Aug 10 14:02:18 2007 +0100 @@ -257,10 +257,6 @@ gtk_box_pack_start(GTK_BOX(title_id3_box), title_id3_entry, TRUE, TRUE, 0); - title_tag_desc = xmms_titlestring_descriptions("pafFetnygc", 2); - gtk_widget_set_sensitive(title_tag_desc, audmad_config.title_override); - gtk_box_pack_start(GTK_BOX(vbox2), title_tag_desc, FALSE, - FALSE, 0); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, gtk_label_new(_("Title")));
--- a/src/madplug/decoder.c Fri Aug 10 14:01:43 2007 +0100 +++ b/src/madplug/decoder.c Fri Aug 10 14:02:18 2007 +0100 @@ -192,7 +192,7 @@ info->duration = mad_timer_zero; // should be cleared before loop, if we use it as break condition. if(info->fileinfo_request == TRUE) { - info->tuple->length = -1; + tuple_associate_int(info->tuple, "length", -1); info->fileinfo_request = FALSE; } @@ -270,11 +270,13 @@ g_message("size = %d", stream.next_frame - stream.this_frame); #endif #endif - if(info->tuple->length == -1) + if(tuple_get_int(info->tuple, "length") == -1) mad_timer_add(&info->duration, header.duration); else { - info->duration.seconds = info->tuple->length / 1000; - info->duration.fraction = info->tuple->length % 1000; + gint length = tuple_get_int(info->tuple, "length"); + + info->duration.seconds = length / 1000; + info->duration.fraction = length % 1000; } data_used += stream.next_frame - stream.this_frame; if (info->frames == 1) { @@ -355,7 +357,7 @@ #ifdef DEBUG g_message("info->frames = %d", info->frames); #endif - if(info->tuple->length == -1) { + if(tuple_get_int(info->tuple, "length") == -1) { if(xing_bitrate > 0.0) { /* calc duration with xing info */ double tmp = 8 * (double)info->xing.bytes * 1000 / xing_bitrate; @@ -369,8 +371,10 @@ } } else { - info->duration.seconds = info->tuple->length / 1000; - info->duration.fraction = info->tuple->length % 1000; + gint length = tuple_get_int(info->tuple, "length"); + + info->duration.seconds = length / 1000; + info->duration.fraction = length % 1000; } #ifdef DEBUG g_message("using fast playtime calculation"); @@ -478,9 +482,9 @@ /* set mainwin title */ if (info->title) g_free(info->title); - info->title = xmms_get_titlestring(audmad_config.title_override == TRUE ? - audmad_config.id3_format : xmms_get_gentitle_format(), info->tuple); - + info->title = tuple_formatter_process_string(info->tuple, audmad_config.title_override == TRUE ? + audmad_config.id3_format : cfg.gentitle_format); + tlen = (gint) mad_timer_count(info->duration, MAD_UNITS_MILLISECONDS), mad_plugin->set_info(info->title, (tlen == 0 || info->size <= 0) ? -1 : tlen, @@ -704,7 +708,7 @@ g_message("e: decode"); #endif /* DEBUG */ - bmp_title_input_free(info->tuple); + mowgli_object_unref(info->tuple); info->tuple = NULL; info->playback->output->close_audio();
--- a/src/madplug/input.c Fri Aug 10 14:01:43 2007 +0100 +++ b/src/madplug/input.c Fri Aug 10 14:02:18 2007 +0100 @@ -280,7 +280,7 @@ return ret; } -gchar *input_id3_get_string(struct id3_tag * tag, char *frame_name) +gchar *input_id3_get_string(struct id3_tag * tag, const gchar *frame_name) { gchar *rtn0 = NULL, *rtn = NULL; const id3_ucs4_t *string_const = NULL; @@ -341,15 +341,24 @@ return rtn; } +static void input_set_and_free_tag(struct id3_tag *tag, Tuple *tuple, const gchar *frame, const gchar *tuple_name) +{ + gchar *scratch = input_id3_get_string(tag, frame); + + tuple_associate_string(tuple, tuple_name, scratch); + tuple_associate_string(tuple, frame, scratch); + + g_free(scratch); +} static void input_alloc_tag(struct mad_info_t *info) { - TitleInput *title_input; + Tuple *title_input; if (info->tuple == NULL) { - title_input = bmp_title_input_new(); + title_input = tuple_new(); info->tuple = title_input; - info->tuple->length = -1; //will be refferd in decoder.c + tuple_associate_int(info->tuple, "length", -1); } else title_input = info->tuple; @@ -362,14 +371,14 @@ { gchar *string = NULL; gchar *realfn = NULL; - TitleInput *title_input; + Tuple *title_input; glong curpos = 0; #ifdef DEBUG g_message("f: input_read_tag"); #endif if (info->tuple == NULL) { - title_input = bmp_title_input_new(); + title_input = tuple_new(); info->tuple = title_input; } else @@ -398,21 +407,19 @@ return; } - title_input->performer = - input_id3_get_string(info->tag, ID3_FRAME_ARTIST); - title_input->track_name = - input_id3_get_string(info->tag, ID3_FRAME_TITLE); - title_input->album_name = - input_id3_get_string(info->tag, ID3_FRAME_ALBUM); - title_input->genre = input_id3_get_string(info->tag, ID3_FRAME_GENRE); - title_input->comment = - input_id3_get_string(info->tag, ID3_FRAME_COMMENT); + input_set_and_free_tag(info->tag, title_input, ID3_FRAME_ARTIST, "artist"); + input_set_and_free_tag(info->tag, title_input, ID3_FRAME_TITLE, "title"); + input_set_and_free_tag(info->tag, title_input, ID3_FRAME_ALBUM, "album"); + input_set_and_free_tag(info->tag, title_input, ID3_FRAME_GENRE, "genre"); + input_set_and_free_tag(info->tag, title_input, ID3_FRAME_COMMENT, "comment"); + string = input_id3_get_string(info->tag, ID3_FRAME_TRACK); if (string) { - title_input->track_number = atoi(string); + tuple_associate_int(title_input, "track-number", atoi(string)); g_free(string); string = NULL; } + // year string = NULL; string = input_id3_get_string(info->tag, ID3_FRAME_YEAR); //TDRC @@ -420,34 +427,44 @@ string = input_id3_get_string(info->tag, "TYER"); if (string) { - title_input->year = atoi(string); + tuple_associate_int(title_input, "year", atoi(string)); g_free(string); string = NULL; } // length - title_input->length = -1; string = input_id3_get_string(info->tag, "TLEN"); if (string) { - title_input->length = atoi(string); + tuple_associate_int(title_input, "length", atoi(string)); #ifdef DEBUG - g_message("input_read_tag: TLEN = %d", title_input->length); + g_message("input_read_tag: TLEN = %d", atoi(string)); #endif g_free(string); string = NULL; } realfn = g_filename_from_uri(info->filename, NULL, NULL); - title_input->file_name = g_strdup(g_basename(realfn ? realfn : info->filename)); - title_input->file_path = g_path_get_dirname(realfn ? realfn : info->filename); - g_free(realfn); realfn = NULL; - if ((string = strrchr(title_input->file_name, '.'))) { - title_input->file_ext = string + 1; + + string = g_strdup(g_basename(realfn ? realfn : info->filename)); + tuple_associate_string(title_input, "file-name", string); + g_free(string); + + string = g_path_get_dirname(realfn ? realfn : info->filename); + tuple_associate_string(title_input, "file-path", string); + g_free(string); + + if ((string = strrchr(realfn ? realfn : info->filename, '.'))) { *string = '\0'; // make filename end at dot. + tuple_associate_string(title_input, "file-ext", string + 1); } - info->title = xmms_get_titlestring(audmad_config.title_override == TRUE ? - audmad_config.id3_format : xmms_get_gentitle_format(), title_input); + g_free(realfn); realfn = NULL; + + tuple_associate_string(title_input, "codec", "MPEG Audio (MP3)"); + tuple_associate_string(title_input, "quality", "lossy"); + + info->title = tuple_formatter_process_string(title_input, audmad_config.title_override == TRUE ? + audmad_config.id3_format : cfg.gentitle_format); // for connection via proxy, we have to stop transfer once. I can't explain the reason. if (info->infile != NULL) { @@ -458,11 +475,12 @@ #ifdef DEBUG g_message("e: input_read_tag"); #endif - } void input_process_remote_metadata(struct mad_info_t *info) { + gboolean metadata = FALSE; + if(info->remote && mad_timer_count(info->duration, MAD_UNITS_SECONDS) <= 0){ gchar *tmp = NULL; #ifdef DEBUG @@ -470,32 +488,41 @@ g_message("process_remote_meta"); #endif #endif + g_free(info->title); info->title = NULL; - g_free(info->tuple->track_name); - info->tuple->track_name = NULL; - g_free(info->tuple->album_name); - info->tuple->album_name = NULL; + tuple_disassociate(info->tuple, "title"); + tuple_disassociate(info->tuple, "album"); tmp = vfs_get_metadata(info->infile, "track-name"); if(tmp){ - info->tuple->track_name = str_to_utf8(tmp); - info->title = g_strdup(info->tuple->track_name); + metadata = TRUE; + gchar *scratch; + + scratch = str_to_utf8(tmp); + tuple_associate_string(info->tuple, "title", scratch); + g_free(scratch); + g_free(tmp); tmp = NULL; } tmp = vfs_get_metadata(info->infile, "stream-name"); if(tmp){ - info->tuple->album_name = str_to_utf8(tmp); + metadata = TRUE; + gchar *scratch; + + scratch = str_to_utf8(tmp); + tuple_associate_string(info->tuple, "album", scratch); + tuple_associate_string(info->tuple, "stream", scratch); + g_free(scratch); + g_free(tmp); tmp = NULL; } - if (info->tuple->track_name && info->tuple->album_name) - tmp = g_strdup_printf("%s (%s)", info->tuple->track_name, info->tuple->album_name); - else if (info->tuple->album_name) - tmp = g_strdup(info->tuple->album_name); + if (metadata) + tmp = tuple_formatter_process_string(info->tuple, "${?title:${title}}${?stream: (${stream})"); else { gchar *realfn = g_filename_from_uri(info->filename, NULL, NULL); gchar *tmp2 = g_path_get_basename(realfn ? realfn : info->filename); // info->filename is uri. --yaz @@ -637,7 +664,7 @@ g_free(info->mp3gain_minmax_str); if (info->tuple) { - bmp_title_input_free(info->tuple); + mowgli_object_unref(info->tuple); info->tuple = NULL; }
--- a/src/madplug/input.h Fri Aug 10 14:01:43 2007 +0100 +++ b/src/madplug/input.h Fri Aug 10 14:02:18 2007 +0100 @@ -28,6 +28,6 @@ gboolean input_get_info(struct mad_info_t *songinfo, gboolean fast_scan); gint input_get_data(struct mad_info_t *songinfo, guchar * buffer, gint buffer_size); -gchar *input_id3_get_string(struct id3_tag *tag, char *frame_name); +gchar *input_id3_get_string(struct id3_tag *tag, const gchar *frame_name); #endif /* ! INPUT_H */
--- a/src/madplug/plugin.c Fri Aug 10 14:01:43 2007 +0100 +++ b/src/madplug/plugin.c Fri Aug 10 14:02:18 2007 +0100 @@ -515,17 +515,17 @@ } if (input_get_info(&myinfo, info.remote ? TRUE : audmad_config.fast_play_time_calc) == TRUE) { - if(myinfo.tuple->track_name) - *title = strdup(myinfo.tuple->track_name); + if(tuple_get_string(myinfo.tuple, "track-name")) + *title = g_strdup(tuple_get_string(myinfo.tuple, "track-name")); else - *title = strdup(url); - if(myinfo.tuple->length == -1) + *title = g_strdup(url); + if(tuple_get_int(myinfo.tuple, "length") == -1) *length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS); else - *length = myinfo.tuple->length; + *length = tuple_get_int(myinfo.tuple, "length"); } else { - *title = strdup(url); + *title = g_strdup(url); *length = -1; } input_term(&myinfo); @@ -552,10 +552,10 @@ } if (input_get_info(&myinfo, info.remote ? TRUE : audmad_config.fast_play_time_calc) == TRUE) { - if(myinfo.tuple->length == -1) + if(tuple_get_int(myinfo.tuple, "length") == -1) *length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS); else - *length = myinfo.tuple->length; + *length = tuple_get_int(myinfo.tuple, "length"); } else { *length = -1; @@ -628,11 +628,16 @@ extern void audmad_get_file_info(char *filename); extern void audmad_configure(); +static void __set_and_free(Tuple *tuple, gchar *name, gchar *value) +{ + tuple_associate_string(tuple, name, value); + g_free(value); +} // tuple stuff -static TitleInput *__audmad_get_song_tuple(char *filename, VFSFile *fd) +static Tuple *__audmad_get_song_tuple(char *filename, VFSFile *fd) { - TitleInput *tuple = NULL; + Tuple *tuple = NULL; gchar *string = NULL; gchar *realfn = NULL; @@ -651,7 +656,7 @@ if(info.remote && mad_timer_count(info.duration, MAD_UNITS_SECONDS) <= 0){ if((fd && vfs_is_streaming(fd)) || (info.playback && info.playback->playing)) { gchar *tmp = NULL; - tuple = bmp_title_input_new(); + tuple = tuple_new(); #ifdef DEBUG if(info.playback) @@ -659,14 +664,24 @@ #endif tmp = vfs_get_metadata(info.infile ? info.infile : fd, "track-name"); if(tmp){ - tuple->track_name = str_to_utf8(tmp); + gchar *scratch; + + scratch = str_to_utf8(tmp); + tuple_associate_string(tuple, "title", scratch); g_free(tmp); + g_free(scratch); + tmp = NULL; } tmp = vfs_get_metadata(info.infile ? info.infile : fd, "stream-name"); if(tmp){ - tuple->album_name = str_to_utf8(tmp); + gchar *scratch; + + scratch = str_to_utf8(tmp); + tuple_associate_string(tuple, "title", scratch); g_free(tmp); + g_free(scratch); + tmp = NULL; } @@ -675,13 +690,13 @@ g_message("audmad_get_song_tuple: stream_name = %s", tuple->album_name); #endif realfn = g_filename_from_uri(filename, NULL, NULL); - tuple->file_name = g_path_get_basename(realfn ? realfn : filename); - tuple->file_path = g_path_get_dirname(realfn ? realfn : filename); - tuple->file_ext = extname(realfn ? realfn : filename); + __set_and_free(tuple, "file-name", g_path_get_basename(realfn ? realfn : filename)); + __set_and_free(tuple, "file-path", g_path_get_dirname(realfn ? realfn : filename)); + tuple_associate_string(tuple, "file-ext", extname(realfn ? realfn : filename)); g_free(realfn); realfn = NULL; - tuple->length = -1; - tuple->mtime = 0; // this indicates streaming + tuple_associate_int(tuple, "length", -1); + tuple_associate_int(tuple, "mtime", 0); // this indicates streaming #ifdef DEBUG g_message("get_song_tuple: remote: tuple"); #endif @@ -693,8 +708,6 @@ return NULL; } /* info.remote */ - tuple = bmp_title_input_new(); - // if !fd, pre-open the file with vfs_fopen() and reuse fd. if(!fd) { fd = vfs_fopen(filename, "rb"); @@ -703,18 +716,18 @@ local_fd = TRUE; } + tuple = tuple_new(); + tuple_associate_int(tuple, "length", -1); + id3file = id3_file_vfsopen(fd, ID3_FILE_MODE_READONLY); if (id3file) { tag = id3_file_tag(id3file); if (tag) { - tuple->performer = - input_id3_get_string(tag, ID3_FRAME_ARTIST); - tuple->album_name = - input_id3_get_string(tag, ID3_FRAME_ALBUM); - tuple->track_name = - input_id3_get_string(tag, ID3_FRAME_TITLE); + __set_and_free(tuple, "artist", input_id3_get_string(tag, ID3_FRAME_ARTIST)); + __set_and_free(tuple, "album", input_id3_get_string(tag, ID3_FRAME_ALBUM)); + __set_and_free(tuple, "title", input_id3_get_string(tag, ID3_FRAME_TITLE)); // year string = NULL; @@ -723,23 +736,22 @@ string = input_id3_get_string(tag, "TYER"); if (string) { - tuple->year = atoi(string); + tuple_associate_int(tuple, "year", atoi(string)); g_free(string); string = NULL; } realfn = g_filename_from_uri(filename, NULL, NULL); - tuple->file_name = g_path_get_basename(realfn ? realfn : filename); - tuple->file_path = g_path_get_dirname(realfn ? realfn : filename); - tuple->file_ext = extname(realfn ? realfn : filename); + __set_and_free(tuple, "file-name", g_path_get_basename(realfn ? realfn : filename)); + __set_and_free(tuple, "file-path", g_path_get_dirname(realfn ? realfn : filename)); + tuple_associate_string(tuple, "file-ext", extname(realfn ? realfn : filename)); g_free(realfn); realfn = NULL; // length - tuple->length = -1; string = input_id3_get_string(tag, "TLEN"); if (string) { - tuple->length = atoi(string); + tuple_associate_int(tuple, "length", atoi(string)); #ifdef DEBUG - g_message("get_song_tuple: TLEN = %d", tuple->length); + g_message("get_song_tuple: TLEN = %d", tuple_get_int(tuple, "length")); #endif g_free(string); string = NULL; @@ -748,47 +760,47 @@ char *dummy = NULL; int length = 0; audmad_get_song_length(filename, &length, fd); - tuple->length = length; + tuple_associate_int(tuple, "length", length); g_free(dummy); } // track number string = input_id3_get_string(tag, ID3_FRAME_TRACK); if (string) { - tuple->track_number = atoi(string); + tuple_associate_int(tuple, "track-number", atoi(string)); g_free(string); string = NULL; } // genre - tuple->genre = input_id3_get_string(tag, ID3_FRAME_GENRE); + __set_and_free(tuple, "genre", input_id3_get_string(tag, ID3_FRAME_GENRE)); + __set_and_free(tuple, "comment", input_id3_get_string(tag, ID3_FRAME_COMMENT)); #ifdef DEBUG g_message("genre = %s", tuple->genre); #endif - // comment - tuple->comment = - input_id3_get_string(tag, ID3_FRAME_COMMENT); - } id3_file_close(id3file); } // id3file else { // no id3tag realfn = g_filename_from_uri(filename, NULL, NULL); - tuple->file_name = g_path_get_basename(realfn ? realfn : filename); - tuple->file_path = g_path_get_dirname(realfn ? realfn : filename); - tuple->file_ext = extname(realfn ? realfn : filename); + __set_and_free(tuple, "file-name", g_path_get_basename(realfn ? realfn : filename)); + __set_and_free(tuple, "file-path", g_path_get_dirname(realfn ? realfn : filename)); + tuple_associate_string(tuple, "file-ext", extname(realfn ? realfn : filename)); g_free(realfn); realfn = NULL; // length { char *dummy = NULL; int length = 0; - if(tuple->length == -1) { + if(tuple_get_int(tuple, "length") == -1) { audmad_get_song_length(filename, &length, fd); - tuple->length = length; + tuple_associate_int(tuple, "length", length); } g_free(dummy); } } + tuple_associate_string(tuple, "quality", "lossy"); + tuple_associate_string(tuple, "codec", "MPEG Audio (MP3)"); + if(local_fd) vfs_fclose(fd); @@ -798,12 +810,12 @@ return tuple; } -static TitleInput *audmad_get_song_tuple(char *filename) +static Tuple *audmad_get_song_tuple(char *filename) { return __audmad_get_song_tuple(filename, NULL); } -static TitleInput *audmad_probe_for_tuple(char *filename, VFSFile *fd) +static Tuple *audmad_probe_for_tuple(char *filename, VFSFile *fd) { if (!audmad_is_our_fd(filename, fd)) return NULL;
--- a/src/madplug/plugin.h Fri Aug 10 14:01:43 2007 +0100 +++ b/src/madplug/plugin.h Fri Aug 10 14:02:18 2007 +0100 @@ -37,7 +37,7 @@ #include <string.h> #include <unistd.h> #include <audacious/plugin.h> -#include <audacious/titlestring.h> +#include <audacious/main.h> #include <audacious/util.h> #include <audacious/strings.h> #include <audacious/vfs.h> @@ -74,7 +74,7 @@ struct id3_tag *tag; struct id3_file *id3file; struct xing xing; - TitleInput *tuple; /* audacious tuple data */ + Tuple *tuple; /* audacious tuple data */ gchar *prev_title; /* used to optimize set_info calls */ /* replay parameters */