]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
mp4: Remove E_MP4_BAD_CHANNEL_COUNT.
authorAndre Noll <maan@tuebingen.mpg.de>
Fri, 27 Aug 2021 14:07:24 +0000 (16:07 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 6 Jun 2022 18:46:37 +0000 (20:46 +0200)
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.

aac_afh.c
error.h
mp4.c
mp4.h

index de99613d2df6adfa506940d454b61e1b893b7c73..0f7f3fa925d24e6e4a39b80aac1aa78ec4cc89a1 100644 (file)
--- 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 a4fe78a5c2878f8ba9ba8c71abfcf5171f7f2636..40081b6b3551712f051ed3ecc4d1ca40ebf2d4f8 100644 (file)
--- a/error.h
+++ b/error.h
        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 205286a24de7498717a6a5ee4c7d0ed3f71577d3..18f43925aef377ae620643a886df8502988fa509 100644 (file)
--- 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 15cc6af9e31d74c88a075703fd8c32683e59e2d1..5a07fadc0278719c422eb15b46e59c5eeb05fb36 100644 (file)
--- 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);