summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2005-12-01 20:39:19 +0000
committerDave Chapman <dave@dchapman.com>2005-12-01 20:39:19 +0000
commit15ca09106da0fc332ce7b9d999c69be573bf6f5b (patch)
tree44e2fc29790ccd1e56ce0228d66b42c0eb07ed70
parent59e0ccb278c11d43502b455662f4f40726cb8650 (diff)
downloadrockbox-15ca09106da0fc332ce7b9d999c69be573bf6f5b.tar.gz
rockbox-15ca09106da0fc332ce7b9d999c69be573bf6f5b.zip
Set appropriate codec type for .m4a files (ALAC or AAC) inside get_metadata(). probe_file_format() is no longer an exported function. Make get_metadata() return false if it can not read the metadata - on the assumption that the codec will also fail.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8118 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/metadata.c35
-rw-r--r--apps/metadata.h1
2 files changed, 17 insertions, 19 deletions
diff --git a/apps/metadata.c b/apps/metadata.c
index 49780b5860..740f3d8f9a 100644
--- a/apps/metadata.c
+++ b/apps/metadata.c
@@ -1181,16 +1181,12 @@ static bool get_m4a_metadata(int fd, struct mp3entry* id3)
1181 entry_size=(buf[i]<<24)|(buf[i+1]<<16)|(buf[i+2]<<8)|buf[i+3]; 1181 entry_size=(buf[i]<<24)|(buf[i+1]<<16)|(buf[i+2]<<8)|buf[i+3];
1182 i+=4; 1182 i+=4;
1183 1183
1184 /* Check the codec type - 'alac' for ALAC, 'mp4a' for AAC */ 1184 if (memcmp(&buf[i],"alac",4)==0) {
1185 if ((id3->codectype==AFMT_ALAC) && 1185 id3->codectype=AFMT_ALAC;
1186 (memcmp(&buf[i],"alac",4)!=0)) { 1186 } else if (memcmp(&buf[i],"mp4a",4)==0) {
1187 logf("Not an ALAC file\n"); 1187 id3->codectype=AFMT_AAC;
1188 return false; 1188 } else {
1189 } 1189 logf("Not an ALAC or AAC file\n");
1190
1191 if ((id3->codectype==AFMT_AAC) &&
1192 (memcmp(&buf[i],"mp4a",4)!=0)) {
1193 logf("Not a MP4 AAC file\n");
1194 return false; 1190 return false;
1195 } 1191 }
1196 1192
@@ -1330,7 +1326,7 @@ static bool get_musepack_metadata(int fd, struct mp3entry *id3)
1330} 1326}
1331 1327
1332/* Simple file type probing by looking at the filename extension. */ 1328/* Simple file type probing by looking at the filename extension. */
1333unsigned int probe_file_format(const char *filename) 1329static unsigned int probe_file_format(const char *filename)
1334{ 1330{
1335 char *suffix; 1331 char *suffix;
1336 unsigned int i; 1332 unsigned int i;
@@ -1364,12 +1360,11 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
1364 unsigned char* buf; 1360 unsigned char* buf;
1365 unsigned long totalsamples; 1361 unsigned long totalsamples;
1366 int i; 1362 int i;
1367 1363
1368 /* We should detect the codec type here. */ 1364 /* Take our best guess at the codec type based on file extension */
1369 track->id3.codectype = probe_file_format(trackname); 1365 track->id3.codectype = probe_file_format(trackname);
1370 1366
1371 /* Load codec specific track tag information. */ 1367 /* Load codec specific track tag information and confirm the codec type. */
1372
1373 switch (track->id3.codectype) 1368 switch (track->id3.codectype)
1374 { 1369 {
1375 case AFMT_MPA_L1: 1370 case AFMT_MPA_L1:
@@ -1518,7 +1513,7 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
1518 case AFMT_AAC: 1513 case AFMT_AAC:
1519 if (!get_m4a_metadata(fd, &(track->id3))) 1514 if (!get_m4a_metadata(fd, &(track->id3)))
1520 { 1515 {
1521// return false; 1516 return false;
1522 } 1517 }
1523 1518
1524 break; 1519 break;
@@ -1533,11 +1528,15 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
1533 /* TODO: read the id3v2 header if it exists */ 1528 /* TODO: read the id3v2 header if it exists */
1534 break; 1529 break;
1535 1530
1536 /* If we don't know how to read the metadata, just store the filename */
1537 default: 1531 default:
1532 /* If we don't know how to read the metadata, assume we can't play
1533 the file */
1534 return false;
1538 break; 1535 break;
1539 } 1536 }
1540 1537
1538 /* We have successfully read the metadata from the file */
1539
1541 lseek(fd, 0, SEEK_SET); 1540 lseek(fd, 0, SEEK_SET);
1542 strncpy(track->id3.path, trackname, sizeof(track->id3.path)); 1541 strncpy(track->id3.path, trackname, sizeof(track->id3.path));
1543 track->taginfo_ready = true; 1542 track->taginfo_ready = true;
diff --git a/apps/metadata.h b/apps/metadata.h
index f790146041..1e07a18277 100644
--- a/apps/metadata.h
+++ b/apps/metadata.h
@@ -22,7 +22,6 @@
22 22
23#include "playback.h" 23#include "playback.h"
24 24
25unsigned int probe_file_format(const char *filename);
26bool get_metadata(struct track_info* track, int fd, const char* trackname, 25bool get_metadata(struct track_info* track, int fd, const char* trackname,
27 bool v1first); 26 bool v1first);
28 27