summaryrefslogtreecommitdiff
path: root/apps/metadata/ogg.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/metadata/ogg.c')
-rw-r--r--apps/metadata/ogg.c59
1 files changed, 1 insertions, 58 deletions
diff --git a/apps/metadata/ogg.c b/apps/metadata/ogg.c
index cd4c85f46e..3a3cb29998 100644
--- a/apps/metadata/ogg.c
+++ b/apps/metadata/ogg.c
@@ -115,64 +115,7 @@ bool get_ogg_metadata(int fd, struct mp3entry* id3)
115 * one from the last page (since we only support a single bitstream). 115 * one from the last page (since we only support a single bitstream).
116 */ 116 */
117 serial = get_long_le(&buf[14]); 117 serial = get_long_le(&buf[14]);
118 118 comment_size = read_vorbis_tags(fd, id3, remaining);
119 /* Minimum header length for Ogg pages is 27. */
120 if (read(fd, buf, 27) < 27)
121 {
122 return false;
123 }
124
125 if (memcmp(buf, "OggS", 4) !=0 )
126 {
127 return false;
128 }
129
130 segments = buf[26];
131
132 /* read in segment table */
133 if (read(fd, buf, segments) < segments)
134 {
135 return false;
136 }
137
138 /* The second packet in a vorbis stream is the comment packet. It *may*
139 * extend beyond the second page, but usually does not. Here we find the
140 * length of the comment packet (or the rest of the page if the comment
141 * packet extends to the third page).
142 */
143 for (i = 0; i < segments; i++)
144 {
145 remaining += buf[i];
146
147 /* The last segment of a packet is always < 255 bytes */
148 if (buf[i] < 255)
149 {
150 break;
151 }
152 }
153
154 comment_size = remaining;
155
156 if (id3->codectype == AFMT_OGG_VORBIS) {
157 /* Now read in packet header (type and id string) */
158 if (read(fd, buf, 7) < 7)
159 {
160 return false;
161 }
162
163 remaining -= 7;
164
165 /* The first byte of a packet is the packet type; comment packets are
166 * type 3.
167 */
168 if (buf[0] != 3)
169 {
170 return false;
171 }
172 }
173
174 /* Failure to read the tags isn't fatal. */
175 read_vorbis_tags(fd, id3, remaining);
176 119
177 /* We now need to search for the last page in the file - identified by 120 /* We now need to search for the last page in the file - identified by
178 * by ('O','g','g','S',0) and retrieve totalsamples. 121 * by ('O','g','g','S',0) and retrieve totalsamples.