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 /lib/rbcodec | |
parent | 5758a055fb6b7f1e2e61149174c7503994aa62a0 (diff) | |
download | rockbox-8c7780bafc9eabac6b92cfe5a5a00831c3d5fd9d.tar.gz rockbox-8c7780bafc9eabac6b92cfe5a5a00831c3d5fd9d.zip |
flac: fix warning introduced in 5758a05
Change-Id: I649f7c356b8b790d6dfbd071a8e391a84d0cdcca
Diffstat (limited to 'lib/rbcodec')
-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 @@ | |||
33 | bool get_flac_metadata(int fd, struct mp3entry* id3) | 33 | bool get_flac_metadata(int fd, struct mp3entry* id3) |
34 | { | 34 | { |
35 | /* A simple parser to read vital metadata from a FLAC file - length, | 35 | /* A simple parser to read vital metadata from a FLAC file - length, |
36 | * frequency, bitrate etc. This code should either be moved to a | 36 | * frequency, bitrate etc. This code should either be moved to a |
37 | * seperate file, or discarded in favour of the libFLAC code. | 37 | * seperate file, or discarded in favour of the libFLAC code. |
38 | * The FLAC stream specification can be found at | 38 | * The FLAC stream specification can be found at |
39 | * http://flac.sourceforge.net/format.html#stream | 39 | * http://flac.sourceforge.net/format.html#stream |
40 | */ | 40 | */ |
41 | 41 | ||
@@ -48,22 +48,22 @@ bool get_flac_metadata(int fd, struct mp3entry* id3) | |||
48 | { | 48 | { |
49 | return rc; | 49 | return rc; |
50 | } | 50 | } |
51 | 51 | ||
52 | if (memcmp(buf, "fLaC", 4) != 0) | 52 | if (memcmp(buf, "fLaC", 4) != 0) |
53 | { | 53 | { |
54 | return rc; | 54 | return rc; |
55 | } | 55 | } |
56 | 56 | ||
57 | while (!last_metadata) | 57 | while (!last_metadata) |
58 | { | 58 | { |
59 | unsigned long i; | 59 | unsigned long i; |
60 | int type; | 60 | int type; |
61 | 61 | ||
62 | if (read(fd, buf, 4) != 4) | 62 | if (read(fd, buf, 4) != 4) |
63 | { | 63 | { |
64 | return rc; | 64 | return rc; |
65 | } | 65 | } |
66 | 66 | ||
67 | last_metadata = buf[0] & 0x80; | 67 | last_metadata = buf[0] & 0x80; |
68 | type = buf[0] & 0x7f; | 68 | type = buf[0] & 0x7f; |
69 | /* The length of the block */ | 69 | /* The length of the block */ |
@@ -72,39 +72,39 @@ bool get_flac_metadata(int fd, struct mp3entry* id3) | |||
72 | if (type == 0) /* 0 is the STREAMINFO block */ | 72 | if (type == 0) /* 0 is the STREAMINFO block */ |
73 | { | 73 | { |
74 | unsigned long totalsamples; | 74 | unsigned long totalsamples; |
75 | 75 | ||
76 | if (i >= sizeof(id3->path) || read(fd, buf, i) != i) | 76 | if (i >= sizeof(id3->path) || read(fd, buf, i) != (int)i) |
77 | { | 77 | { |
78 | return rc; | 78 | return rc; |
79 | } | 79 | } |
80 | 80 | ||
81 | id3->vbr = true; /* All FLAC files are VBR */ | 81 | id3->vbr = true; /* All FLAC files are VBR */ |
82 | id3->filesize = filesize(fd); | 82 | id3->filesize = filesize(fd); |
83 | id3->frequency = (buf[10] << 12) | (buf[11] << 4) | 83 | id3->frequency = (buf[10] << 12) | (buf[11] << 4) |
84 | | ((buf[12] & 0xf0) >> 4); | 84 | | ((buf[12] & 0xf0) >> 4); |
85 | rc = true; /* Got vital metadata */ | 85 | rc = true; /* Got vital metadata */ |
86 | 86 | ||
87 | /* totalsamples is a 36-bit field, but we assume <= 32 bits are used */ | 87 | /* totalsamples is a 36-bit field, but we assume <= 32 bits are used */ |
88 | totalsamples = get_long_be(&buf[14]); | 88 | totalsamples = get_long_be(&buf[14]); |
89 | 89 | ||
90 | if(totalsamples > 0) | 90 | if(totalsamples > 0) |
91 | { | 91 | { |
92 | /* Calculate track length (in ms) and estimate the bitrate (in kbit/s) */ | 92 | /* Calculate track length (in ms) and estimate the bitrate (in kbit/s) */ |
93 | id3->length = ((int64_t) totalsamples * 1000) / id3->frequency; | 93 | id3->length = ((int64_t) totalsamples * 1000) / id3->frequency; |
94 | id3->bitrate = (id3->filesize * 8) / id3->length; | 94 | id3->bitrate = (id3->filesize * 8) / id3->length; |
95 | } | 95 | } |
96 | else if (totalsamples == 0) | 96 | else if (totalsamples == 0) |
97 | { | 97 | { |
98 | id3->length = 0; | 98 | id3->length = 0; |
99 | id3->bitrate = 0; | 99 | id3->bitrate = 0; |
100 | } | 100 | } |
101 | else | 101 | else |
102 | { | 102 | { |
103 | logf("flac length invalid!"); | 103 | logf("flac length invalid!"); |
104 | return false; | 104 | return false; |
105 | } | 105 | } |
106 | 106 | ||
107 | } | 107 | } |
108 | else if (type == 4) /* 4 is the VORBIS_COMMENT block */ | 108 | else if (type == 4) /* 4 is the VORBIS_COMMENT block */ |
109 | { | 109 | { |
110 | /* The next i bytes of the file contain the VORBIS COMMENTS. */ | 110 | /* The next i bytes of the file contain the VORBIS COMMENTS. */ |
@@ -112,7 +112,7 @@ bool get_flac_metadata(int fd, struct mp3entry* id3) | |||
112 | { | 112 | { |
113 | return rc; | 113 | return rc; |
114 | } | 114 | } |
115 | } | 115 | } |
116 | #ifdef HAVE_ALBUMART | 116 | #ifdef HAVE_ALBUMART |
117 | else if (type == 6) /* 6 is the PICTURE block */ | 117 | else if (type == 6) /* 6 is the PICTURE block */ |
118 | { | 118 | { |
@@ -172,6 +172,6 @@ bool get_flac_metadata(int fd, struct mp3entry* id3) | |||
172 | } | 172 | } |
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | return true; | 176 | return true; |
177 | } | 177 | } |