diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-08-10 14:32:40 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-08-10 14:32:40 -0400 |
commit | 8c7780bafc9eabac6b92cfe5a5a00831c3d5fd9d (patch) | |
tree | 4b13a42d0494af573d5f3a322c40ad0706be9d5c | |
parent | 5758a055fb6b7f1e2e61149174c7503994aa62a0 (diff) | |
download | rockbox-8c7780bafc9eabac6b92cfe5a5a00831c3d5fd9d.tar.gz rockbox-8c7780bafc9eabac6b92cfe5a5a00831c3d5fd9d.zip |
flac: fix warning introduced in 5758a05
Change-Id: I649f7c356b8b790d6dfbd071a8e391a84d0cdcca
-rw-r--r-- | lib/rbcodec/metadata/flac.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/lib/rbcodec/metadata/flac.c b/lib/rbcodec/metadata/flac.c index af39c1346b..f19591fe3e 100644 --- a/lib/rbcodec/metadata/flac.c +++ b/lib/rbcodec/metadata/flac.c @@ -33,9 +33,9 @@ bool get_flac_metadata(int fd, struct mp3entry* id3) { /* A simple parser to read vital metadata from a FLAC file - length, - * frequency, bitrate etc. This code should either be moved to a + * frequency, bitrate etc. This code should either be moved to a * seperate file, or discarded in favour of the libFLAC code. - * The FLAC stream specification can be found at + * The FLAC stream specification can be found at * http://flac.sourceforge.net/format.html#stream */ @@ -48,22 +48,22 @@ bool get_flac_metadata(int fd, struct mp3entry* id3) { return rc; } - - if (memcmp(buf, "fLaC", 4) != 0) + + if (memcmp(buf, "fLaC", 4) != 0) { return rc; } - while (!last_metadata) + while (!last_metadata) { unsigned long i; int type; - + if (read(fd, buf, 4) != 4) { return rc; } - + last_metadata = buf[0] & 0x80; type = buf[0] & 0x7f; /* The length of the block */ @@ -72,39 +72,39 @@ bool get_flac_metadata(int fd, struct mp3entry* id3) if (type == 0) /* 0 is the STREAMINFO block */ { unsigned long totalsamples; - - if (i >= sizeof(id3->path) || read(fd, buf, i) != i) + + if (i >= sizeof(id3->path) || read(fd, buf, i) != (int)i) { return rc; } - + id3->vbr = true; /* All FLAC files are VBR */ id3->filesize = filesize(fd); - id3->frequency = (buf[10] << 12) | (buf[11] << 4) + id3->frequency = (buf[10] << 12) | (buf[11] << 4) | ((buf[12] & 0xf0) >> 4); rc = true; /* Got vital metadata */ /* totalsamples is a 36-bit field, but we assume <= 32 bits are used */ totalsamples = get_long_be(&buf[14]); - + if(totalsamples > 0) { - /* Calculate track length (in ms) and estimate the bitrate (in kbit/s) */ + /* Calculate track length (in ms) and estimate the bitrate (in kbit/s) */ id3->length = ((int64_t) totalsamples * 1000) / id3->frequency; - id3->bitrate = (id3->filesize * 8) / id3->length; - } + id3->bitrate = (id3->filesize * 8) / id3->length; + } else if (totalsamples == 0) { id3->length = 0; id3->bitrate = 0; } - else + else { logf("flac length invalid!"); return false; } - } + } else if (type == 4) /* 4 is the VORBIS_COMMENT block */ { /* The next i bytes of the file contain the VORBIS COMMENTS. */ @@ -112,7 +112,7 @@ bool get_flac_metadata(int fd, struct mp3entry* id3) { return rc; } - } + } #ifdef HAVE_ALBUMART else if (type == 6) /* 6 is the PICTURE block */ { @@ -172,6 +172,6 @@ bool get_flac_metadata(int fd, struct mp3entry* id3) } } } - + return true; } |