- af = p;
- af->reposition_stream = aac_reposition_stream;
- af->get_file_info = aac_get_file_info,
- af->read_chunk = aac_read_chunk;
- af->close_audio_file = aac_close_audio_file;
- af->get_header_info = NULL;
- af->suffixes = aac_suffixes;
+ int ret;
+ struct mp4_metadata *metadata;
+ struct mp4 *mp4;
+ struct mp4_callback cb = {
+ .read = aac_afh_meta_read_cb,
+ .seek = aac_afh_meta_seek_cb,
+ .write = aac_afh_meta_write_cb,
+ .truncate = aac_afh_meta_truncate_cb,
+ .user_data = &fd
+ };
+
+ ret = write_all(fd, map, mapsize);
+ if (ret < 0)
+ return ret;
+ lseek(fd, 0, SEEK_SET);
+
+ ret = mp4_open_meta(&cb, &mp4);
+ if (ret < 0)
+ return ret;
+ metadata = mp4_get_meta(mp4);
+ PARA_NOTICE_LOG("%u metadata item(s) found\n", metadata->count);
+ replace_or_add_tag("artist", tags->artist, metadata);
+ replace_or_add_tag("title", tags->title, metadata);
+ 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);
+ mp4_close(mp4);
+ return ret;