diff options
Diffstat (limited to 'lib/rbcodec/metadata/aiff.c')
-rw-r--r-- | lib/rbcodec/metadata/aiff.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/lib/rbcodec/metadata/aiff.c b/lib/rbcodec/metadata/aiff.c index 1bb95f3ed2..eb0b5589d9 100644 --- a/lib/rbcodec/metadata/aiff.c +++ b/lib/rbcodec/metadata/aiff.c | |||
@@ -34,15 +34,24 @@ | |||
34 | /* compressionType: AIFC QuickTime IMA ADPCM */ | 34 | /* compressionType: AIFC QuickTime IMA ADPCM */ |
35 | #define AIFC_FORMAT_QT_IMA_ADPCM "ima4" | 35 | #define AIFC_FORMAT_QT_IMA_ADPCM "ima4" |
36 | 36 | ||
37 | static void read_id3_tags(int fd, struct mp3entry* id3) | ||
38 | { | ||
39 | id3->tracknum = 0; | ||
40 | id3->discnum = 0; | ||
41 | setid3v2title(fd, id3); | ||
42 | } | ||
43 | |||
37 | bool get_aiff_metadata(int fd, struct mp3entry* id3) | 44 | bool get_aiff_metadata(int fd, struct mp3entry* id3) |
38 | { | 45 | { |
39 | unsigned char buf[512]; | 46 | unsigned char buf[512]; |
40 | unsigned long numChannels = 0; | 47 | unsigned long numChannels = 0; |
41 | unsigned long numSampleFrames = 0; | 48 | unsigned long numSampleFrames = 0; |
42 | unsigned long numbytes = 0; | 49 | unsigned long numbytes = 0; |
50 | unsigned long offset = 0; | ||
43 | bool is_aifc = false; | 51 | bool is_aifc = false; |
44 | char *p=id3->id3v2buf; | 52 | char *p=id3->id3v2buf; |
45 | 53 | ||
54 | |||
46 | if ((lseek(fd, 0, SEEK_SET) < 0) || (read(fd, &buf[0], 12) < 12) || | 55 | if ((lseek(fd, 0, SEEK_SET) < 0) || (read(fd, &buf[0], 12) < 12) || |
47 | (memcmp(&buf[0], "FORM", 4) != 0) || (memcmp(&buf[8], "AIF", 3) != 0) || | 56 | (memcmp(&buf[0], "FORM", 4) != 0) || (memcmp(&buf[8], "AIF", 3) != 0) || |
48 | (!(is_aifc = (buf[11] == 'C')) && buf[11] != 'F')) | 57 | (!(is_aifc = (buf[11] == 'C')) && buf[11] != 'F')) |
@@ -50,6 +59,7 @@ bool get_aiff_metadata(int fd, struct mp3entry* id3) | |||
50 | return false; | 59 | return false; |
51 | } | 60 | } |
52 | 61 | ||
62 | |||
53 | while (read(fd, &buf[0], 8) == 8) | 63 | while (read(fd, &buf[0], 8) == 8) |
54 | { | 64 | { |
55 | size_t size = get_long_be(&buf[4]); /* chunkSize */ | 65 | size_t size = get_long_be(&buf[4]); /* chunkSize */ |
@@ -57,6 +67,18 @@ bool get_aiff_metadata(int fd, struct mp3entry* id3) | |||
57 | if (memcmp(&buf[0], "SSND", 4) == 0) | 67 | if (memcmp(&buf[0], "SSND", 4) == 0) |
58 | { | 68 | { |
59 | numbytes = size - 8; | 69 | numbytes = size - 8; |
70 | |||
71 | /* check for ID3 tag */ | ||
72 | offset=lseek(fd, 0, SEEK_CUR); | ||
73 | lseek(fd, size, SEEK_CUR); | ||
74 | if ((read(fd, &buf[0], 8) == 8) && (memcmp(&buf[0], "ID3", 3) == 0)) | ||
75 | { | ||
76 | id3->id3v2len = get_long_be(&buf[4]); | ||
77 | read_id3_tags(fd, id3); | ||
78 | } | ||
79 | else | ||
80 | DEBUGF("ID3 tag not present immediately after sound data"); | ||
81 | lseek(fd, offset, SEEK_SET); | ||
60 | break; /* assume COMM was already read */ | 82 | break; /* assume COMM was already read */ |
61 | } | 83 | } |
62 | 84 | ||
@@ -72,25 +94,30 @@ bool get_aiff_metadata(int fd, struct mp3entry* id3) | |||
72 | 94 | ||
73 | if (memcmp(&buf[0], "NAME", 4) == 0) | 95 | if (memcmp(&buf[0], "NAME", 4) == 0) |
74 | { | 96 | { |
75 | read_string(fd, p, 512, 20, size); | 97 | read_string(fd, p, 512, 0, size); |
76 | id3->title=p; | 98 | id3->title=p; |
77 | p+=size; | 99 | p+=size; |
78 | } | 100 | } |
79 | 101 | ||
80 | else if (memcmp(&buf[0], "AUTH", 4) == 0) | 102 | else if (memcmp(&buf[0], "AUTH", 4) == 0) |
81 | { | 103 | { |
82 | read_string(fd, p, 512, 20, size); | 104 | read_string(fd, p, 512, 0, size); |
83 | id3->artist=p; | 105 | id3->artist=p; |
84 | p+=size; | 106 | p+=size; |
85 | } | 107 | } |
86 | 108 | ||
87 | else if (memcmp(&buf[0], "ANNO", 4) == 0) | 109 | else if (memcmp(&buf[0], "ANNO", 4) == 0) |
88 | { | 110 | { |
89 | read_string(fd, p, 512, 20, size); | 111 | read_string(fd, p, 512, 0, size); |
90 | id3->comment=p; | 112 | id3->comment=p; |
91 | p+=size; | 113 | p+=size; |
92 | } | 114 | } |
93 | 115 | ||
116 | else if (memcmp(&buf[0], "ID3", 3) == 0) | ||
117 | { | ||
118 | read_id3_tags(fd, id3); | ||
119 | } | ||
120 | |||
94 | 121 | ||
95 | else if (memcmp(&buf[0], "COMM", 4) == 0) | 122 | else if (memcmp(&buf[0], "COMM", 4) == 0) |
96 | { | 123 | { |