]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - aac_afh.c
mp4: Rename mp4_open_read() to mp4_open().
[paraslash.git] / aac_afh.c
index de99613d2df6adfa506940d454b61e1b893b7c73..7be441ab209b5ee7ca85c371f229f0c76ece96cb 100644 (file)
--- a/aac_afh.c
+++ b/aac_afh.c
@@ -68,7 +68,7 @@ static int aac_afh_open(const void *map, size_t mapsize, void **afh_context)
        c->cb.seek = aac_afh_seek_cb;
        c->cb.user_data = c;
 
-       ret = mp4_open_read(&c->cb, &c->mp4);
+       ret = mp4_open(&c->cb, &c->mp4);
        if (ret < 0)
                goto free_ctx;
        *afh_context = c;
@@ -123,7 +123,6 @@ static int aac_get_file_info(char *map, size_t numbytes, __a_unused int fd,
                struct afh_info *afhi)
 {
        int ret;
-       int32_t rv;
        struct aac_afh_context *c;
        uint64_t milliseconds;
        const char *buf;
@@ -133,23 +132,13 @@ static int aac_get_file_info(char *map, size_t numbytes, __a_unused int fd,
        if (ret < 0)
                return ret;
 
-       ret = -E_MP4_BAD_SAMPLERATE;
-       rv = mp4_get_sample_rate(c->mp4);
-       if (rv <= 0)
-               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;
-
-       ret = -E_MP4_BAD_SAMPLE_COUNT;
-       rv = mp4_num_samples(c->mp4);
-       if (rv <= 0)
-               goto close;
-       afhi->chunks_total = rv;
+       afhi->frequency = mp4_get_sample_rate(c->mp4);
+       assert(afhi->frequency > 0);
+       afhi->channels = mp4_get_channel_count(c->mp4);
+       assert(afhi->channels > 0);
+       afhi->chunks_total = mp4_num_samples(c->mp4);
+       assert(afhi->chunks_total > 0);
+
        afhi->max_chunk_size = 0;
        for (n = 0; n < afhi->chunks_total; n++) {
                if (aac_afh_get_chunk(n, c, &buf, &len) < 0)
@@ -164,7 +153,6 @@ static int aac_get_file_info(char *map, size_t numbytes, __a_unused int fd,
        afhi->bitrate = 8 * numbytes / afhi->seconds_total / 1000;
        aac_afh_get_taginfo(c->mp4, &afhi->tags);
        ret = 1;
-close:
        aac_afh_close(c);
        return ret;
 }
@@ -249,7 +237,7 @@ static int aac_afh_rewrite_tags(const char *map, size_t mapsize,
        replace_or_add_tag("album", tags->album, metadata);
        replace_or_add_tag("date", tags->year, metadata);
        replace_or_add_tag("comment", tags->comment, metadata);
-       ret = mp4_meta_update(mp4);
+       ret = mp4_update_meta(mp4);
        mp4_close(mp4);
        return ret;
 }