/* converts ogg frames into audioFrames Copyright (C) 2001 Martin Vogt This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation. For more information look at the file COPYRIGHT in this package */ #include "vorbisDecoder.h" #ifdef OGG_VORBIS #define _VORBIS_NEED_SYNTHHEADER_1 1 #define _VORBIS_NEED_SYNTHHEADER_2 2 #define _VORBIS_NEED_SYNTHHEADER_3 3 #define _VORBIS_DECODE_SETUP 4 #define _VORBIS_DECODE_LOOP 5 #include using namespace std; VorbisDecoder::VorbisDecoder() { vorbis_info_init(&vi); vorbis_comment_init(&vc); reset(); } VorbisDecoder::~VorbisDecoder() { } int VorbisDecoder::hasHeader() { return (initState>=_VORBIS_DECODE_LOOP); } int VorbisDecoder::decode(RawFrame* rawFrame,AudioFrame* dest) { if ((rawFrame == NULL) || (dest == NULL)) { cout << "VorbisDecoder::decode NULL pointer!"<getFrameType() != _FRAME_RAW_OGG) { cout << "VorbisDecoder::decode not _FRAME_RAW_OGG"<getData(); switch(initState) { case _VORBIS_NEED_SYNTHHEADER_1: case _VORBIS_NEED_SYNTHHEADER_2: case _VORBIS_NEED_SYNTHHEADER_3: cout << "_VORBIS_NEED_SYNTHHEADER:"< 0) { int maxSamples=dest->getSize(); if (samples > maxSamples) { cout << "more samples in vorbis than we can store"<clearrawdata(); dest->setFrameFormat(vi.channels-1,vi.rate); if (vi.channels == 2) { dest->putFloatData(pcm[0],pcm[1],samples); } else { dest->putFloatData(pcm[0],NULL,samples); } vorbis_synthesis_read(&vd,samples); /* tell libvorbis how many samples we actually consumed */ return true; } return false; } default: cout << "unknown state in vorbis decoder"<