diff options
author | William Wilgus <wilgus.william@gmail.com> | 2021-08-07 17:07:32 -0400 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2021-08-07 17:07:32 -0400 |
commit | da778a1783226a4d73714a4d1b91f03811cbf72a (patch) | |
tree | 1a2e21fb76ec99b0ef3da5bfecd51fe43cd6ca87 | |
parent | 5311ff01737524b160d4974449b82a35c2ebeaad (diff) | |
download | rockbox-da778a1783226a4d73714a4d1b91f03811cbf72a.tar.gz rockbox-da778a1783226a4d73714a4d1b91f03811cbf72a.zip |
metadata/asap.c WS cleanup
Change-Id: Id3bc053a45eeea107a54dd47640fa3ceb4b04498
-rw-r--r-- | lib/rbcodec/metadata/asap.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/lib/rbcodec/metadata/asap.c b/lib/rbcodec/metadata/asap.c index 94e4dfce58..b1cd649d89 100644 --- a/lib/rbcodec/metadata/asap.c +++ b/lib/rbcodec/metadata/asap.c | |||
@@ -108,13 +108,13 @@ static bool read_asap_string(char* source, char** buf, char** buffer_end, char** | |||
108 | { | 108 | { |
109 | if(parse_text(*buf,source) == false) | 109 | if(parse_text(*buf,source) == false) |
110 | return false; | 110 | return false; |
111 | 111 | ||
112 | /* set dest pointer */ | 112 | /* set dest pointer */ |
113 | *dest = *buf; | 113 | *dest = *buf; |
114 | 114 | ||
115 | /* move buf ptr */ | 115 | /* move buf ptr */ |
116 | *buf += strlen(*buf)+1; | 116 | *buf += strlen(*buf)+1; |
117 | 117 | ||
118 | /* check size */ | 118 | /* check size */ |
119 | if(*buf >= *buffer_end) | 119 | if(*buf >= *buffer_end) |
120 | { | 120 | { |
@@ -129,26 +129,26 @@ static bool parse_sap_header(int fd, struct mp3entry* id3, int file_len) | |||
129 | int module_index = 0; | 129 | int module_index = 0; |
130 | int sap_signature = -1; | 130 | int sap_signature = -1; |
131 | int duration_index = 0; | 131 | int duration_index = 0; |
132 | unsigned char cur_char = 0; | 132 | unsigned char cur_char = 0; |
133 | int i; | 133 | int i; |
134 | 134 | ||
135 | /* set defaults */ | 135 | /* set defaults */ |
136 | int numSongs = 1; | 136 | int numSongs = 1; |
137 | int defSong = 0; | 137 | int defSong = 0; |
138 | int durations[MAX_SONGS]; | 138 | int durations[MAX_SONGS]; |
139 | for (i = 0; i < MAX_SONGS; i++) | 139 | for (i = 0; i < MAX_SONGS; i++) |
140 | durations[i] = -1; | 140 | durations[i] = -1; |
141 | 141 | ||
142 | /* use id3v2 buffer for our strings */ | 142 | /* use id3v2 buffer for our strings */ |
143 | char* buffer = id3->id3v2buf; | 143 | char* buffer = id3->id3v2buf; |
144 | char* buffer_end = id3->id3v2buf + ID3V2_BUF_SIZE; | 144 | char* buffer_end = id3->id3v2buf + ID3V2_BUF_SIZE; |
145 | 145 | ||
146 | /* parse file */ | 146 | /* parse file */ |
147 | while (1) | 147 | while (1) |
148 | { | 148 | { |
149 | char line[256]; | 149 | char line[256]; |
150 | char *p; | 150 | char *p; |
151 | 151 | ||
152 | if (module_index + 8 >= file_len) | 152 | if (module_index + 8 >= file_len) |
153 | return false; | 153 | return false; |
154 | /* read a char */ | 154 | /* read a char */ |
@@ -156,11 +156,11 @@ static bool parse_sap_header(int fd, struct mp3entry* id3, int file_len) | |||
156 | /* end of header */ | 156 | /* end of header */ |
157 | if (cur_char == 0xff) | 157 | if (cur_char == 0xff) |
158 | break; | 158 | break; |
159 | 159 | ||
160 | i = 0; | 160 | i = 0; |
161 | while (cur_char != 0x0d) | 161 | while (cur_char != 0x0d) |
162 | { | 162 | { |
163 | line[i++] = cur_char; | 163 | line[i++] = cur_char; |
164 | module_index++; | 164 | module_index++; |
165 | if (module_index >= file_len || (unsigned)i >= sizeof(line) - 1) | 165 | if (module_index >= file_len || (unsigned)i >= sizeof(line) - 1) |
166 | return false; | 166 | return false; |
@@ -171,9 +171,9 @@ static bool parse_sap_header(int fd, struct mp3entry* id3, int file_len) | |||
171 | return false; | 171 | return false; |
172 | /* read a char */ | 172 | /* read a char */ |
173 | read(fd,&cur_char,1); | 173 | read(fd,&cur_char,1); |
174 | if ( cur_char != 0x0a) | 174 | if ( cur_char != 0x0a) |
175 | return false; | 175 | return false; |
176 | 176 | ||
177 | line[i] = '\0'; | 177 | line[i] = '\0'; |
178 | for (p = line; *p != '\0'; p++) { | 178 | for (p = line; *p != '\0'; p++) { |
179 | if (*p == ' ') { | 179 | if (*p == ' ') { |
@@ -181,7 +181,7 @@ static bool parse_sap_header(int fd, struct mp3entry* id3, int file_len) | |||
181 | break; | 181 | break; |
182 | } | 182 | } |
183 | } | 183 | } |
184 | 184 | ||
185 | /* parse tags */ | 185 | /* parse tags */ |
186 | if(strcmp(line, "SAP") == 0) | 186 | if(strcmp(line, "SAP") == 0) |
187 | sap_signature = 1; | 187 | sap_signature = 1; |
@@ -200,49 +200,49 @@ static bool parse_sap_header(int fd, struct mp3entry* id3, int file_len) | |||
200 | else if(strcmp(line, "DATE") == 0) | 200 | else if(strcmp(line, "DATE") == 0) |
201 | { | 201 | { |
202 | if(read_asap_string(p, &buffer, &buffer_end, &id3->year_string) == false) | 202 | if(read_asap_string(p, &buffer, &buffer_end, &id3->year_string) == false) |
203 | return false; | 203 | return false; |
204 | } | 204 | } |
205 | else if (strcmp(line, "SONGS") == 0) | 205 | else if (strcmp(line, "SONGS") == 0) |
206 | { | 206 | { |
207 | if (parse_dec(&numSongs, p, 1, MAX_SONGS) == false ) | 207 | if (parse_dec(&numSongs, p, 1, MAX_SONGS) == false ) |
208 | return false; | 208 | return false; |
209 | } | 209 | } |
210 | else if (strcmp(line, "DEFSONG") == 0) | 210 | else if (strcmp(line, "DEFSONG") == 0) |
211 | { | 211 | { |
212 | if (parse_dec(&defSong, p, 0, MAX_SONGS) == false) | 212 | if (parse_dec(&defSong, p, 0, MAX_SONGS) == false) |
213 | return false; | 213 | return false; |
214 | } | 214 | } |
215 | else if (strcmp(line, "TIME") == 0) | 215 | else if (strcmp(line, "TIME") == 0) |
216 | { | 216 | { |
217 | int durationTemp = ASAP_ParseDuration(p); | 217 | int durationTemp = ASAP_ParseDuration(p); |
218 | if (durationTemp < 0 || duration_index >= MAX_SONGS) | 218 | if (durationTemp < 0 || duration_index >= MAX_SONGS) |
219 | return false; | 219 | return false; |
220 | durations[duration_index++] = durationTemp; | 220 | durations[duration_index++] = durationTemp; |
221 | } | 221 | } |
222 | } | 222 | } |
223 | 223 | ||
224 | /* set length: */ | 224 | /* set length: */ |
225 | int length = durations[defSong]; | 225 | int length = durations[defSong]; |
226 | if (length < 0) | 226 | if (length < 0) |
227 | length = 180 * 1000; | 227 | length = 180 * 1000; |
228 | id3->length = length; | 228 | id3->length = length; |
229 | 229 | ||
230 | lseek(fd, 0, SEEK_SET); | 230 | lseek(fd, 0, SEEK_SET); |
231 | return true; | 231 | return true; |
232 | } | 232 | } |
233 | 233 | ||
234 | 234 | ||
235 | bool get_asap_metadata(int fd, struct mp3entry* id3) | 235 | bool get_asap_metadata(int fd, struct mp3entry* id3) |
236 | { | 236 | { |
237 | 237 | ||
238 | int filelength = filesize(fd); | 238 | int filelength = filesize(fd); |
239 | 239 | ||
240 | if(parse_sap_header(fd, id3, filelength) == false) | 240 | if(parse_sap_header(fd, id3, filelength) == false) |
241 | { | 241 | { |
242 | DEBUGF("parse sap header failed.\n"); | 242 | DEBUGF("parse sap header failed.\n"); |
243 | return false; | 243 | return false; |
244 | } | 244 | } |
245 | 245 | ||
246 | id3->bitrate = 706; | 246 | id3->bitrate = 706; |
247 | id3->frequency = 44100; | 247 | id3->frequency = 44100; |
248 | 248 | ||