Remove unneeded function call (radio_load_presets does clear the memory)
[kugel-rb/myfork.git] / apps / metadata / vorbis.c
blobcfaa7158f16f171b839dbc4ddb8cf78bf3f28fe2
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 Dave Chapman
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #include <stdio.h>
22 #include <string.h>
23 #include <stdlib.h>
24 #include <ctype.h>
25 #include <inttypes.h>
27 #include "system.h"
28 #include "metadata.h"
29 #include "metadata_common.h"
30 #include "metadata_parsers.h"
31 #include "structec.h"
32 #include "logf.h"
34 /* Read the items in a Vorbis comment packet. Returns true the items were
35 * fully read, false otherwise.
37 bool read_vorbis_tags(int fd, struct mp3entry *id3,
38 long tag_remaining)
40 char *buf = id3->id3v2buf;
41 int32_t comment_count;
42 int32_t len;
43 int buf_remaining = sizeof(id3->id3v2buf) + sizeof(id3->id3v1buf);
44 int i;
46 if (ecread(fd, &len, 1, "l", IS_BIG_ENDIAN) < (long) sizeof(len))
48 return false;
51 if ((lseek(fd, len, SEEK_CUR) < 0)
52 || (ecread(fd, &comment_count, 1, "l", IS_BIG_ENDIAN)
53 < (long) sizeof(comment_count)))
55 return false;
58 tag_remaining -= len + sizeof(len) + sizeof(comment_count);
60 if (tag_remaining <= 0)
62 return true;
65 for (i = 0; i < comment_count; i++)
67 char name[TAG_NAME_LENGTH];
68 char value[TAG_VALUE_LENGTH];
69 int32_t read_len;
71 if (tag_remaining < 4)
73 break;
76 if (ecread(fd, &len, 1, "l", IS_BIG_ENDIAN) < (long) sizeof(len))
78 return false;
81 tag_remaining -= 4;
83 /* Quit if we've passed the end of the page */
84 if (tag_remaining < len)
86 break;
89 tag_remaining -= len;
90 read_len = read_string(fd, name, sizeof(name), '=', len);
92 if (read_len < 0)
94 return false;
97 len -= read_len;
99 if (read_string(fd, value, sizeof(value), -1, len) < 0)
101 return false;
104 len = parse_tag(name, value, id3, buf, buf_remaining,
105 TAGTYPE_VORBIS);
106 buf += len;
107 buf_remaining -= len;
110 /* Skip to the end of the block */
111 if (tag_remaining)
113 if (lseek(fd, tag_remaining, SEEK_CUR) < 0)
115 return false;
119 return true;