- char *taginfo;
-
- vorbis_info_init(&vi);
- vorbis_comment_init(&vc);
-
- ret = -E_SYNC_PAGEOUT;
- if (ogg_sync_pageout(oss, &page) != 1)
- goto out;
-
- ret = ogg_page_serialno(&page);
- ogg_stream_init(&stream, ret);
-
- ret = -E_STREAM_PAGEIN;
- if (ogg_stream_pagein(&stream, &page) < 0)
- goto out;
-
- 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;
- ret = 1;
-out:
- vorbis_info_clear(&vi);
- vorbis_comment_clear(&vc);
- ogg_stream_clear(&stream);
+ struct private_vorbis_data pvd;
+ struct ogg_afh_callback_info vorbis_callback_info = {
+ .packet_callback = vorbis_packet_callback,
+ .private_data = &pvd,
+ };
+
+ vorbis_info_init(&pvd.vi);
+ vorbis_comment_init(&pvd.vc);
+ ret = ogg_get_file_info(map, numbytes, afhi, &vorbis_callback_info);
+ vorbis_info_clear(&pvd.vi);
+ vorbis_comment_clear(&pvd.vc);