diff options
author | Dave Bryant <bryant@rockbox.org> | 2006-09-01 23:17:51 +0000 |
---|---|---|
committer | Dave Bryant <bryant@rockbox.org> | 2006-09-01 23:17:51 +0000 |
commit | aeee39b27e15c3fd0202b8bfd672bf4c0ff1162d (patch) | |
tree | 3d8fe93810fc95200e4b0a5da6cbb6d41b3d5fff /apps | |
parent | 7d8c5aaf6ac05eea2ea1fb3a3af938c68372264e (diff) | |
download | rockbox-aeee39b27e15c3fd0202b8bfd672bf4c0ff1162d.tar.gz rockbox-aeee39b27e15c3fd0202b8bfd672bf4c0ff1162d.zip |
Fixed metadata parser to allow playback of self-extracting WavPack files and
also prevent playback of WavPack files with floating-point audio data.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10850 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/metadata.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/apps/metadata.c b/apps/metadata.c index 8838a83aa4..676108116d 100644 --- a/apps/metadata.c +++ b/apps/metadata.c | |||
@@ -1491,23 +1491,34 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname, | |||
1491 | break; | 1491 | break; |
1492 | 1492 | ||
1493 | case AFMT_WAVPACK: | 1493 | case AFMT_WAVPACK: |
1494 | /* A simple parser to read basic information from a WavPack file. | 1494 | /* A simple parser to read basic information from a WavPack file. This |
1495 | * This will fail on WavPack files that don't have the WavPack header | 1495 | * now works with self-extrating WavPack files and also will fail on |
1496 | * as the first thing (i.e. self-extracting WavPack files) or WavPack | 1496 | * WavPack files containing floating-point audio data (although these |
1497 | * files that have so much extra RIFF data stored in the first block | 1497 | * should be possible to play in theory). |
1498 | * that they don't have samples (very rare, I would think). | ||
1499 | */ | 1498 | */ |
1500 | 1499 | ||
1501 | /* Use the trackname part of the id3 structure as a temporary buffer */ | 1500 | /* Use the trackname part of the id3 structure as a temporary buffer */ |
1502 | buf = track->id3.path; | 1501 | buf = track->id3.path; |
1503 | 1502 | ||
1504 | if ((lseek(fd, 0, SEEK_SET) < 0) || (read(fd, buf, 32) < 32)) | 1503 | for (i = 0; i < 256; ++i) { |
1505 | { | 1504 | |
1506 | return false; | 1505 | /* at every 256 bytes into file, try to read a WavPack header */ |
1506 | |||
1507 | if ((lseek(fd, i * 256, SEEK_SET) < 0) || (read(fd, buf, 32) < 32)) | ||
1508 | { | ||
1509 | return false; | ||
1510 | } | ||
1511 | |||
1512 | /* if valid WavPack 4 header version & not floating data, break */ | ||
1513 | |||
1514 | if (memcmp (buf, "wvpk", 4) == 0 && buf [9] == 4 && | ||
1515 | (buf [8] >= 2 && buf [8] <= 0x10) && !(buf [24] & 0x80)) | ||
1516 | { | ||
1517 | break; | ||
1518 | } | ||
1507 | } | 1519 | } |
1508 | 1520 | ||
1509 | if (memcmp (buf, "wvpk", 4) != 0 || buf [9] != 4 || buf [8] < 2) | 1521 | if (i == 256) { |
1510 | { | ||
1511 | logf ("%s is not a WavPack file\n", trackname); | 1522 | logf ("%s is not a WavPack file\n", trackname); |
1512 | return false; | 1523 | return false; |
1513 | } | 1524 | } |