[theora] OpenAl and Vorbis

Lars Quentmeier Quentmeier at gmx.de
Thu Aug 31 08:03:05 PDT 2006


Hello! My name is Lars Quentmeier and I'm trying to write a theora-player.
Video is already showing up, but unfortunately I can't get my Vorbis-Decoder to work correctly. Could you perhaps help me? My decoding function looks like this:
int
VorbisDecoder::getAudioData(char* audiobuf, int fragsize){
	// single audio fragment audio buffering 
	bool		 audiobufReady = false;
	int size=0;
	int audiobufFill = 0;

	while(!audiobufReady){
	
		//1)try to decode some data
		while(!audiobufReady){
			float **pcm;

			//if there's pending, decoded audio, grab it 
			if((size=vorbis_synthesis_pcmout(&vorbisDspState,&pcm))>0){
				int count=audiobufFill/2;
				int maxsamples=(fragsize-audiobufFill)/vorbisInfo.channels/2;// /2
				int i;
				for(i=0; i<size && i<maxsamples; i++){
					for(int j=0;j<vorbisInfo.channels;j++){
						int val=(int) (pcm[j][i]*32767.f);
						if(val>32767) val=32767;
						if(val<-32768) val=-32768;
						audiobuf[count++]=val;
					}
				}
				vorbis_synthesis_read(&vorbisDspState,i);
				audiobufFill += i*vorbisInfo.channels*2;
				if (audiobufFill == fragsize) audiobufReady = true;        
			} else {
				// no pending audio; is there a pending packet to decode?
				if(ogg_stream_packetout(&oggStreamState,&oggPacket)>0){
					if(vorbis_synthesis(&vorbisBlock,&oggPacket)==0) // test for success! 
						vorbis_synthesis_blockin(&vorbisDspState,&vorbisBlock);
				}else{   // we need more data; break out to suck in another page 
					break;
				}
			}
		}
		
		//1)grab new data
		if(!audiobufReady){
			/* no data yet for somebody.  Grab another page */
			if(!source->requestData()) return 0;
            while(ogg_sync_pageout(&oggSyncState,&oggPage)>0)
            {
				ogg_stream_pagein(&oggStreamState, &oggPage);
            }
		}
	}
	return audiobufFill;
} 


It would be really nice if somebody could give me a hint.
Greetings Lars


-- 


"Feel free" – 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail


More information about the theora mailing list