diff options
author | Magnus Holmgren <magnushol@gmail.com> | 2005-10-03 18:35:02 +0000 |
---|---|---|
committer | Magnus Holmgren <magnushol@gmail.com> | 2005-10-03 18:35:02 +0000 |
commit | 4bf7373b888c93c9dd1430f186c440673b1c4801 (patch) | |
tree | d773b834fb2df9a8abde1f0c5bb79e190eb2c4fa /firmware | |
parent | 1cbac551be172186ad43aec96f5ff38a49ca7a32 (diff) | |
download | rockbox-4bf7373b888c93c9dd1430f186c440673b1c4801.tar.gz rockbox-4bf7373b888c93c9dd1430f186c440673b1c4801.zip |
iRiver: remove some code that isn't needed any more.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7578 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/replaygain.c | 84 |
1 files changed, 17 insertions, 67 deletions
diff --git a/firmware/replaygain.c b/firmware/replaygain.c index a21336013b..3a2e89757a 100644 --- a/firmware/replaygain.c +++ b/firmware/replaygain.c | |||
@@ -342,100 +342,50 @@ long get_replaypeak(const char* str) | |||
342 | return peak; | 342 | return peak; |
343 | } | 343 | } |
344 | 344 | ||
345 | /* Compare two strings, ignoring case, up to the end nil or another end of | ||
346 | * string character. E.g., if eos is '=', "a=" would equal "a". Returns | ||
347 | * true for a match, false otherwise. | ||
348 | * TODO: This should be placed somewhere else, as it could be useful in | ||
349 | * other places too. | ||
350 | */ | ||
351 | static bool str_equal(const char* s1, const char* s2, char eos) | ||
352 | { | ||
353 | char c1 = 0; | ||
354 | char c2 = 0; | ||
355 | |||
356 | while (*s1 && *s2 && (*s1 != eos) && (*s2 != eos)) | ||
357 | { | ||
358 | if ((c1 = toupper(*s1)) != (c2 = toupper(*s2))) | ||
359 | { | ||
360 | return false; | ||
361 | } | ||
362 | |||
363 | s1++; | ||
364 | s2++; | ||
365 | } | ||
366 | |||
367 | if (c1 == eos) | ||
368 | { | ||
369 | c1 = '\0'; | ||
370 | } | ||
371 | |||
372 | if (c2 == eos) | ||
373 | { | ||
374 | c2 = '\0'; | ||
375 | } | ||
376 | |||
377 | return c1 == c2; | ||
378 | } | ||
379 | |||
380 | /* Check for a ReplayGain tag conforming to the "VorbisGain standard". If | 345 | /* Check for a ReplayGain tag conforming to the "VorbisGain standard". If |
381 | * found, set the mp3entry accordingly. If value is NULL, key is expected | 346 | * found, set the mp3entry accordingly. buffer is where to store the text |
382 | * to be on the "key=value" format, and the comparion/extraction is done | 347 | * contents of the gain tags; up to length bytes (including end nil) can be |
383 | * accordingly. buffer is where to store the text contents of the gain tags; | 348 | * written. Returns number of bytes written to the tag text buffer, or zero |
384 | * up to length bytes (including end nil) can be written. | 349 | * if no ReplayGain tag was found (or nothing was copied to the buffer for |
385 | * Returns number of bytes written to the tag text buffer, or zero if | ||
386 | * no ReplayGain tag was found (or nothing was copied to the buffer for | ||
387 | * other reasons). | 350 | * other reasons). |
388 | */ | 351 | */ |
389 | long parse_replaygain(const char* key, const char* value, | 352 | long parse_replaygain(const char* key, const char* value, |
390 | struct mp3entry* entry, char* buffer, int length) | 353 | struct mp3entry* entry, char* buffer, int length) |
391 | { | 354 | { |
392 | const char* val = value; | ||
393 | char **p = NULL; | 355 | char **p = NULL; |
394 | char eos = '\0'; | ||
395 | |||
396 | if (!val) | ||
397 | { | ||
398 | if (!(val = strchr(key, '='))) | ||
399 | { | ||
400 | return 0; | ||
401 | } | ||
402 | |||
403 | val++; | ||
404 | eos = '='; | ||
405 | } | ||
406 | 356 | ||
407 | if (str_equal(key, "replaygain_track_gain", eos) | 357 | if ((strcasecmp(key, "replaygain_track_gain") == 0) |
408 | || (str_equal(key, "rg_radio", eos) && !entry->track_gain)) | 358 | || ((strcasecmp(key, "rg_radio") == 0) && !entry->track_gain)) |
409 | { | 359 | { |
410 | entry->track_gain = get_replaygain(val); | 360 | entry->track_gain = get_replaygain(value); |
411 | p = &(entry->track_gain_string); | 361 | p = &(entry->track_gain_string); |
412 | } | 362 | } |
413 | else if (str_equal(key, "replaygain_album_gain", eos) | 363 | else if ((strcasecmp(key, "replaygain_album_gain") == 0) |
414 | || (str_equal(key, "rg_audiophile", eos) && !entry->album_gain)) | 364 | || ((strcasecmp(key, "rg_audiophile") == 0) && !entry->album_gain)) |
415 | { | 365 | { |
416 | entry->album_gain = get_replaygain(val); | 366 | entry->album_gain = get_replaygain(value); |
417 | p = &(entry->album_gain_string); | 367 | p = &(entry->album_gain_string); |
418 | } | 368 | } |
419 | else if (str_equal(key, "replaygain_track_peak", eos) | 369 | else if ((strcasecmp(key, "replaygain_track_peak") == 0) |
420 | || (str_equal(key, "rg_peak", eos) && !entry->track_peak)) | 370 | || ((strcasecmp(key, "rg_peak") == 0) && !entry->track_peak)) |
421 | { | 371 | { |
422 | entry->track_peak = get_replaypeak(val); | 372 | entry->track_peak = get_replaypeak(value); |
423 | } | 373 | } |
424 | else if (str_equal(key, "replaygain_album_peak", eos)) | 374 | else if (strcasecmp(key, "replaygain_album_peak") == 0) |
425 | { | 375 | { |
426 | entry->album_peak = get_replaypeak(val); | 376 | entry->album_peak = get_replaypeak(value); |
427 | } | 377 | } |
428 | 378 | ||
429 | if (p) | 379 | if (p) |
430 | { | 380 | { |
431 | int len = strlen(val); | 381 | int len = strlen(value); |
432 | 382 | ||
433 | len = MIN(len, length - 1); | 383 | len = MIN(len, length - 1); |
434 | 384 | ||
435 | /* A few characters just isn't interesting... */ | 385 | /* A few characters just isn't interesting... */ |
436 | if (len > 1) | 386 | if (len > 1) |
437 | { | 387 | { |
438 | strncpy(buffer, val, len); | 388 | strncpy(buffer, value, len); |
439 | buffer[len] = 0; | 389 | buffer[len] = 0; |
440 | *p = buffer; | 390 | *p = buffer; |
441 | return len + 1; | 391 | return len + 1; |