]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - aac_afh.c
mp4: Introduce mp4_is_audio_track().
[paraslash.git] / aac_afh.c
index aed2153608fc56616be17a291230f6d8be4b5f4c..fdb0339c7715bf9e319c03bdf6990ecac1814313 100644 (file)
--- a/aac_afh.c
+++ b/aac_afh.c
@@ -51,24 +51,13 @@ static uint32_t aac_afh_seek_cb(void *user_data, uint64_t pos)
 
 static int32_t aac_afh_get_track(struct mp4 *mp4)
 {
-       int32_t i, rc, num_tracks = mp4_total_tracks(mp4);
+       int32_t i, num_tracks = mp4_total_tracks(mp4);
 
        assert(num_tracks >= 0);
-       for (i = 0; i < num_tracks; i++) {
-               unsigned char *buf = NULL;
-               unsigned buf_size = 0;
-
-               mp4_get_decoder_config(mp4, i, &buf, &buf_size);
-               if (buf) {
-                       mp4AudioSpecificConfig masc;
-                       rc = NeAACDecAudioSpecificConfig(buf, buf_size, &masc);
-                       free(buf);
-                       if (rc < 0)
-                               continue;
+       for (i = 0; i < num_tracks; i++)
+               if (mp4_is_audio_track(mp4, i))
                        return i;
-               }
-       }
-       return -1; /* no audio track */
+       return -E_MP4_TRACK; /* no audio track */
 }
 
 static int aac_afh_open(const void *map, size_t mapsize, void **afh_context)
@@ -87,10 +76,10 @@ static int aac_afh_open(const void *map, size_t mapsize, void **afh_context)
        c->mp4 = mp4_open_read(&c->cb);
        if (!c->mp4)
                goto free_ctx;
-       c->track = aac_afh_get_track(c->mp4);
-       ret = -E_MP4_TRACK;
-       if (c->track < 0)
+       ret = aac_afh_get_track(c->mp4);
+       if (ret < 0)
                goto close_mp4;
+       c->track = ret;
        *afh_context = c;
        return 0;
 close_mp4: