Mercurial > audlegacy-plugins
comparison src/console/Audacious_Driver.cxx @ 1418:08a6320f7a2b
console: update to new tuple API
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Fri, 10 Aug 2007 06:05:54 -0500 |
parents | 761e17b23e0c |
children | 195b5657303e |
comparison
equal
deleted
inserted
replaced
1417:59f2c23810bc | 1418:08a6320f7a2b |
---|---|
11 #endif | 11 #endif |
12 | 12 |
13 #include <glib.h> | 13 #include <glib.h> |
14 #include <audacious/i18n.h> | 14 #include <audacious/i18n.h> |
15 #include <gtk/gtk.h> | 15 #include <gtk/gtk.h> |
16 extern "C" { | |
17 #include "audacious/main.h" | |
18 #include "audacious/tuple.h" | |
19 #include "audacious/tuple_formatter.h" | |
16 #include "audacious/util.h" | 20 #include "audacious/util.h" |
17 #include "audacious/titlestring.h" | |
18 extern "C" { | |
19 #include "audacious/output.h" | 21 #include "audacious/output.h" |
20 #include "audacious/playlist.h" | 22 #include "audacious/playlist.h" |
21 } | 23 } |
22 #include <string.h> | 24 #include <string.h> |
23 #include <stdlib.h> | 25 #include <stdlib.h> |
198 return NULL; | 200 return NULL; |
199 | 201 |
200 return g_strdup(in); | 202 return g_strdup(in); |
201 } | 203 } |
202 | 204 |
203 static TitleInput* get_track_ti( const char* path, track_info_t const& info, int track ) | 205 static Tuple* get_track_ti( const char* path, track_info_t const& info, int track ) |
204 { | 206 { |
205 TitleInput* ti = bmp_title_input_new(); | 207 Tuple* ti = tuple_new(); |
206 if ( ti ) | 208 if ( ti ) |
207 { | 209 { |
208 ti->file_name = g_path_get_basename( path ); | 210 tuple_associate_string(ti, "file-name", g_path_get_basename(path)); |
209 ti->file_path = g_path_get_dirname ( path ); | 211 tuple_associate_string(ti, "file-path", g_path_get_dirname(path)); |
210 ti->performer = selective_strdup( info.author ); | 212 tuple_associate_string(ti, "artist", info.author); |
211 ti->album_name = selective_strdup( info.game ); | 213 tuple_associate_string(ti, "album", info.game); |
212 ti->track_name = selective_strdup( info.song ? info.song : ti->file_name ); | 214 tuple_associate_string(ti, "game", info.game); |
215 tuple_associate_string(ti, "title", info.song ? info.song : g_path_get_basename(path)); | |
213 if ( info.track_count > 1 ) | 216 if ( info.track_count > 1 ) |
214 ti->track_number = track + 1; | 217 { |
215 ti->comment = selective_strdup( info.copyright ); | 218 tuple_associate_int(ti, "track-number", track + 1); |
216 ti->genre = g_strconcat( "Console: ", info.system, NULL ); | 219 tuple_associate_int(ti, "subsong", track); |
217 | 220 } |
221 tuple_associate_string(ti, "copyright", info.copyright); | |
222 tuple_associate_string(ti, "console", info.system); | |
223 tuple_associate_string(ti, "codec", info.system); | |
224 tuple_associate_string(ti, "quality", "sequenced"); | |
225 tuple_associate_string(ti, "dumper", info.dumper); | |
226 tuple_associate_string(ti, "comment", info.comment); | |
227 | |
218 int length = info.length; | 228 int length = info.length; |
219 if ( length <= 0 ) | 229 if ( length <= 0 ) |
220 length = info.intro_length + 2 * info.loop_length; | 230 length = info.intro_length + 2 * info.loop_length; |
221 if ( length <= 0 ) | 231 if ( length <= 0 ) |
222 length = audcfg.loop_length * 1000; | 232 length = audcfg.loop_length * 1000; |
223 else if ( length >= fade_threshold ) | 233 else if ( length >= fade_threshold ) |
224 length += fade_length; | 234 length += fade_length; |
225 ti->length = length; | 235 tuple_associate_int(ti, "length", length); |
226 } | 236 } |
227 return ti; | 237 return ti; |
228 } | 238 } |
229 | 239 |
230 static char* format_and_free_ti( TitleInput* ti, int* length ) | 240 static char* format_and_free_ti( Tuple* ti, int* length ) |
231 { | 241 { |
232 char* result = xmms_get_titlestring( xmms_get_gentitle_format(), ti ); | 242 char* result = tuple_formatter_process_string(ti, cfg.gentitle_format); |
233 if ( result ) | 243 if ( result ) |
234 *length = ti->length; | 244 *length = tuple_get_int(ti, "length"); |
235 bmp_title_input_free( ti ); | 245 mowgli_object_unref((void *) ti); |
236 | 246 |
237 return result; | 247 return result; |
238 } | 248 } |
239 | 249 |
240 static TitleInput *get_song_tuple( gchar *path ) | 250 static Tuple *get_song_tuple( gchar *path ) |
241 { | 251 { |
242 TitleInput* result = 0; | 252 Tuple* result = 0; |
243 File_Handler fh( path ); | 253 File_Handler fh( path ); |
244 if ( !fh.load( gme_info_only ) ) | 254 if ( !fh.load( gme_info_only ) ) |
245 { | 255 { |
246 track_info_t info; | 256 track_info_t info; |
247 if ( !log_err( fh.emu->track_info( &info, fh.track ) ) ) | 257 if ( !log_err( fh.emu->track_info( &info, fh.track ) ) ) |
253 static void get_song_info( char* path, char** title, int* length ) | 263 static void get_song_info( char* path, char** title, int* length ) |
254 { | 264 { |
255 *length = -1; | 265 *length = -1; |
256 *title = NULL; | 266 *title = NULL; |
257 | 267 |
258 TitleInput* ti = get_song_tuple( path ); | 268 Tuple* ti = get_song_tuple( path ); |
259 if ( ti ) | 269 if ( ti ) |
260 *title = format_and_free_ti( ti, length ); | 270 *title = format_and_free_ti( ti, length ); |
261 } | 271 } |
262 | 272 |
263 // Playback | 273 // Playback |
360 track_info_t info; | 370 track_info_t info; |
361 if ( !log_err( fh.emu->track_info( &info, fh.track ) ) ) | 371 if ( !log_err( fh.emu->track_info( &info, fh.track ) ) ) |
362 { | 372 { |
363 if ( fh.type == gme_spc_type && audcfg.ignore_spc_length ) | 373 if ( fh.type == gme_spc_type && audcfg.ignore_spc_length ) |
364 info.length = -1; | 374 info.length = -1; |
365 TitleInput* ti = get_track_ti( fh.path, info, fh.track ); | 375 Tuple* ti = get_track_ti( fh.path, info, fh.track ); |
366 if ( ti ) | 376 if ( ti ) |
367 { | 377 { |
368 char* title = format_and_free_ti( ti, &length ); | 378 char* title = format_and_free_ti( ti, &length ); |
369 if ( title ) | 379 if ( title ) |
370 { | 380 { |