Mercurial > audlegacy-plugins
changeset 1426:120892cfdbf0
Isn't that cute. But it's WRONG.
author | Tony Vroon <chainsaw@gentoo.org> |
---|---|
date | Fri, 10 Aug 2007 12:58:05 +0100 |
parents | a25c2cfcce83 (current diff) 230661b01dc7 (diff) |
children | 138ea47220e8 |
files | src/cdaudio-ng/cdaudio-ng.h |
diffstat | 10 files changed, 189 insertions(+), 118 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alac/plugin.c Fri Aug 10 12:55:42 2007 +0100 +++ b/src/alac/plugin.c Fri Aug 10 12:58:05 2007 +0100 @@ -46,6 +46,7 @@ #include <audacious/i18n.h> #include <audacious/plugin.h> +#include <audacious/main.h> #include <audacious/output.h> #include <audacious/vfs.h> #include <audacious/util.h> @@ -116,31 +117,40 @@ return TRUE; } -TitleInput *build_tuple_from_demux(demux_res_t *demux_res, char *path) +Tuple *build_tuple_from_demux(demux_res_t *demux_res, char *path) { - TitleInput *ti = bmp_title_input_new(); + Tuple *ti = tuple_new(); + gchar *scratch; if (demux_res->tuple.art != NULL) - ti->performer = g_strdup(demux_res->tuple.art); + tuple_associate_string(ti, "artist", demux_res->tuple.art); if (demux_res->tuple.nam != NULL) - ti->track_name = g_strdup(demux_res->tuple.nam); + tuple_associate_string(ti, "title", demux_res->tuple.nam); if (demux_res->tuple.alb != NULL) - ti->album_name = g_strdup(demux_res->tuple.alb); + tuple_associate_string(ti, "album", demux_res->tuple.alb); if (demux_res->tuple.gen != NULL) - ti->genre = g_strdup(demux_res->tuple.gen); + tuple_associate_string(ti, "genre", demux_res->tuple.gen); if (demux_res->tuple.cmt != NULL) - ti->comment = g_strdup(demux_res->tuple.cmt); + tuple_associate_string(ti, "comment", demux_res->tuple.cmt); if (demux_res->tuple.day != NULL) - ti->year = atoi(demux_res->tuple.day); + tuple_associate_int(ti, "year", atoi(demux_res->tuple.day)); + + scratch = g_path_get_basename(path); + tuple_associate_string(ti, "file-name", scratch); + g_free(scratch); - ti->file_name = g_path_get_basename(path); - ti->file_path = g_path_get_dirname(path); - ti->file_ext = extname(path); + scratch = g_path_get_dirname(path); + tuple_associate_string(ti, "file-path", scratch); + g_free(scratch); + + tuple_associate_string(ti, "file-ext", extname(path)); + tuple_associate_string(ti, "codec", "Apple Lossless (ALAC)"); + tuple_associate_string(ti, "quality", "lossless"); return ti; } -TitleInput *build_tuple(char *filename) +Tuple *build_tuple(char *filename) { demux_res_t demux_res; VFSFile *input_file; @@ -313,7 +323,7 @@ gulong duration = 0; /* samples added up */ VFSFile *input_file; stream_t *input_stream; - TitleInput *ti; + Tuple *ti; gchar *title; memset(&demux_res, 0, sizeof(demux_res)); @@ -335,7 +345,7 @@ /* Get the titlestring ready. */ ti = build_tuple_from_demux(&demux_res, (char *) args); - title = xmms_get_titlestring(xmms_get_gentitle_format(), ti); + title = tuple_formatter_process_string(ti, cfg.gentitle_format); /* initialise the sound converter */ demux_res.alac = create_alac(demux_res.sample_size, demux_res.num_channels);
--- a/src/cdaudio-ng/cdaudio-ng.h Fri Aug 10 12:55:42 2007 +0100 +++ b/src/cdaudio-ng/cdaudio-ng.h Fri Aug 10 12:58:05 2007 +0100 @@ -7,7 +7,7 @@ #define CDDA_DEFAULT "cdda://default" #define CDDA_DAE_FRAMES 8 #define CDDA_DEFAULT_CDDB_SERVER "freedb.org" -#define CDDA_DEFAULT_CDDB_PORT 8880 +#define CDDA_DEFAULT_CDDB_PORT 888 typedef struct {
--- a/src/console/Audacious_Driver.cxx Fri Aug 10 12:55:42 2007 +0100 +++ b/src/console/Audacious_Driver.cxx Fri Aug 10 12:58:05 2007 +0100 @@ -13,9 +13,11 @@ #include <glib.h> #include <audacious/i18n.h> #include <gtk/gtk.h> +extern "C" { +#include "audacious/main.h" +#include "audacious/tuple.h" +#include "audacious/tuple_formatter.h" #include "audacious/util.h" -#include "audacious/titlestring.h" -extern "C" { #include "audacious/output.h" #include "audacious/playlist.h" } @@ -200,21 +202,29 @@ return g_strdup(in); } -static TitleInput* get_track_ti( const char* path, track_info_t const& info, int track ) +static Tuple* get_track_ti( const char* path, track_info_t const& info, int track ) { - TitleInput* ti = bmp_title_input_new(); + Tuple* ti = tuple_new(); if ( ti ) { - ti->file_name = g_path_get_basename( path ); - ti->file_path = g_path_get_dirname ( path ); - ti->performer = selective_strdup( info.author ); - ti->album_name = selective_strdup( info.game ); - ti->track_name = selective_strdup( info.song ? info.song : ti->file_name ); + tuple_associate_string(ti, "file-name", g_path_get_basename(path)); + tuple_associate_string(ti, "file-path", g_path_get_dirname(path)); + tuple_associate_string(ti, "artist", info.author); + tuple_associate_string(ti, "album", info.game); + tuple_associate_string(ti, "game", info.game); + tuple_associate_string(ti, "title", info.song ? info.song : g_path_get_basename(path)); if ( info.track_count > 1 ) - ti->track_number = track + 1; - ti->comment = selective_strdup( info.copyright ); - ti->genre = g_strconcat( "Console: ", info.system, NULL ); - + { + tuple_associate_int(ti, "track-number", track + 1); + tuple_associate_int(ti, "subsong", track); + } + tuple_associate_string(ti, "copyright", info.copyright); + tuple_associate_string(ti, "console", info.system); + tuple_associate_string(ti, "codec", info.system); + tuple_associate_string(ti, "quality", "sequenced"); + tuple_associate_string(ti, "dumper", info.dumper); + tuple_associate_string(ti, "comment", info.comment); + int length = info.length; if ( length <= 0 ) length = info.intro_length + 2 * info.loop_length; @@ -222,24 +232,24 @@ length = audcfg.loop_length * 1000; else if ( length >= fade_threshold ) length += fade_length; - ti->length = length; + tuple_associate_int(ti, "length", length); } return ti; } -static char* format_and_free_ti( TitleInput* ti, int* length ) +static char* format_and_free_ti( Tuple* ti, int* length ) { - char* result = xmms_get_titlestring( xmms_get_gentitle_format(), ti ); + char* result = tuple_formatter_process_string(ti, cfg.gentitle_format); if ( result ) - *length = ti->length; - bmp_title_input_free( ti ); - + *length = tuple_get_int(ti, "length"); + mowgli_object_unref((void *) ti); + return result; } -static TitleInput *get_song_tuple( gchar *path ) +static Tuple *get_song_tuple( gchar *path ) { - TitleInput* result = 0; + Tuple* result = 0; File_Handler fh( path ); if ( !fh.load( gme_info_only ) ) { @@ -255,7 +265,7 @@ *length = -1; *title = NULL; - TitleInput* ti = get_song_tuple( path ); + Tuple* ti = get_song_tuple( path ); if ( ti ) *title = format_and_free_ti( ti, length ); } @@ -362,7 +372,7 @@ { if ( fh.type == gme_spc_type && audcfg.ignore_spc_length ) info.length = -1; - TitleInput* ti = get_track_ti( fh.path, info, fh.track ); + Tuple* ti = get_track_ti( fh.path, info, fh.track ); if ( ti ) { char* title = format_and_free_ti( ti, &length );
--- a/src/cue/cuesheet.c Fri Aug 10 12:55:42 2007 +0100 +++ b/src/cue/cuesheet.c Fri Aug 10 12:58:05 2007 +0100 @@ -31,7 +31,6 @@ #include <audacious/util.h> #include <audacious/strings.h> #include <audacious/main.h> -#include <audacious/strings.h> #define MAX_CUE_LINE_LENGTH 1000 #define MAX_CUE_TRACKS 1000 @@ -46,8 +45,8 @@ static void seek(InputPlayback *data, gint time); static void stop(InputPlayback *data); static void cue_pause(InputPlayback *data, short); -static TitleInput *get_tuple(gchar *uri); -static TitleInput *get_tuple_uri(gchar *uri); +static Tuple *get_tuple(gchar *uri); +static Tuple *get_tuple_uri(gchar *uri); static void get_song_info(gchar *uri, gchar **title, gint *length); static void cue_init(void); static void cue_cleanup(void); @@ -222,9 +221,9 @@ play_cue_uri(data, uri); } -static TitleInput *get_tuple(gchar *uri) +static Tuple *get_tuple(gchar *uri) { - TitleInput *ret; + Tuple *ret; /* this isn't a cue:// uri? */ if (strncasecmp("cue://", uri, 6)) @@ -238,7 +237,14 @@ return get_tuple_uri(uri); } -static TitleInput *get_tuple_uri(gchar *uri) +static void _tuple_copy_field(Tuple *tuple, Tuple *tuple2, const gchar *field) +{ + const gchar *str = tuple_get_string(tuple, field); + tuple_disassociate(tuple2, field); + tuple_associate_string(tuple2, field, str); +} + +static Tuple *get_tuple_uri(gchar *uri) { gchar *path2 = g_strdup(uri + 6); gchar *_path = strchr(path2, '?'); @@ -247,7 +253,7 @@ ProbeResult *pr; InputPlugin *dec; - TitleInput *phys_tuple, *out; + Tuple *phys_tuple, *out; if (_path != NULL && *_path == '?') { @@ -273,34 +279,37 @@ else phys_tuple = input_get_song_tuple(cue_file); - out = bmp_title_input_new(); + if(!phys_tuple) + return NULL; + + out = tuple_new(); - if(!phys_tuple) - return out; + _tuple_copy_field(phys_tuple, out, "file-path"); + _tuple_copy_field(phys_tuple, out, "file-name"); + _tuple_copy_field(phys_tuple, out, "file-exit"); + _tuple_copy_field(phys_tuple, out, "codec"); + _tuple_copy_field(phys_tuple, out, "quality"); + _tuple_copy_field(phys_tuple, out, "copyright"); + _tuple_copy_field(phys_tuple, out, "comment"); - if(phys_tuple->file_path) - out->file_path = g_strdup(phys_tuple->file_path); - if(phys_tuple->file_name) - out->file_name = g_strdup(phys_tuple->file_name); - if(phys_tuple->file_ext) - out->file_ext = g_strdup(phys_tuple->file_ext); - out->length = phys_tuple->length; + tuple_associate_int(out, "length", tuple_get_int(phys_tuple, "length")); + + mowgli_object_unref(phys_tuple); - bmp_title_input_free(phys_tuple); - - out->track_name = g_strdup(cue_tracks[track].title); - out->performer = g_strdup(cue_tracks[track].performer ? + tuple_associate_string(out, "title", cue_tracks[track].title); + tuple_associate_string(out, "artist", cue_tracks[track].performer ? cue_tracks[track].performer : cue_performer); - out->album_name = g_strdup(cue_title); - out->genre = g_strdup(cue_genre); - out->year = cue_year ? atoi(cue_year) : 0; - out->track_number = track + 1; - return out; + tuple_associate_string(out, "album", cue_title); + tuple_associate_string(out, "genre", cue_genre); + tuple_associate_int(out, "year", atoi(cue_year)); + tuple_associate_int(out, "track-number", track + 1); + + return out; } static void get_song_info(gchar *uri, gchar **title, gint *length) { - TitleInput *tuple; + Tuple *tuple; /* this isn't a cue:// uri? */ if (strncasecmp("cue://", uri, 6)) @@ -314,10 +323,10 @@ g_return_if_fail(tuple != NULL); - *title = xmms_get_titlestring(xmms_get_gentitle_format(), tuple); - *length = tuple->length; + *title = tuple_formatter_process_string(tuple, cfg.gentitle_format); + *length = tuple_get_int(tuple, "length"); - bmp_title_input_free(tuple); + mowgli_object_unref(tuple); } static void seek(InputPlayback * data, gint time)
--- a/src/sexypsf/plugin.c Fri Aug 10 12:55:42 2007 +0100 +++ b/src/sexypsf/plugin.c Fri Aug 10 12:58:05 2007 +0100 @@ -18,7 +18,9 @@ #include "audacious/output.h" #include "audacious/plugin.h" -#include "audacious/titlestring.h" +#include "audacious/main.h" +#include "audacious/tuple.h" +#include "audacious/tuple_formatter.h" #include "audacious/util.h" #include "audacious/vfs.h" #include <stdio.h> @@ -218,18 +220,35 @@ } } -static TitleInput *get_tuple_psf(gchar *fn) { - TitleInput *tuple = NULL; +static Tuple *get_tuple_psf(gchar *fn) { + Tuple *tuple = NULL; PSFINFO *tmp = sexypsf_getpsfinfo(fn); if (tmp->length) { - tuple = bmp_title_input_new(); - tuple->length = tmp->length; - tuple->performer = g_strdup(tmp->artist); - tuple->album_name = g_strdup(tmp->game); - tuple->track_name = g_strdup(tmp->title); - tuple->file_name = g_path_get_basename(fn); - tuple->file_path = g_path_get_dirname(fn); + gchar *scratch; + + tuple = tuple_new(); + tuple_associate_int(tuple, "length", tmp->length); + tuple_associate_string(tuple, "artist", tmp->artist); + tuple_associate_string(tuple, "album", tmp->game); + tuple_associate_string(tuple, "game", tmp->game); + tuple_associate_string(tuple, "title", tmp->title); + tuple_associate_string(tuple, "genre", tmp->genre); + tuple_associate_string(tuple, "copyright", tmp->copyright); + tuple_associate_string(tuple, "quality", "sequenced"); + tuple_associate_string(tuple, "codec", "PlayStation Audio"); + tuple_associate_string(tuple, "console", "PlayStation"); + tuple_associate_string(tuple, "dumper", tmp->psfby); + tuple_associate_string(tuple, "comment", tmp->comment); + + scratch = g_path_get_basename(fn); + tuple_associate_string(tuple, "file-name", scratch); + g_free(scratch); + + scratch = g_path_get_dirname(fn); + tuple_associate_string(tuple, "file-path", scratch); + g_free(scratch); + sexypsf_freepsfinfo(tmp); } @@ -238,12 +257,11 @@ static gchar *get_title_psf(gchar *fn) { gchar *title = NULL; - TitleInput *tinput = get_tuple_psf(fn); + Tuple *tuple = get_tuple_psf(fn); - if (tinput != NULL) { - title = xmms_get_titlestring(xmms_get_gentitle_format(), - tinput); - bmp_title_input_free(tinput); + if (tuple != NULL) { + title = tuple_formatter_process_string(tuple, cfg.gentitle_format); + mowgli_object_unref(tuple); } else title = g_path_get_basename(fn);
--- a/src/vorbis/vorbis.c Fri Aug 10 12:55:42 2007 +0100 +++ b/src/vorbis/vorbis.c Fri Aug 10 12:58:05 2007 +0100 @@ -364,6 +364,7 @@ */ if (bytes <= 0 && bytes != OV_HOLE) { g_mutex_unlock(vf_mutex); + playback->playing = 0; playback->output->buffer_free(); playback->output->buffer_free(); playback->eof = TRUE;
--- a/src/vtx/about.c Fri Aug 10 12:55:42 2007 +0100 +++ b/src/vtx/about.c Fri Aug 10 12:58:05 2007 +0100 @@ -4,7 +4,6 @@ #include <audacious/output.h> #include <audacious/util.h> -#include <audacious/titlestring.h> #include <audacious/vfs.h> #include <audacious/strings.h> #include <audacious/i18n.h>
--- a/src/vtx/info.c Fri Aug 10 12:55:42 2007 +0100 +++ b/src/vtx/info.c Fri Aug 10 12:58:05 2007 +0100 @@ -1,7 +1,6 @@ #include <audacious/plugin.h> #include <audacious/util.h> #include <audacious/output.h> -#include <audacious/titlestring.h> #include <audacious/vfs.h> #include <audacious/strings.h> #include <audacious/i18n.h>
--- a/src/vtx/vtx.c Fri Aug 10 12:55:42 2007 +0100 +++ b/src/vtx/vtx.c Fri Aug 10 12:58:05 2007 +0100 @@ -21,9 +21,9 @@ #include <audacious/output.h> #include <audacious/util.h> -#include <audacious/titlestring.h> #include <audacious/configdb.h> #include <audacious/vfs.h> +#include <audacious/main.h> #include <audacious/strings.h> #include <audacious/i18n.h> @@ -92,36 +92,48 @@ return ret; } -TitleInput * +Tuple * vtx_get_song_tuple_from_vtx(const gchar *filename, ayemu_vtx_t *in) { - TitleInput *out = bmp_title_input_new(); + Tuple *out = tuple_new(); gchar *string; + gchar *scratch; - out->performer = g_strdup(in->hdr.author); - out->track_name = g_strdup(in->hdr.title); + tuple_associate_string(out, "artist", in->hdr.author); + tuple_associate_string(out, "title", in->hdr.title); - out->file_name = g_strdup(g_basename(filename)); - out->file_path = g_path_get_dirname(filename); - if ((string = strrchr(out->file_name, '.'))) - { - out->file_ext = string + 1; - *string = '\0'; - } + scratch = g_path_get_basename(filename); + tuple_associate_string(out, "file-name", scratch); + g_free(scratch); + + scratch = g_path_get_dirname(filename); + tuple_associate_string(out, "file-path", scratch); + g_free(scratch); - out->length = in->hdr.regdata_size / 14 * 1000 / 50; + tuple_associate_string(out, "file-ext", strrchr(filename, '.') + 1); + tuple_associate_int(out, "length", in->hdr.regdata_size / 14 * 1000 / 50); + + tuple_associate_string(out, "genre", (in->hdr.chiptype == AYEMU_AY)? "AY chiptunes" : "YM chiptunes"); + tuple_associate_string(out, "album", in->hdr.from); + tuple_associate_string(out, "game", in->hdr.from); + + tuple_associate_string(out, "quality", "sequenced"); + tuple_associate_string(out, "codec", in->hdr.tracker); + tuple_associate_string(out, "tracker", in->hdr.tracker); + + tuple_associate_int(out, "year", in->hdr.year); return out; } -TitleInput * +Tuple * vtx_get_song_tuple(gchar *filename) { ayemu_vtx_t tmp; if (ayemu_vtx_open (&tmp, filename)) { - TitleInput *ti = vtx_get_song_tuple_from_vtx(filename, &tmp); + Tuple *ti = vtx_get_song_tuple_from_vtx(filename, &tmp); ayemu_vtx_free(&tmp); return ti; } @@ -204,7 +216,7 @@ { gchar *filename = playback->filename; gchar *buf; - TitleInput *ti; + Tuple *ti; memset (&ay, 0, sizeof(ay)); @@ -232,8 +244,7 @@ seek_to = -1; ti = vtx_get_song_tuple_from_vtx(playback->filename, &vtx); - - buf = xmms_get_titlestring(xmms_get_gentitle_format(), ti); + buf = tuple_formatter_process_string(ti, cfg.gentitle_format); vtx_ip.set_info (buf, vtx.hdr.regdata_size / 14 * 1000 / 50, 14 * 50 * 8, freq, bits / 8); @@ -294,13 +305,13 @@ (*title) = NULL; if (ayemu_vtx_open (&tmp, filename)) { - TitleInput *ti = vtx_get_song_tuple_from_vtx(filename, &tmp); + Tuple *ti = vtx_get_song_tuple_from_vtx(filename, &tmp); - *title = xmms_get_titlestring(xmms_get_gentitle_format(), ti); - *length = ti->length; + *title = tuple_formatter_process_string(ti, cfg.gentitle_format); + *length = tuple_get_int(ti, "length"); ayemu_vtx_free (&tmp); - bmp_title_input_free(ti); + mowgli_object_unref(ti); } }
--- a/src/wav/wav.c Fri Aug 10 12:55:42 2007 +0100 +++ b/src/wav/wav.c Fri Aug 10 12:58:05 2007 +0100 @@ -29,7 +29,9 @@ #include <string.h> #include <audacious/util.h> -#include <audacious/titlestring.h> +#include <audacious/main.h> +#include <audacious/tuple.h> +#include <audacious/tuple_formatter.h> #include "audacious/output.h" #include <audacious/i18n.h> @@ -204,21 +206,33 @@ static gchar * get_title(const gchar * filename) { - TitleInput *input; + Tuple *tuple; gchar *title; + gchar *scratch; - input = bmp_title_input_new(); + tuple = tuple_new(); + + scratch = g_path_get_basename(filename); + tuple_associate_string(tuple, "file-name", scratch); + g_free(scratch); + + tuple_associate_string(tuple, "file-ext", get_extension(filename)); - input->file_name = g_path_get_basename(filename); - input->file_ext = get_extension(filename); - input->file_path = g_path_get_dirname(filename); + scratch = g_path_get_dirname(filename); + tuple_associate_string(tuple, "file-path", scratch); + g_free(scratch); + + tuple_associate_string(tuple, "codec", "RIFF/WAV Audio (ADPCM)"); + tuple_associate_string(tuple, "quality", "lossless"); - if (!(title = xmms_get_titlestring(xmms_get_gentitle_format(), input))) - title = g_strdup(input->file_name); + title = tuple_formatter_process_string(tuple, cfg.gentitle_format); + if (*title == '\0') + { + g_free(title); + title = g_strdup(tuple_get_string(tuple, "file-name")); + } - g_free(input->file_path); - g_free(input->file_name); - g_free(input); + mowgli_object_unref(tuple); return title; }