From: Andre Noll Date: Fri, 27 Aug 2021 14:07:24 +0000 (+0200) Subject: mp4: Remove E_MP4_BAD_CHANNEL_COUNT. X-Git-Tag: v0.7.1~7^2~13 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=84c7e6c683280d39a41155cc402f0ff2eafc7a0a;p=paraslash.git mp4: Remove E_MP4_BAD_CHANNEL_COUNT. If the mp4 file does not contain an m4a atom, the channel count stays at zero and open_file() returns -E_MP4_TRACK in this case. So the check in aac_afh.c for a non-positive return value from mp4_get_channel_count() can never trigger. Replace the check by an assertion and remove the error code. Also, let mp4_get_channel_count() return uint16_t as the number of channels is stored as an unsigned 16 bit number in the mp4 file. --- diff --git a/aac_afh.c b/aac_afh.c index de99613d..0f7f3fa9 100644 --- a/aac_afh.c +++ b/aac_afh.c @@ -139,11 +139,8 @@ static int aac_get_file_info(char *map, size_t numbytes, __a_unused int fd, goto close; afhi->frequency = rv; - ret = -E_MP4_BAD_CHANNEL_COUNT; - rv = mp4_get_channel_count(c->mp4); - if (rv <= 0) - goto close; - afhi->channels = rv; + afhi->channels = mp4_get_channel_count(c->mp4); + assert(afhi->channels > 0); ret = -E_MP4_BAD_SAMPLE_COUNT; rv = mp4_num_samples(c->mp4); diff --git a/error.h b/error.h index a4fe78a5..40081b6b 100644 --- a/error.h +++ b/error.h @@ -139,7 +139,6 @@ PARA_ERROR(MP3_INFO, "could not read mp3 info"), \ PARA_ERROR(MP4_READ, "mp4: read error or unexpected end of file"), \ PARA_ERROR(MP4_CORRUPT, "invalid/corrupt mp4 file"), \ - PARA_ERROR(MP4_BAD_CHANNEL_COUNT, "mp4: invalid number of channels"), \ PARA_ERROR(MP4_BAD_SAMPLE, "mp4: invalid sample number"), \ PARA_ERROR(MP4_BAD_SAMPLERATE, "mp4: invalid sample rate"), \ PARA_ERROR(MP4_BAD_SAMPLE_COUNT, "mp4: invalid number of samples"), \ diff --git a/mp4.c b/mp4.c index 205286a2..18f43925 100644 --- a/mp4.c +++ b/mp4.c @@ -698,7 +698,7 @@ uint32_t mp4_get_sample_rate(const struct mp4 *f) return f->track.sample_rate; } -uint32_t mp4_get_channel_count(const struct mp4 *f) +uint16_t mp4_get_channel_count(const struct mp4 *f) { return f->track.channel_count; } diff --git a/mp4.h b/mp4.h index 15cc6af9..5a07fadc 100644 --- a/mp4.h +++ b/mp4.h @@ -24,7 +24,7 @@ int mp4_open_read(const struct mp4_callback *cb, struct mp4 **result); void mp4_close(struct mp4 *f); int mp4_get_sample_size(const struct mp4 *f, uint32_t sample, uint32_t *result); uint32_t mp4_get_sample_rate(const struct mp4 *f); -uint32_t mp4_get_channel_count(const struct mp4 * f); +uint16_t mp4_get_channel_count(const struct mp4 *f); int32_t mp4_num_samples(const struct mp4 *f); uint64_t mp4_get_duration(const struct mp4 *f); int mp4_open_meta(const struct mp4_callback *cb, struct mp4 **result);