diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2005-06-07 18:03:33 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2005-06-07 18:03:33 +0000 |
commit | 61716dd645f87d29f5bd10c22603ff3c5ad1babc (patch) | |
tree | 54b8911560fc236374fa92ee5938ebd9d4783970 /apps | |
parent | 91c46c818a4a200f31945fccca6834d6ee34bf4f (diff) | |
download | rockbox-61716dd645f87d29f5bd10c22603ff3c5ad1babc.tar.gz rockbox-61716dd645f87d29f5bd10c22603ff3c5ad1babc.zip |
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
Diffstat (limited to 'apps')
-rw-r--r-- | apps/playback.c | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/apps/playback.c b/apps/playback.c index d1678a89e1..73a014c9a9 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -350,25 +350,31 @@ bool codec_seek_buffer_callback(off_t newpos) | |||
350 | return true; | 350 | return true; |
351 | } | 351 | } |
352 | 352 | ||
353 | char *rindex(const char *s, int c) | ||
354 | { | ||
355 | char *p = NULL; | ||
356 | |||
357 | if (s == NULL) | ||
358 | return NULL; | ||
359 | |||
360 | while (*s != '\0') { | ||
361 | if (*s == c) | ||
362 | p = (char *)s; | ||
363 | s++; | ||
364 | } | ||
365 | |||
366 | return p; | ||
367 | } | ||
368 | |||
353 | /* Simple file type probing by looking filename extension. */ | 369 | /* Simple file type probing by looking filename extension. */ |
354 | int probe_file_format(const char *filename) | 370 | int probe_file_format(const char *filename) |
355 | { | 371 | { |
356 | char suffix[4]; | 372 | char *suffix; |
357 | char *p; | ||
358 | int len, i; | ||
359 | 373 | ||
360 | if (filename == NULL) | 374 | suffix = rindex(filename, '.'); |
375 | if (suffix == NULL) | ||
361 | return AFMT_UNKNOWN; | 376 | return AFMT_UNKNOWN; |
362 | 377 | suffix += 1; | |
363 | len = strlen(filename); | ||
364 | if (len < 4) | ||
365 | return AFMT_UNKNOWN; | ||
366 | |||
367 | p = (char *)&filename[len-3]; | ||
368 | memset(suffix, 0, sizeof(suffix)); | ||
369 | for (i = 0; i < 3; i++) { | ||
370 | suffix[i] = tolower(p[i]); | ||
371 | } | ||
372 | 378 | ||
373 | if (!strcmp("mp3", suffix)) | 379 | if (!strcmp("mp3", suffix)) |
374 | return AFMT_MPA_L3; | 380 | return AFMT_MPA_L3; |
@@ -376,7 +382,7 @@ int probe_file_format(const char *filename) | |||
376 | return AFMT_OGG_VORBIS; | 382 | return AFMT_OGG_VORBIS; |
377 | else if (!strcmp("wav", suffix)) | 383 | else if (!strcmp("wav", suffix)) |
378 | return AFMT_PCM_WAV; | 384 | return AFMT_PCM_WAV; |
379 | else if (!strcmp("flac", suffix)) // FIX THIS | 385 | else if (!strcmp("flac", suffix)) |
380 | return AFMT_FLAC; | 386 | return AFMT_FLAC; |
381 | else if (!strcmp("mpc", suffix)) | 387 | else if (!strcmp("mpc", suffix)) |
382 | return AFMT_MPC; | 388 | return AFMT_MPC; |
@@ -385,11 +391,11 @@ int probe_file_format(const char *filename) | |||
385 | else if (!strcmp("ape", suffix)) | 391 | else if (!strcmp("ape", suffix)) |
386 | return AFMT_APE; | 392 | return AFMT_APE; |
387 | else if (!strcmp("wma", suffix)) | 393 | else if (!strcmp("wma", suffix)) |
388 | return AFMT_OGG_VORBIS; | 394 | return AFMT_WMA; |
389 | else if (!strcmp("a52", suffix)) | 395 | else if (!strcmp("a52", suffix)) |
390 | return AFMT_OGG_VORBIS; | 396 | return AFMT_A52; |
391 | else if (!strcmp(".rm", suffix)) | 397 | else if (!strcmp("rm", suffix)) |
392 | return AFMT_OGG_VORBIS; | 398 | return AFMT_REAL; |
393 | 399 | ||
394 | return AFMT_UNKNOWN; | 400 | return AFMT_UNKNOWN; |
395 | 401 | ||
@@ -398,6 +404,7 @@ int probe_file_format(const char *filename) | |||
398 | void yield_codecs(void) | 404 | void yield_codecs(void) |
399 | { | 405 | { |
400 | #ifndef SIMULATOR | 406 | #ifndef SIMULATOR |
407 | yield(); | ||
401 | if (!pcm_is_playing()) | 408 | if (!pcm_is_playing()) |
402 | sleep(5); | 409 | sleep(5); |
403 | while (pcm_is_lowdata()) | 410 | while (pcm_is_lowdata()) |