- afi->header_len = 0;
- while (ogg_stream_flush(stream_out, &page))
- afi->header_len += page.body_len + page.header_len;
- PARA_INFO_LOG("header_len = %d\n", afi->header_len);
- afi->header_offset = 0;
+ ret = -E_STREAM_PACKETOUT;
+ if (ogg_stream_packetout(&stream, &packet) != 1)
+ goto out;
+
+ ret = -E_VORBIS;
+ if (vorbis_synthesis_headerin(&vi, &vc, &packet) < 0)
+ goto out;
+ if (vi.rate == 0)
+ goto out;
+ afhi->channels = vi.channels;
+ afhi->frequency = vi.rate;
+ afhi->bitrate = vi.bitrate_nominal / 1000;
+ PARA_DEBUG_LOG("channels: %i, sampling rate: %i, bitrate: %i\n",
+ afhi->channels, afhi->frequency, afhi->bitrate);
+ ret = read_vorbis_comment(oss, &stream, &vi, &vc);
+ if (ret < 0)
+ goto out;
+ taginfo = make_taginfo(
+ vorbis_comment_query(&vc, "title", 0),
+ vorbis_comment_query(&vc, "artist", 0),
+ vorbis_comment_query(&vc, "album", 0),
+ vorbis_comment_query(&vc, "year", 0),
+ vorbis_comment_query(&vc, "comment", 0)
+ );
+ PARA_DEBUG_LOG("tag info: %s\n", taginfo);
+ afhi->info_string = make_message("%s:\n%s",
+ status_item_list[SI_AUDIO_FILE_INFO], taginfo);
+ free(taginfo);
+
+ afhi->header_offset = 0;
+ afhi->header_len = oss->returned;