comparison src/cdaudio-ng/cdaudio-ng.c @ 1466:a0b4583a5e48

tuple API update.
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Sat, 11 Aug 2007 20:10:10 +0900
parents 195b5657303e
children eb0913bf54c3
comparison
equal deleted inserted replaced
1465:db616ccdd40c 1466:a0b4583a5e48
57 static gint cdaudio_get_time(InputPlayback *pinputplayback); 57 static gint cdaudio_get_time(InputPlayback *pinputplayback);
58 static gint cdaudio_get_volume(gint *l, gint *r); 58 static gint cdaudio_get_volume(gint *l, gint *r);
59 static gint cdaudio_set_volume(gint l, gint r); 59 static gint cdaudio_set_volume(gint l, gint r);
60 static void cdaudio_cleanup(); 60 static void cdaudio_cleanup();
61 static void cdaudio_get_song_info(gchar *filename, gchar **title, gint *length); 61 static void cdaudio_get_song_info(gchar *filename, gchar **title, gint *length);
62 static TitleInput *cdaudio_get_song_tuple(gchar *filename); 62 static Tuple *cdaudio_get_song_tuple(gchar *filename);
63 63
64 static TitleInput *create_tuple_from_trackinfo(char *filename); 64 static Tuple *create_tuple_from_trackinfo(char *filename);
65 static void dae_play_loop(dae_params_t *pdae_params); 65 static void dae_play_loop(dae_params_t *pdae_params);
66 static int calculate_track_length(int startlsn, int endlsn); 66 static int calculate_track_length(int startlsn, int endlsn);
67 static int find_trackno_from_filename(char *filename); 67 static int find_trackno_from_filename(char *filename);
68 static void cleanup_on_error(); 68 static void cleanup_on_error();
69 69
445 return list; 445 return list;
446 } 446 }
447 447
448 void cdaudio_play_file(InputPlayback *pinputplayback) 448 void cdaudio_play_file(InputPlayback *pinputplayback)
449 { 449 {
450 Tuple *tuple;
451 char *title;
452
450 if (debug) 453 if (debug)
451 printf("cdaudio-ng: cdaudio_play_file(\"%s\")\n", pinputplayback->filename); 454 printf("cdaudio-ng: cdaudio_play_file(\"%s\")\n", pinputplayback->filename);
452 455
453 pglobalinputplayback = pinputplayback; 456 pglobalinputplayback = pinputplayback;
454 457
480 483
481 pinputplayback->playing = TRUE; 484 pinputplayback->playing = TRUE;
482 playing_track = trackno; 485 playing_track = trackno;
483 is_paused = FALSE; 486 is_paused = FALSE;
484 487
485 char *title = xmms_get_titlestring(xmms_get_gentitle_format(), create_tuple_from_trackinfo(pinputplayback->filename)); 488 tuple = create_tuple_from_trackinfo(pinputplayback->filename);
489 title = tuple_formatter_process_string(tuple, xmms_get_gentitle_format());
486 490
487 inputplugin.set_info(title, calculate_track_length(trackinfo[trackno].startlsn, trackinfo[trackno].endlsn), 1411200, 44100, 2); 491 inputplugin.set_info(title, calculate_track_length(trackinfo[trackno].startlsn, trackinfo[trackno].endlsn), 1411200, 44100, 2);
488 free(title); 492 free(title); title = NULL;
493 tuple_free(tuple); tuple = NULL;
489 494
490 if (use_dae) { 495 if (use_dae) {
491 if (debug) 496 if (debug)
492 printf("cdaudio-ng: using digital audio extraction\n"); 497 printf("cdaudio-ng: using digital audio extraction\n");
493 498
726 { 731 {
727 if (debug) 732 if (debug)
728 printf("cdaudio-ng: cdaudio_get_song_info(\"%s\")\n", filename); 733 printf("cdaudio-ng: cdaudio_get_song_info(\"%s\")\n", filename);
729 734
730 int trackno = find_trackno_from_filename(filename); 735 int trackno = find_trackno_from_filename(filename);
731 736 Tuple *tuple = create_tuple_from_trackinfo(filename);
732 *title = xmms_get_titlestring(xmms_get_gentitle_format(), create_tuple_from_trackinfo(filename)); 737
738 if(tuple) {
739 *title = tuple_formatter_process_string(tuple, xmms_get_gentitle_format());
740 tuple_free(tuple);
741 tuple = NULL;
742 }
733 *length = calculate_track_length(trackinfo[trackno].startlsn, trackinfo[trackno].endlsn); 743 *length = calculate_track_length(trackinfo[trackno].startlsn, trackinfo[trackno].endlsn);
734 } 744 }
735 745
736 TitleInput *cdaudio_get_song_tuple(gchar *filename) 746 Tuple *cdaudio_get_song_tuple(gchar *filename)
737 { 747 {
738 if (debug) 748 if (debug)
739 printf("cdaudio-ng: cdaudio_get_song_tuple(\"%s\")\n", filename); 749 printf("cdaudio-ng: cdaudio_get_song_tuple(\"%s\")\n", filename);
740 750
741 return create_tuple_from_trackinfo(filename); 751 return create_tuple_from_trackinfo(filename);
742 } 752 }
743 753
744 754
745 /* auxiliar functions */ 755 /* auxiliar functions */
746 756
747 TitleInput *create_tuple_from_trackinfo(char *filename) 757 Tuple *create_tuple_from_trackinfo(char *filename)
748 { 758 {
749 if (trackinfo == NULL) 759 if (trackinfo == NULL)
750 return NULL; 760 return NULL;
751 761
752 TitleInput *tuple = bmp_title_input_new(); 762 Tuple *tuple = tuple_new_from_filename(filename);
753 int trackno = find_trackno_from_filename(filename); 763 int trackno = find_trackno_from_filename(filename);
754 764
755 if (trackno < firsttrackno || trackno > lasttrackno) 765 if (trackno < firsttrackno || trackno > lasttrackno)
756 return NULL; 766 return NULL;
757 767
758 tuple->performer = strlen(trackinfo[trackno].performer) > 0 ? g_strdup(trackinfo[trackno].performer) : NULL; 768 if(strlen(trackinfo[trackno].performer)) {
759 tuple->album_name = strlen(trackinfo[0].name) > 0 ? g_strdup(trackinfo[0].name) : NULL; 769 tuple_associate_string(tuple, "artist", trackinfo[trackno].performer);
760 tuple->track_name = strlen(trackinfo[trackno].name) > 0 ? g_strdup(trackinfo[trackno].name) : NULL; 770 }
761 tuple->track_number = trackno; 771 if(strlen(trackinfo[0].name)) {
762 tuple->file_name = g_strdup(basename(filename)); 772 tuple_associate_string(tuple, "album", trackinfo[0].name);
763 tuple->file_path = g_strdup(basename(filename)); 773 }
764 tuple->file_ext = g_strdup("cda"); 774 if(strlen(trackinfo[trackno].name)) {
765 tuple->length = calculate_track_length(trackinfo[trackno].startlsn, trackinfo[trackno].endlsn); 775 tuple_associate_string(tuple, "title", trackinfo[trackno].name);
766 tuple->genre = strlen(trackinfo[trackno].genre) > 0 ? g_strdup(trackinfo[trackno].genre) : NULL; 776 }
777 tuple_associate_int(tuple, "track-number", trackno);
778 tuple_associate_string(tuple, "ext", "cda"); //XXX should do? --yaz
779
780 tuple_associate_int(tuple, "length", calculate_track_length(trackinfo[trackno].startlsn, trackinfo[trackno].endlsn));
781 if(strlen(trackinfo[trackno].genre)) {
782 tuple_associate_string(tuple, "genre", trackinfo[trackno].genre);
783 }
767 //tuple->year = 0; todo: set the year 784 //tuple->year = 0; todo: set the year
768 785
769 return tuple; 786 return tuple;
770 } 787 }
771 788