comparison src/musepack/libmpc.cxx @ 1438:dc3e28d3b92a

mpc: convert, wma: fixes
author William Pitcock <nenolod@atheme-project.org>
date Fri, 10 Aug 2007 09:19:44 -0500
parents 761e17b23e0c
children 195b5657303e
comparison
equal deleted inserted replaced
1437:7373c4e2657c 1438:dc3e28d3b92a
344 if(!isAlive()) 344 if(!isAlive())
345 return -1; 345 return -1;
346 return data->output->output_time(); 346 return data->output->output_time();
347 } 347 }
348 348
349 static TitleInput *mpcGetSongTuple(char* p_Filename) 349 static Tuple *mpcGetSongTuple(char* p_Filename)
350 { 350 {
351 VFSFile *input = vfs_fopen(p_Filename, "rb"); 351 VFSFile *input = vfs_fopen(p_Filename, "rb");
352 TitleInput *tuple = NULL; 352 Tuple *tuple = NULL;
353 353
354 if(input) 354 if(input)
355 { 355 {
356 tuple = bmp_title_input_new(); 356 tuple = tuple_new_from_filename(p_Filename);
357 gchar *filename_proxy = g_strdup(p_Filename);
358
359 tuple->file_name = g_path_get_basename(filename_proxy);
360 tuple->file_path = g_path_get_dirname(filename_proxy);
361 tuple->file_ext = "mpc"; // XXX: I can't be assed. -nenolod
362 357
363 MpcInfo tags = getTags(p_Filename); 358 MpcInfo tags = getTags(p_Filename);
364 359
365 tuple->date = g_strdup(tags.date); 360 tuple_associate_string(tuple, "date", tags.date);
366 tuple->track_name = g_strdup(tags.title); 361 tuple_associate_string(tuple, "title", tags.title);
367 tuple->performer = g_strdup(tags.artist); 362 tuple_associate_string(tuple, "artist", tags.artist);
368 tuple->album_name = g_strdup(tags.album); 363 tuple_associate_string(tuple, "album", tags.album);
369 tuple->track_number = tags.track; 364 tuple_associate_int(tuple, "track-number", tags.track);
370 tuple->year = tags.year; 365 tuple_associate_int(tuple, "year", tags.year);
371 tuple->genre = g_strdup(tags.genre); 366 tuple_associate_string(tuple, "genre", tags.genre);
372 tuple->comment = g_strdup(tags.comment); 367 tuple_associate_string(tuple, "comment", tags.comment);
368
369 tuple_associate_string(tuple, "codec", "Musepack");
370 tuple_associate_string(tuple, "quality", "lossy");
373 371
374 freeTags(tags); 372 freeTags(tags);
375 373
376 mpc_streaminfo info; 374 mpc_streaminfo info;
377 mpc_reader_file reader; 375 mpc_reader_file reader;
378 mpc_reader_setup_file_vfs(&reader, input); 376 mpc_reader_setup_file_vfs(&reader, input);
379 mpc_streaminfo_read(&info, &reader.reader); 377 mpc_streaminfo_read(&info, &reader.reader);
380 378
381 tuple->length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info)); 379 tuple_associate_int(tuple, "length", static_cast<int> (1000 * mpc_streaminfo_get_length(&info)));
382 vfs_fclose(input); 380 vfs_fclose(input);
383 } 381 }
384 else 382 else
385 { 383 {
386 char* temp = g_strdup_printf("[xmms-musepack] mpcGetSongInfo is unable to open %s\n", p_Filename); 384 char* temp = g_strdup_printf("[xmms-musepack] mpcGetSongInfo is unable to open %s\n", p_Filename);
731 widgets.infoBox = NULL; 729 widgets.infoBox = NULL;
732 } 730 }
733 731
734 static char* mpcGenerateTitle(const MpcInfo& p_Tags, char* p_Filename) 732 static char* mpcGenerateTitle(const MpcInfo& p_Tags, char* p_Filename)
735 { 733 {
736 TitleInput* tuple = mpcGetSongTuple(p_Filename); 734 Tuple* tuple = mpcGetSongTuple(p_Filename);
737 735
738 char* title = xmms_get_titlestring (xmms_get_gentitle_format(), tuple); 736 char* title = tuple_formatter_process_string(tuple, cfg.gentitle_format);
739 if(!title) 737
740 title = g_strdup(tuple->file_name); 738 if (!*title)
741 else if (!*title) 739 title = g_strdup(tuple_get_string(tuple, "file-name"));
742 title = g_strdup(tuple->file_name); 740
743 741 mowgli_object_unref((void *) tuple);
744 bmp_title_input_free(tuple);
745 return title; 742 return title;
746 } 743 }
747 744
748 static void* endThread(char* p_FileName, VFSFile * p_FileHandle, bool release) 745 static void* endThread(char* p_FileName, VFSFile * p_FileHandle, bool release)
749 { 746 {