Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Ogg Vorbis Problem

This topic is 5332 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I can''t seem to get this to work, I can open and read from the Ogg Vorbis file, but can''t stream the data to OpenAL properly. (OpenAL has been initialized somewhere else, and wavs play properly) #define NUM_MP3_BUFFERS 2 size_t pooread(void *buf,unsigned int a,unsigned int b,void * fp) { return fread(buf,a,b,(FILE *)fp); } int pooclose(void * fp) { return fclose((FILE *)fp); } int pooseek(void *fp,__int64 a,int b) { return fseek((FILE *)fp,(long)a,b); } long pootell(void *fp) { return ftell((FILE *)fp); } void COggPlayer:lay() { OggVorbis_File vf; FILE * fi = fopen("plum3.ogg","rb"); ov_callbacks ovcb; ovcb.read_func = pooread; ovcb.close_func = pooclose; ovcb.seek_func = pooseek; ovcb.tell_func = pootell; if( ov_open_callbacks(fi,&vf,NULL,0,ovcb) < 0 ) { TRACE("Input does not appear to be an Ogg bitstream.\n"); return; } //info vorbis_comment * vcomment = ov_comment(&vf,-1); TRACE("Vendor: %s\n",vcomment->vendor); for(int i=0;icomments;i++) { TRACE("Comment: %s\n",vcomment->user_comments); } vorbis_info * vinfo = ov_info(&vf,-1); TRACE("Bitsream is %d channel, %dHz\n",vinfo->channels,vinfo->rate); TRACE("Decoded length: %d\n",ov_pcm_total(&vf,-1)); char pcmout[8192]; ALuint buffer[NUM_MP3_BUFFERS]; ALuint source; int ind = 0; alGenBuffers(NUM_MP3_BUFFERS,buffer); alGenSources(1,&source); ALfloat pos[] = {0,0,-1,0,0,0}; alSourcef(source,AL_PITCH,1.f); alSourcef(source,AL_GAIN,1.f); alSourcefv(source,AL_POSITION,pos); alSourcefv(source,AL_VELOCITY,pos); alSourcei(source,AL_LOOPING,AL_FALSE); ALint processed; bool bPlayed = false; while(1) { alGetSourcei(source,AL_BUFFERS_PROCESSED,&processed); if( processed>0 || !bPlayed ) { TRACE("Processed: %d\n",processed); int bs=0; long ret=ov_read(&vf,pcmout,sizeof(pcmout),0,2,1,&bs); if( ret <= 0 || bs != 0 ) { break; } TRACE("read %d\n",ret); alBufferData(buffer[ind],AL_FORMAT_STEREO16,pcmout,ret,vinfo->rate); alSourceQueueBuffers(source,1,&buffer[ind]); ind=(ind+1)%NUM_MP3_BUFFERS; TRACE("upped\n"); if( !bPlayed ) { alSourcePlay(source); bPlayed = true; } } } ov_clear(&vf); }

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
I had the exact same problem. You are probably linking these files:


You need to link these files:


The bad news is that this doesn''t work either. When you try to run it it gives you a bunch of error messages such as _free already defined. Can anyone tell me how to go around this stupid error?

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!