mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Don't block file browser while buffering tracks. Better file extension
probing. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6595 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
91c46c818a
commit
61716dd645
1 changed files with 26 additions and 19 deletions
|
@ -350,25 +350,31 @@ bool codec_seek_buffer_callback(off_t newpos)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *rindex(const char *s, int c)
|
||||||
|
{
|
||||||
|
char *p = NULL;
|
||||||
|
|
||||||
|
if (s == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
while (*s != '\0') {
|
||||||
|
if (*s == c)
|
||||||
|
p = (char *)s;
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
/* Simple file type probing by looking filename extension. */
|
/* Simple file type probing by looking filename extension. */
|
||||||
int probe_file_format(const char *filename)
|
int probe_file_format(const char *filename)
|
||||||
{
|
{
|
||||||
char suffix[4];
|
char *suffix;
|
||||||
char *p;
|
|
||||||
int len, i;
|
|
||||||
|
|
||||||
if (filename == NULL)
|
suffix = rindex(filename, '.');
|
||||||
|
if (suffix == NULL)
|
||||||
return AFMT_UNKNOWN;
|
return AFMT_UNKNOWN;
|
||||||
|
suffix += 1;
|
||||||
len = strlen(filename);
|
|
||||||
if (len < 4)
|
|
||||||
return AFMT_UNKNOWN;
|
|
||||||
|
|
||||||
p = (char *)&filename[len-3];
|
|
||||||
memset(suffix, 0, sizeof(suffix));
|
|
||||||
for (i = 0; i < 3; i++) {
|
|
||||||
suffix[i] = tolower(p[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp("mp3", suffix))
|
if (!strcmp("mp3", suffix))
|
||||||
return AFMT_MPA_L3;
|
return AFMT_MPA_L3;
|
||||||
|
@ -376,7 +382,7 @@ int probe_file_format(const char *filename)
|
||||||
return AFMT_OGG_VORBIS;
|
return AFMT_OGG_VORBIS;
|
||||||
else if (!strcmp("wav", suffix))
|
else if (!strcmp("wav", suffix))
|
||||||
return AFMT_PCM_WAV;
|
return AFMT_PCM_WAV;
|
||||||
else if (!strcmp("flac", suffix)) // FIX THIS
|
else if (!strcmp("flac", suffix))
|
||||||
return AFMT_FLAC;
|
return AFMT_FLAC;
|
||||||
else if (!strcmp("mpc", suffix))
|
else if (!strcmp("mpc", suffix))
|
||||||
return AFMT_MPC;
|
return AFMT_MPC;
|
||||||
|
@ -385,11 +391,11 @@ int probe_file_format(const char *filename)
|
||||||
else if (!strcmp("ape", suffix))
|
else if (!strcmp("ape", suffix))
|
||||||
return AFMT_APE;
|
return AFMT_APE;
|
||||||
else if (!strcmp("wma", suffix))
|
else if (!strcmp("wma", suffix))
|
||||||
return AFMT_OGG_VORBIS;
|
return AFMT_WMA;
|
||||||
else if (!strcmp("a52", suffix))
|
else if (!strcmp("a52", suffix))
|
||||||
return AFMT_OGG_VORBIS;
|
return AFMT_A52;
|
||||||
else if (!strcmp(".rm", suffix))
|
else if (!strcmp("rm", suffix))
|
||||||
return AFMT_OGG_VORBIS;
|
return AFMT_REAL;
|
||||||
|
|
||||||
return AFMT_UNKNOWN;
|
return AFMT_UNKNOWN;
|
||||||
|
|
||||||
|
@ -398,6 +404,7 @@ int probe_file_format(const char *filename)
|
||||||
void yield_codecs(void)
|
void yield_codecs(void)
|
||||||
{
|
{
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
|
yield();
|
||||||
if (!pcm_is_playing())
|
if (!pcm_is_playing())
|
||||||
sleep(5);
|
sleep(5);
|
||||||
while (pcm_is_lowdata())
|
while (pcm_is_lowdata())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue