summaryrefslogtreecommitdiff
path: root/apps/metadata.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/metadata.c')
-rw-r--r--apps/metadata.c88
1 files changed, 44 insertions, 44 deletions
diff --git a/apps/metadata.c b/apps/metadata.c
index 0e770dde7a..7b9bb89706 100644
--- a/apps/metadata.c
+++ b/apps/metadata.c
@@ -301,7 +301,7 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
301 if (memcmp(&buf[i],"OggS",5)==0) { 301 if (memcmp(&buf[i],"OggS",5)==0) {
302 if (i < (j-17)) { 302 if (i < (j-17)) {
303 totalsamples=(buf[i+6])|(buf[i+7]<<8)|(buf[i+8]<<16)|(buf[i+9]<<24); 303 totalsamples=(buf[i+6])|(buf[i+7]<<8)|(buf[i+8]<<16)|(buf[i+9]<<24);
304 last_serialno=(buf[i+14])|(buf[i+15]<<8)|(buf[i+16]<<16)|(buf[i+17]<<24); 304 last_serialno=(buf[i+14])|(buf[i+15]<<8)|(buf[i+16]<<16)|(buf[i+17]<<24);
305 j=0; /* We can discard the rest of the buffer */ 305 j=0; /* We can discard the rest of the buffer */
306 } else { 306 } else {
307 break; 307 break;
@@ -321,11 +321,11 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
321 /* This file has mutiple vorbis bitstreams (or is corrupt) */ 321 /* This file has mutiple vorbis bitstreams (or is corrupt) */
322 /* FIXME we should display an error here */ 322 /* FIXME we should display an error here */
323 if (serialno != last_serialno) { 323 if (serialno != last_serialno) {
324 track->taginfo_ready=false; 324 track->taginfo_ready=false;
325 logf("serialno mismatch"); 325 logf("serialno mismatch");
326 logf("%ld", serialno); 326 logf("%ld", serialno);
327 logf("%ld", last_serialno); 327 logf("%ld", last_serialno);
328 return false; 328 return false;
329 } 329 }
330 330
331 track->id3.samples=totalsamples; 331 track->id3.samples=totalsamples;
@@ -794,24 +794,24 @@ static bool get_vorbis_comments (struct mp3entry *entry, int fd)
794 * packet extends to the third page). 794 * packet extends to the third page).
795 */ 795 */
796 for (i = 0; i < segments; i++) { 796 for (i = 0; i < segments; i++) {
797 packet_remaining += temp[i]; 797 packet_remaining += temp[i];
798 /* The last segment of a packet is always < 255 bytes */ 798 /* The last segment of a packet is always < 255 bytes */
799 if (temp[i] < 255) { 799 if (temp[i] < 255) {
800 break; 800 break;
801 } 801 }
802 } 802 }
803 803
804 /* Now read in packet header (type and id string) */ 804 /* Now read in packet header (type and id string) */
805 if(read(fd, temp, 7) < 7) { 805 if(read(fd, temp, 7) < 7) {
806 return false; 806 return false;
807 } 807 }
808 808
809 /* The first byte of a packet is the packet type; comment packets are 809 /* The first byte of a packet is the packet type; comment packets are
810 * type 3. 810 * type 3.
811 */ 811 */
812 if ((temp[0] != 3) || (memcmp(temp + 1,"vorbis",6)!=0)) { 812 if ((temp[0] != 3) || (memcmp(temp + 1,"vorbis",6)!=0)) {
813 logf("Not a vorbis comment packet"); 813 logf("Not a vorbis comment packet");
814 return false; 814 return false;
815 } 815 }
816 816
817 packet_remaining -= 7; 817 packet_remaining -= 7;
@@ -831,7 +831,7 @@ static bool get_vorbis_comments (struct mp3entry *entry, int fd)
831 little_endian_to_native(&comment_count, "L"); 831 little_endian_to_native(&comment_count, "L");
832 packet_remaining -= (vendor_length + 8); 832 packet_remaining -= (vendor_length + 8);
833 if ( packet_remaining <= 0 ) { 833 if ( packet_remaining <= 0 ) {
834 return true; 834 return true;
835 } 835 }
836 836
837 for ( i = 0; i < comment_count; i++ ) { 837 for ( i = 0; i < comment_count; i++ ) {
@@ -843,10 +843,10 @@ static bool get_vorbis_comments (struct mp3entry *entry, int fd)
843 843
844 little_endian_to_native(&comment_length, "L"); 844 little_endian_to_native(&comment_length, "L");
845 845
846 /* Quit if we've passed the end of the page */ 846 /* Quit if we've passed the end of the page */
847 packet_remaining -= (comment_length + 4); 847 packet_remaining -= (comment_length + 4);
848 if ( packet_remaining <= 0 ) { 848 if ( packet_remaining <= 0 ) {
849 return true; 849 return true;
850 } 850 }
851 851
852 /* Skip comment if it won't fit in buffer */ 852 /* Skip comment if it won't fit in buffer */
@@ -876,37 +876,37 @@ static bool get_vorbis_comments (struct mp3entry *entry, int fd)
876 name_length = 5; 876 name_length = 5;
877 p = &(entry->genre_string); 877 p = &(entry->genre_string);
878 } else if (strncasecmp(temp, "DATE=", 5) == 0) { 878 } else if (strncasecmp(temp, "DATE=", 5) == 0) {
879 int j=0; 879 int j=0;
880 /* verify that this is a number */ 880 /* verify that this is a number */
881 /* Note: vorbis uses UTF-8 for its comments, so it is 881 /* Note: vorbis uses UTF-8 for its comments, so it is
882 * safe to compare the values against ASCII 0 and 9 882 * safe to compare the values against ASCII 0 and 9
883 */ 883 */
884 while ( j < (comment_length - 5) ) { 884 while ( j < (comment_length - 5) ) {
885 if ( (temp[5+j] < '0') || (temp[5+j] > '9') ) { 885 if ( (temp[5+j] < '0') || (temp[5+j] > '9') ) {
886 break; 886 break;
887 } 887 }
888 j++; 888 j++;
889 } 889 }
890 if ( j == (comment_length - 5) ) { 890 if ( j == (comment_length - 5) ) {
891 p = NULL; 891 p = NULL;
892 entry->year = atoi(temp + 5); 892 entry->year = atoi(temp + 5);
893 } 893 }
894 } else if (strncasecmp(temp, "TRACKNUMBER=", 12) == 0) { 894 } else if (strncasecmp(temp, "TRACKNUMBER=", 12) == 0) {
895 int j=0; 895 int j=0;
896 /* verify that this is a number */ 896 /* verify that this is a number */
897 /* Note: vorbis uses UTF-8 for its comments, so it is 897 /* Note: vorbis uses UTF-8 for its comments, so it is
898 * safe to compare the values against ASCII 0 and 9 898 * safe to compare the values against ASCII 0 and 9
899 */ 899 */
900 while ( j < (comment_length - 12) ) { 900 while ( j < (comment_length - 12) ) {
901 if ( (temp[12+j] < '0') || (temp[12+j] > '9') ) { 901 if ( (temp[12+j] < '0') || (temp[12+j] > '9') ) {
902 break; 902 break;
903 } 903 }
904 j++; 904 j++;
905 } 905 }
906 if ( j == (comment_length - 12) ) { 906 if ( j == (comment_length - 12) ) {
907 p = NULL; 907 p = NULL;
908 entry->tracknum = atoi(temp + 12); 908 entry->tracknum = atoi(temp + 12);
909 } 909 }
910 } else { 910 } else {
911 p = NULL; 911 p = NULL;
912 } 912 }