X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=aac_afh.c;h=7be441ab209b5ee7ca85c371f229f0c76ece96cb;hb=0b0434f3debae3fc5cd768f5de32f84f05e79761;hp=b6c90d59009a3315f9249e5e3b200429132d6296;hpb=3b7939a8c294dc3ee103d99e6ff00e2800cf39f3;p=paraslash.git diff --git a/aac_afh.c b/aac_afh.c index b6c90d59..7be441ab 100644 --- 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; @@ -90,7 +90,7 @@ static int aac_afh_get_chunk(uint32_t chunk_num, void *afh_context, const char **buf, uint32_t *len) { struct aac_afh_context *c = afh_context; - int32_t ss; + uint32_t ss; size_t offset; int ret; @@ -98,22 +98,22 @@ static int aac_afh_get_chunk(uint32_t chunk_num, void *afh_context, if (ret < 0) return ret; offset = c->fpos; - ss = mp4_get_sample_size(c->mp4, chunk_num); - if (ss <= 0) - return -E_MP4_BAD_SAMPLE; + ret = mp4_get_sample_size(c->mp4, chunk_num, &ss); + if (ret < 0) + return ret; assert(ss + offset <= c->mapsize); *buf = c->map + offset; *len = ss; return 1; } -static void _aac_afh_get_taginfo(const struct mp4 *mp4, struct taginfo *tags) +static void aac_afh_get_taginfo(const struct mp4 *mp4, struct taginfo *tags) { - tags->artist = mp4_meta_get_artist(mp4); - tags->title = mp4_meta_get_title(mp4); - tags->year = mp4_meta_get_date(mp4); - tags->album = mp4_meta_get_album(mp4); - tags->comment = mp4_meta_get_comment(mp4); + tags->artist = mp4_get_tag_value(mp4, "artist"); + tags->title = mp4_get_tag_value(mp4, "title"); + tags->year = mp4_get_tag_value(mp4, "date"); + tags->album = mp4_get_tag_value(mp4, "album"); + tags->comment = mp4_get_tag_value(mp4, "comment"); } /* @@ -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) @@ -162,9 +151,8 @@ static int aac_get_file_info(char *map, size_t numbytes, __a_unused int fd, if (aac_afh_get_chunk(0, c, &buf, &len) >= 0) numbytes -= buf - map; afhi->bitrate = 8 * numbytes / afhi->seconds_total / 1000; - _aac_afh_get_taginfo(c->mp4, &afhi->tags); + aac_afh_get_taginfo(c->mp4, &afhi->tags); ret = 1; -close: aac_afh_close(c); return ret; } @@ -190,7 +178,7 @@ static ssize_t aac_afh_meta_write_cb(void *user_data, void *dest, size_t count) return write(fd, dest, count); } -static uint32_t aac_afh_meta_truncate_cb(void *user_data) +static int aac_afh_meta_truncate_cb(void *user_data) { int fd = *(int *)user_data; off_t offset = lseek(fd, 0, SEEK_CUR); @@ -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; }