Mercurial > audlegacy-plugins
comparison src/madplug/plugin.c @ 1976:5fa26178eaef
s/tuple_/aud_tuple_/g
| author | William Pitcock <nenolod@atheme.org> |
|---|---|
| date | Sun, 07 Oct 2007 00:22:59 -0500 |
| parents | e1ebf3fc1a16 |
| children | fa9f85cebade |
comparison
equal
deleted
inserted
replaced
| 1973:f86cb7fc1d4f | 1976:5fa26178eaef |
|---|---|
| 514 #endif | 514 #endif |
| 515 return; | 515 return; |
| 516 } | 516 } |
| 517 | 517 |
| 518 if (input_get_info(&myinfo, info.remote ? TRUE : audmad_config.fast_play_time_calc) == TRUE) { | 518 if (input_get_info(&myinfo, info.remote ? TRUE : audmad_config.fast_play_time_calc) == TRUE) { |
| 519 if(tuple_get_string(myinfo.tuple, -1, "track-name")) | 519 if(aud_tuple_get_string(myinfo.tuple, -1, "track-name")) |
| 520 *title = g_strdup(tuple_get_string(myinfo.tuple, -1, "track-name")); | 520 *title = g_strdup(aud_tuple_get_string(myinfo.tuple, -1, "track-name")); |
| 521 else | 521 else |
| 522 *title = g_strdup(url); | 522 *title = g_strdup(url); |
| 523 | 523 |
| 524 *length = tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL); | 524 *length = aud_tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL); |
| 525 if(*length == -1) | 525 if(*length == -1) |
| 526 *length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS); | 526 *length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS); |
| 527 } | 527 } |
| 528 else { | 528 else { |
| 529 *title = g_strdup(url); | 529 *title = g_strdup(url); |
| 551 #endif | 551 #endif |
| 552 return; | 552 return; |
| 553 } | 553 } |
| 554 | 554 |
| 555 if (input_get_info(&myinfo, info.remote ? TRUE : audmad_config.fast_play_time_calc) == TRUE) { | 555 if (input_get_info(&myinfo, info.remote ? TRUE : audmad_config.fast_play_time_calc) == TRUE) { |
| 556 *length = tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL); | 556 *length = aud_tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL); |
| 557 if(*length == -1) | 557 if(*length == -1) |
| 558 *length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS); | 558 *length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS); |
| 559 } | 559 } |
| 560 else { | 560 else { |
| 561 *length = -1; | 561 *length = -1; |
| 628 extern void audmad_get_file_info(char *filename); | 628 extern void audmad_get_file_info(char *filename); |
| 629 extern void audmad_configure(); | 629 extern void audmad_configure(); |
| 630 | 630 |
| 631 static void __set_and_free(Tuple *tuple, gint nfield, gchar *name, gchar *value) | 631 static void __set_and_free(Tuple *tuple, gint nfield, gchar *name, gchar *value) |
| 632 { | 632 { |
| 633 tuple_associate_string(tuple, nfield, name, value); | 633 aud_tuple_associate_string(tuple, nfield, name, value); |
| 634 g_free(value); | 634 g_free(value); |
| 635 } | 635 } |
| 636 | 636 |
| 637 // tuple stuff | 637 // tuple stuff |
| 638 static Tuple *__audmad_get_song_tuple(char *filename, VFSFile *fd) | 638 static Tuple *__audmad_get_song_tuple(char *filename, VFSFile *fd) |
| 654 #endif | 654 #endif |
| 655 | 655 |
| 656 if(info.remote && mad_timer_count(info.duration, MAD_UNITS_SECONDS) <= 0){ | 656 if(info.remote && mad_timer_count(info.duration, MAD_UNITS_SECONDS) <= 0){ |
| 657 if((fd && vfs_is_streaming(fd)) || (info.playback && info.playback->playing)) { | 657 if((fd && vfs_is_streaming(fd)) || (info.playback && info.playback->playing)) { |
| 658 gchar *tmp = NULL; | 658 gchar *tmp = NULL; |
| 659 tuple = tuple_new_from_filename(filename); | 659 tuple = aud_tuple_new_from_filename(filename); |
| 660 | 660 |
| 661 #ifdef DEBUG | 661 #ifdef DEBUG |
| 662 if(info.playback) | 662 if(info.playback) |
| 663 g_message("info.playback->playing = %d",info.playback->playing); | 663 g_message("info.playback->playing = %d",info.playback->playing); |
| 664 #endif | 664 #endif |
| 665 tmp = vfs_get_metadata(info.infile ? info.infile : fd, "track-name"); | 665 tmp = vfs_get_metadata(info.infile ? info.infile : fd, "track-name"); |
| 666 if(tmp){ | 666 if(tmp){ |
| 667 gchar *scratch; | 667 gchar *scratch; |
| 668 | 668 |
| 669 scratch = str_to_utf8(tmp); | 669 scratch = str_to_utf8(tmp); |
| 670 tuple_associate_string(tuple, FIELD_TITLE, NULL, scratch); | 670 aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, scratch); |
| 671 g_free(tmp); | 671 g_free(tmp); |
| 672 g_free(scratch); | 672 g_free(scratch); |
| 673 | 673 |
| 674 tmp = NULL; | 674 tmp = NULL; |
| 675 } | 675 } |
| 676 tmp = vfs_get_metadata(info.infile ? info.infile : fd, "stream-name"); | 676 tmp = vfs_get_metadata(info.infile ? info.infile : fd, "stream-name"); |
| 677 if(tmp){ | 677 if(tmp){ |
| 678 gchar *scratch; | 678 gchar *scratch; |
| 679 | 679 |
| 680 scratch = str_to_utf8(tmp); | 680 scratch = str_to_utf8(tmp); |
| 681 tuple_associate_string(tuple, FIELD_TITLE, NULL, scratch); | 681 aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, scratch); |
| 682 g_free(tmp); | 682 g_free(tmp); |
| 683 g_free(scratch); | 683 g_free(scratch); |
| 684 | 684 |
| 685 tmp = NULL; | 685 tmp = NULL; |
| 686 } | 686 } |
| 687 | 687 |
| 688 #ifdef DEBUG | 688 #ifdef DEBUG |
| 689 g_message("audmad_get_song_tuple: track_name = %s", tuple_get_string(tuple, -1, "track-name")); | 689 g_message("audmad_get_song_tuple: track_name = %s", aud_tuple_get_string(tuple, -1, "track-name")); |
| 690 g_message("audmad_get_song_tuple: stream_name = %s", tuple_get_string(tuple, -1, "stream-name")); | 690 g_message("audmad_get_song_tuple: stream_name = %s", aud_tuple_get_string(tuple, -1, "stream-name")); |
| 691 #endif | 691 #endif |
| 692 tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1); | 692 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1); |
| 693 tuple_associate_int(tuple, FIELD_MTIME, NULL, 0); // this indicates streaming | 693 aud_tuple_associate_int(tuple, FIELD_MTIME, NULL, 0); // this indicates streaming |
| 694 #ifdef DEBUG | 694 #ifdef DEBUG |
| 695 g_message("get_song_tuple: remote: tuple"); | 695 g_message("get_song_tuple: remote: tuple"); |
| 696 #endif | 696 #endif |
| 697 return tuple; | 697 return tuple; |
| 698 } | 698 } |
| 708 if(!fd) | 708 if(!fd) |
| 709 return NULL; | 709 return NULL; |
| 710 local_fd = TRUE; | 710 local_fd = TRUE; |
| 711 } | 711 } |
| 712 | 712 |
| 713 tuple = tuple_new(); | 713 tuple = aud_tuple_new(); |
| 714 tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1); | 714 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1); |
| 715 | 715 |
| 716 id3file = id3_file_vfsopen(fd, ID3_FILE_MODE_READONLY); | 716 id3file = id3_file_vfsopen(fd, ID3_FILE_MODE_READONLY); |
| 717 | 717 |
| 718 if (id3file) { | 718 if (id3file) { |
| 719 | 719 |
| 728 string = input_id3_get_string(tag, ID3_FRAME_YEAR); //TDRC | 728 string = input_id3_get_string(tag, ID3_FRAME_YEAR); //TDRC |
| 729 if (!string) | 729 if (!string) |
| 730 string = input_id3_get_string(tag, "TYER"); | 730 string = input_id3_get_string(tag, "TYER"); |
| 731 | 731 |
| 732 if (string) { | 732 if (string) { |
| 733 tuple_associate_int(tuple, FIELD_YEAR, NULL, atoi(string)); | 733 aud_tuple_associate_int(tuple, FIELD_YEAR, NULL, atoi(string)); |
| 734 g_free(string); | 734 g_free(string); |
| 735 string = NULL; | 735 string = NULL; |
| 736 } | 736 } |
| 737 realfn = g_filename_from_uri(filename, NULL, NULL); | 737 realfn = g_filename_from_uri(filename, NULL, NULL); |
| 738 __set_and_free(tuple, FIELD_FILE_NAME, NULL, g_path_get_basename(realfn ? realfn : filename)); | 738 __set_and_free(tuple, FIELD_FILE_NAME, NULL, g_path_get_basename(realfn ? realfn : filename)); |
| 739 __set_and_free(tuple, FIELD_FILE_PATH, NULL, g_path_get_dirname(realfn ? realfn : filename)); | 739 __set_and_free(tuple, FIELD_FILE_PATH, NULL, g_path_get_dirname(realfn ? realfn : filename)); |
| 740 tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, extname(realfn ? realfn : filename)); | 740 aud_tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, extname(realfn ? realfn : filename)); |
| 741 g_free(realfn); realfn = NULL; | 741 g_free(realfn); realfn = NULL; |
| 742 | 742 |
| 743 // length | 743 // length |
| 744 string = input_id3_get_string(tag, "TLEN"); | 744 string = input_id3_get_string(tag, "TLEN"); |
| 745 if (string) { | 745 if (string) { |
| 746 tuple_associate_int(tuple, FIELD_LENGTH, NULL, atoi(string)); | 746 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, atoi(string)); |
| 747 #ifdef DEBUG | 747 #ifdef DEBUG |
| 748 g_message("get_song_tuple: TLEN = %d", tuple_get_int(tuple, FIELD_LENGTH, NULL)); | 748 g_message("get_song_tuple: TLEN = %d", aud_tuple_get_int(tuple, FIELD_LENGTH, NULL)); |
| 749 #endif | 749 #endif |
| 750 g_free(string); | 750 g_free(string); |
| 751 string = NULL; | 751 string = NULL; |
| 752 } | 752 } |
| 753 else { | 753 else { |
| 754 char *dummy = NULL; | 754 char *dummy = NULL; |
| 755 int length = 0; | 755 int length = 0; |
| 756 audmad_get_song_length(filename, &length, fd); | 756 audmad_get_song_length(filename, &length, fd); |
| 757 tuple_associate_int(tuple, FIELD_LENGTH, NULL, length); | 757 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, length); |
| 758 g_free(dummy); | 758 g_free(dummy); |
| 759 } | 759 } |
| 760 | 760 |
| 761 // track number | 761 // track number |
| 762 string = input_id3_get_string(tag, ID3_FRAME_TRACK); | 762 string = input_id3_get_string(tag, ID3_FRAME_TRACK); |
| 763 if (string) { | 763 if (string) { |
| 764 tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atoi(string)); | 764 aud_tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atoi(string)); |
| 765 g_free(string); | 765 g_free(string); |
| 766 string = NULL; | 766 string = NULL; |
| 767 } | 767 } |
| 768 // genre | 768 // genre |
| 769 __set_and_free(tuple, FIELD_GENRE, NULL, input_id3_get_string(tag, ID3_FRAME_GENRE)); | 769 __set_and_free(tuple, FIELD_GENRE, NULL, input_id3_get_string(tag, ID3_FRAME_GENRE)); |
| 770 __set_and_free(tuple, FIELD_COMMENT, NULL, input_id3_get_string(tag, ID3_FRAME_COMMENT)); | 770 __set_and_free(tuple, FIELD_COMMENT, NULL, input_id3_get_string(tag, ID3_FRAME_COMMENT)); |
| 771 #ifdef DEBUG | 771 #ifdef DEBUG |
| 772 g_message("genre = %s", tuple_get_string(tuple, FIELD_GENRE, NULL)); | 772 g_message("genre = %s", aud_tuple_get_string(tuple, FIELD_GENRE, NULL)); |
| 773 #endif | 773 #endif |
| 774 } | 774 } |
| 775 id3_file_close(id3file); | 775 id3_file_close(id3file); |
| 776 } // id3file | 776 } // id3file |
| 777 else { // no id3tag | 777 else { // no id3tag |
| 778 realfn = g_filename_from_uri(filename, NULL, NULL); | 778 realfn = g_filename_from_uri(filename, NULL, NULL); |
| 779 __set_and_free(tuple, FIELD_FILE_NAME, NULL, g_path_get_basename(realfn ? realfn : filename)); | 779 __set_and_free(tuple, FIELD_FILE_NAME, NULL, g_path_get_basename(realfn ? realfn : filename)); |
| 780 __set_and_free(tuple, FIELD_FILE_PATH, NULL, g_path_get_dirname(realfn ? realfn : filename)); | 780 __set_and_free(tuple, FIELD_FILE_PATH, NULL, g_path_get_dirname(realfn ? realfn : filename)); |
| 781 tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, extname(realfn ? realfn : filename)); | 781 aud_tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, extname(realfn ? realfn : filename)); |
| 782 g_free(realfn); realfn = NULL; | 782 g_free(realfn); realfn = NULL; |
| 783 // length | 783 // length |
| 784 { | 784 { |
| 785 char *dummy = NULL; | 785 char *dummy = NULL; |
| 786 int length = 0; | 786 int length = 0; |
| 787 if(tuple_get_int(tuple, FIELD_LENGTH, NULL) == -1) { | 787 if(aud_tuple_get_int(tuple, FIELD_LENGTH, NULL) == -1) { |
| 788 audmad_get_song_length(filename, &length, fd); | 788 audmad_get_song_length(filename, &length, fd); |
| 789 tuple_associate_int(tuple, FIELD_LENGTH, NULL, length); | 789 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, length); |
| 790 } | 790 } |
| 791 g_free(dummy); | 791 g_free(dummy); |
| 792 } | 792 } |
| 793 } | 793 } |
| 794 | 794 |
| 795 tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossy"); | 795 aud_tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossy"); |
| 796 tuple_associate_string(tuple, FIELD_CODEC, NULL, "MPEG Audio (MP3)"); | 796 aud_tuple_associate_string(tuple, FIELD_CODEC, NULL, "MPEG Audio (MP3)"); |
| 797 | 797 |
| 798 if(local_fd) | 798 if(local_fd) |
| 799 vfs_fclose(fd); | 799 vfs_fclose(fd); |
| 800 | 800 |
| 801 #ifdef DEBUG | 801 #ifdef DEBUG |
