forked from len0rd/rockbox
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
This commit is contained in:
parent
1cbac551be
commit
4bf7373b88
1 changed files with 17 additions and 67 deletions
|
|
@ -342,100 +342,50 @@ long get_replaypeak(const char* str)
|
||||||
return peak;
|
return peak;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compare two strings, ignoring case, up to the end nil or another end of
|
|
||||||
* string character. E.g., if eos is '=', "a=" would equal "a". Returns
|
|
||||||
* true for a match, false otherwise.
|
|
||||||
* TODO: This should be placed somewhere else, as it could be useful in
|
|
||||||
* other places too.
|
|
||||||
*/
|
|
||||||
static bool str_equal(const char* s1, const char* s2, char eos)
|
|
||||||
{
|
|
||||||
char c1 = 0;
|
|
||||||
char c2 = 0;
|
|
||||||
|
|
||||||
while (*s1 && *s2 && (*s1 != eos) && (*s2 != eos))
|
|
||||||
{
|
|
||||||
if ((c1 = toupper(*s1)) != (c2 = toupper(*s2)))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
s1++;
|
|
||||||
s2++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c1 == eos)
|
|
||||||
{
|
|
||||||
c1 = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c2 == eos)
|
|
||||||
{
|
|
||||||
c2 = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
return c1 == c2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check for a ReplayGain tag conforming to the "VorbisGain standard". If
|
/* Check for a ReplayGain tag conforming to the "VorbisGain standard". If
|
||||||
* found, set the mp3entry accordingly. If value is NULL, key is expected
|
* found, set the mp3entry accordingly. buffer is where to store the text
|
||||||
* to be on the "key=value" format, and the comparion/extraction is done
|
* contents of the gain tags; up to length bytes (including end nil) can be
|
||||||
* accordingly. buffer is where to store the text contents of the gain tags;
|
* written. Returns number of bytes written to the tag text buffer, or zero
|
||||||
* up to length bytes (including end nil) can be written.
|
* if no ReplayGain tag was found (or nothing was copied to the buffer for
|
||||||
* Returns number of bytes written to the tag text buffer, or zero if
|
|
||||||
* no ReplayGain tag was found (or nothing was copied to the buffer for
|
|
||||||
* other reasons).
|
* other reasons).
|
||||||
*/
|
*/
|
||||||
long parse_replaygain(const char* key, const char* value,
|
long parse_replaygain(const char* key, const char* value,
|
||||||
struct mp3entry* entry, char* buffer, int length)
|
struct mp3entry* entry, char* buffer, int length)
|
||||||
{
|
{
|
||||||
const char* val = value;
|
|
||||||
char **p = NULL;
|
char **p = NULL;
|
||||||
char eos = '\0';
|
|
||||||
|
|
||||||
if (!val)
|
|
||||||
{
|
|
||||||
if (!(val = strchr(key, '=')))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
val++;
|
|
||||||
eos = '=';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (str_equal(key, "replaygain_track_gain", eos)
|
if ((strcasecmp(key, "replaygain_track_gain") == 0)
|
||||||
|| (str_equal(key, "rg_radio", eos) && !entry->track_gain))
|
|| ((strcasecmp(key, "rg_radio") == 0) && !entry->track_gain))
|
||||||
{
|
{
|
||||||
entry->track_gain = get_replaygain(val);
|
entry->track_gain = get_replaygain(value);
|
||||||
p = &(entry->track_gain_string);
|
p = &(entry->track_gain_string);
|
||||||
}
|
}
|
||||||
else if (str_equal(key, "replaygain_album_gain", eos)
|
else if ((strcasecmp(key, "replaygain_album_gain") == 0)
|
||||||
|| (str_equal(key, "rg_audiophile", eos) && !entry->album_gain))
|
|| ((strcasecmp(key, "rg_audiophile") == 0) && !entry->album_gain))
|
||||||
{
|
{
|
||||||
entry->album_gain = get_replaygain(val);
|
entry->album_gain = get_replaygain(value);
|
||||||
p = &(entry->album_gain_string);
|
p = &(entry->album_gain_string);
|
||||||
}
|
}
|
||||||
else if (str_equal(key, "replaygain_track_peak", eos)
|
else if ((strcasecmp(key, "replaygain_track_peak") == 0)
|
||||||
|| (str_equal(key, "rg_peak", eos) && !entry->track_peak))
|
|| ((strcasecmp(key, "rg_peak") == 0) && !entry->track_peak))
|
||||||
{
|
{
|
||||||
entry->track_peak = get_replaypeak(val);
|
entry->track_peak = get_replaypeak(value);
|
||||||
}
|
}
|
||||||
else if (str_equal(key, "replaygain_album_peak", eos))
|
else if (strcasecmp(key, "replaygain_album_peak") == 0)
|
||||||
{
|
{
|
||||||
entry->album_peak = get_replaypeak(val);
|
entry->album_peak = get_replaypeak(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
int len = strlen(val);
|
int len = strlen(value);
|
||||||
|
|
||||||
len = MIN(len, length - 1);
|
len = MIN(len, length - 1);
|
||||||
|
|
||||||
/* A few characters just isn't interesting... */
|
/* A few characters just isn't interesting... */
|
||||||
if (len > 1)
|
if (len > 1)
|
||||||
{
|
{
|
||||||
strncpy(buffer, val, len);
|
strncpy(buffer, value, len);
|
||||||
buffer[len] = 0;
|
buffer[len] = 0;
|
||||||
*p = buffer;
|
*p = buffer;
|
||||||
return len + 1;
|
return len + 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue