From 72c89788b2a4e34e6c0e0893c34d418d55c6f7a3 Mon Sep 17 00:00:00 2001 From: shatty Date: Mon, 8 Nov 2004 05:17:37 +0000 Subject: [PATCH] add compatibility chunk interpretation for extractors not providing OGG_PACKET_DATA_TYPE git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9839 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../plugins/vorbis/vorbisCodecPlugin.cpp | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/add-ons/media/plugins/vorbis/vorbisCodecPlugin.cpp b/src/add-ons/media/plugins/vorbis/vorbisCodecPlugin.cpp index fac94834a7..2cc2565d21 100644 --- a/src/add-ons/media/plugins/vorbis/vorbisCodecPlugin.cpp +++ b/src/add-ons/media/plugins/vorbis/vorbisCodecPlugin.cpp @@ -189,9 +189,19 @@ VorbisDecoder::Decode(void *buffer, int64 *frameCount, TRACE("VorbisDecoder::Decode: GetNextChunk failed\n"); return status; } - if (mh.user_data_type != OGG_PACKET_DATA_TYPE) { - TRACE("VorbisDecoder::Decode: chunk missing ogg_packet data"); - return B_ERROR; + ogg_packet packet; + if (mh.user_data_type == OGG_PACKET_DATA_TYPE) { + memcpy(&packet, mh.user_data, sizeof(packet)); + } else { + // According to http://lists.xiph.org/pipermail/theora-dev/2004-May/002161.html + // this is invalid, but results from it are tolerable and better than nothing. + TRACE("VorbisDecoder::Decode: using compatibility chunk interpretation\n"); + packet.b_o_s = 0; + packet.e_o_s = 0; + packet.granulepos = -1; + packet.packetno = 7; + packet.packet = static_cast(chunkBuffer); + packet.bytes = chunkSize; } if (!synced) { if (mh.start_time > 0) { @@ -199,9 +209,7 @@ VorbisDecoder::Decode(void *buffer, int64 *frameCount, synced = true; } } - ogg_packet * packet = reinterpret_cast(mh.user_data); - packet->packet = static_cast(chunkBuffer); - if (vorbis_synthesis(&fBlock, packet)==0) { + if (vorbis_synthesis(&fBlock, &packet)==0) { vorbis_synthesis_blockin(&fDspState,&fBlock); } }