+static int vorbis_get_header_callback(ogg_packet *packet, int packet_num,
+ int serial, __a_unused struct afh_info *afhi, void *private_data)
+{
+ int ret;
+ struct vorbis_get_header_data *vghd = private_data;
+ ogg_page og;
+ static unsigned char dummy_packet[] = {
+ 0x03,
+ 'v', 'o', 'r', 'b', 'i', 's',
+ 0x06, 0x00, 0x00, 0x00,
+ 'd', 'u', 'm', 'm', 'y', '\0',
+ 0x00, 0x00, 0x00, 0x00, /* no comment :) */
+ 0xff /* framing bit */
+ };
+
+ PARA_DEBUG_LOG("processing ogg packet #%d\n", packet_num);
+ if (packet_num > 2)
+ return 0;
+ if (packet_num == 0) {
+ ogg_stream_init(&vghd->os, serial);
+ ret = ogg_stream_packetin(&vghd->os, packet);
+ if (ret < 0)
+ goto out;
+ ret = -E_OGG_STREAM_FLUSH;
+ if (ogg_stream_flush(&vghd->os, &og) == 0)
+ goto out;
+ add_ogg_page(&og, vghd);
+ return 1;
+ }
+ if (packet_num == 1) {
+ ogg_packet replacement = *packet;
+ PARA_INFO_LOG("replacing metadata packet\n");
+ replacement.packet = dummy_packet;
+ replacement.bytes = sizeof(dummy_packet);
+ ret = ogg_stream_packetin(&vghd->os, &replacement);
+ if (ret >= 0)
+ return 1;
+ ret = -E_OGG_PACKET_IN;