Mercurial > audlegacy-plugins
changeset 1560:e5a0c508c025
Merged.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 02 Sep 2007 23:00:33 +0300 |
parents | 6b4e47c5ca67 (current diff) c8c725957643 (diff) |
children | 88878ed02ca0 |
files | |
diffstat | 2 files changed, 82 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/src/adplug/adplug-xmms.cc Sun Sep 02 22:58:45 2007 +0300 +++ b/src/adplug/adplug-xmms.cc Sun Sep 02 23:00:33 2007 +0300 @@ -31,13 +31,13 @@ #include "emuopl.h" #include "silentopl.h" #include "players.h" -#include "audacious/plugin.h" -#include "audacious/util.h" -#include "audacious/configdb.h" -#include <audacious/i18n.h> +#include "audacious/i18n.h" extern "C" { +#include "audacious/configdb.h" +#include "audacious/plugin.h" #include "audacious/output.h" +#include "audacious/util.h" } @@ -679,6 +679,48 @@ /***** Main player (!! threaded !!) *****/ +static Tuple* +adplug_get_tuple (char *filename) +{ + CSilentopl tmpopl; + VFSFile *fd = vfs_buffered_file_new_from_uri (filename); + + if (!fd) + return NULL; + + CPlayer *p = factory (fd, &tmpopl); + + if (p) + { + Tuple *ti = tuple_new_from_filename(filename); + if (! p->getauthor().empty()) + tuple_associate_string(ti, "artist", p->getauthor().c_str()); + if (! p->gettitle().empty()) + tuple_associate_string(ti, "title", p->gettitle().c_str()); + else if (! p->getdesc().empty()) + tuple_associate_string(ti, "title", p->getdesc().c_str()); + else + tuple_associate_string(ti, "title", g_path_get_basename(filename)); + tuple_associate_string(ti, "codec", p->gettype().c_str()); + tuple_associate_string(ti, "quality", "sequenced"); + tuple_associate_int(ti, "length", p->songlength (plr.subsong)); + delete p; + return ti; + } + + return NULL; +} + +static char* format_and_free_ti( Tuple* ti, int* length ) +{ + char* result = tuple_formatter_make_title_string(ti, get_gentitle_format()); + if ( result ) + *length = tuple_get_int(ti, "length"); + tuple_free((void *) ti); + + return result; +} + static void update_infobox (void) { @@ -711,6 +753,7 @@ CEmuopl opl (cfg.freq, cfg.bit16, cfg.stereo); long toadd = 0, i, towrite; char *sndbuf, *sndbufpos; + int songlength; bool playing = true, // Song self-end indicator. bit16 = cfg.bit16, // Duplicate config, so it doesn't affect us if stereo = cfg.stereo; // the user changes it while we're playing. @@ -737,17 +780,14 @@ return (NULL); } - // Cache song length - dbg_printf ("length, "); - plr.songlength = plr.p->songlength (plr.subsong); - - // cache song title + // cache song title & length from tuple dbg_printf ("title, "); - if (!plr.p->gettitle ().empty ()) + Tuple* ti = adplug_get_tuple(filename); + if (ti) { - plr.songtitle = (char *) malloc (plr.p->gettitle ().length () + 1); - strcpy (plr.songtitle, plr.p->gettitle ().c_str ()); + plr.songtitle = format_and_free_ti( ti, &songlength ); } + plr.songlength = songlength; // reset to first subsong on new file dbg_printf ("subsong, "); @@ -921,36 +961,12 @@ static void adplug_song_info (char *filename, char **title, int *length) { - CSilentopl tmpopl; - VFSFile *fd = vfs_buffered_file_new_from_uri (filename); - - if (!fd) - return; - - CPlayer *p = factory (fd, &tmpopl); - - dbg_printf ("adplug_song_info(\"%s\", \"%s\", %d): ", filename, *title, - *length); + *length = -1; + *title = NULL; - if (p) - { - // allocate and set title string - if (p->gettitle ().empty ()) - *title = 0; - else - { - *title = (char *) malloc (p->gettitle ().length () + 1); - strcpy (*title, p->gettitle ().c_str ()); - } - - // get song length - *length = p->songlength (plr.subsong); - - // delete temporary player object - delete p; - } - - dbg_printf ("title = \"%s\", length = %d\n", *title, *length); + Tuple* ti = adplug_get_tuple( filename ); + if ( ti ) + *title = format_and_free_ti( ti, length ); } /***** Player control *****/ @@ -1138,9 +1154,9 @@ NULL, // set_info (filled by XMMS) NULL, // set_info_text (filled by XMMS) adplug_song_info, - adplug_info_box, // adplug_info_box was here (but it used deprecated GTK+ functions) + adplug_info_box, NULL, // output plugin (filled by XMMS) - NULL, + adplug_get_tuple, NULL, NULL, adplug_is_our_fd, @@ -1150,3 +1166,4 @@ InputPlugin *adplug_iplist[] = { &adplug_ip, NULL }; DECLARE_PLUGIN(adplug, NULL, NULL, adplug_iplist, NULL, NULL, NULL, NULL,NULL); +
--- a/src/cue/cuesheet.c Sun Sep 02 22:58:45 2007 +0300 +++ b/src/cue/cuesheet.c Sun Sep 02 23:00:33 2007 +0300 @@ -178,7 +178,7 @@ gint i; /* add the files, build cue urls, etc. */ - cache_cue_file(filename); + cache_cue_file(filename); //filename should be uri. for (i = 0; i < last_cue_track; i++) { @@ -203,10 +203,11 @@ static void play(InputPlayback *data) { - gchar *uri = data->filename; + gchar *uri = g_strdup(data->filename); #ifdef DEBUG g_print("play: playback = %p\n", data); + g_print("play: uri = %s\n", uri); #endif caller_ip = data; @@ -214,13 +215,13 @@ if (strncasecmp("cue://", uri, 6)) { gchar *tmp = g_strdup_printf("cue://%s?0", uri); - play_cue_uri(data, tmp); - g_free(tmp); - return; + g_free(uri); + uri = tmp; } play_thread = g_thread_self(); - data->set_pb_ready(data); + data->set_pb_ready(data); // it should be done in real input plugin? --yaz play_cue_uri(data, uri); + g_free(uri); uri = NULL; } static Tuple *get_tuple(gchar *uri) @@ -264,11 +265,13 @@ track = atoi(_path); } - cache_cue_file(path2); + cache_cue_file(path2); //path2 should be uri. if (cue_file == NULL) return NULL; - +#ifdef DEBUG + g_print("cue_file = %s\n", cue_file); +#endif pr = input_check_file(cue_file, FALSE); if (pr == NULL) return NULL; @@ -303,7 +306,8 @@ cue_tracks[track].performer : cue_performer); tuple_associate_string(out, "album", cue_title); tuple_associate_string(out, "genre", cue_genre); - tuple_associate_int(out, "year", atoi(cue_year)); + if(cue_year) + tuple_associate_int(out, "year", atoi(cue_year)); tuple_associate_int(out, "track-number", track + 1); return out; @@ -467,7 +471,7 @@ static void play_cue_uri(InputPlayback * data, gchar *uri) { - gchar *path2 = g_strdup(uri + 6); + gchar *path2 = g_strdup(uri + 6); // "cue://" is stripped. gchar *_path = strchr(path2, '?'); gint file_length = 0; gint track = 0; @@ -478,6 +482,7 @@ #ifdef DEBUG g_print("f: play_cue_uri\n"); g_print("play_cue_uri: playback = %p\n", data); + g_print("play_cue_uri: path2 = %s\n", path2); #endif /* stop watchdog thread */ @@ -493,7 +498,7 @@ track = atoi(_path); } cur_cue_track = track; - cache_cue_file(path2); + cache_cue_file(path2); //path2 should be uri. if (cue_file == NULL || !vfs_file_test(cue_file, G_FILE_TEST_EXISTS)) return; @@ -518,6 +523,12 @@ real_ip->output = data->output; real_ip->data = data->data; + /* we have to copy set_pb_ready things too. */ + real_ip->pb_ready_mutex = data->pb_ready_mutex; + real_ip->pb_ready_cond = data->pb_ready_cond; + real_ip->pb_ready_val = data->pb_ready_val; + real_ip->set_pb_ready = data->set_pb_ready; + real_play_thread = g_thread_create((GThreadFunc)(real_ip->plugin->play_file), (gpointer)real_ip, TRUE, NULL); g_usleep(50000); // wait for 50msec while real input plugin is initializing.