# Unity OpenAl + Ogg support ERROR

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

## Recommended Posts

I know that this problem was allready discussed here:
http://www.gamedev.net/community/forums/topic.asp?topic_id=198649&whichpage=1?
but i didn't really get what was actually the solution. I've tried everything written there, and nothing helped. I also dont have "vorbisfile_static.dll" and other "_static.dll" files. What should I do?

##### Share on other sites
Rule #1: disregard all of the ALut stuff.
[EDIT]
You can use it, but it's deprecated in Open AL 1.1.
[/EDIT]

Chances are your problems are related to your program crashing whenever you try to read the files, which can be solved by replacing all of the file handling functions, like this:

//the functions you'll use to replace the functions the OGG libraries broke//don't worry about them too much, just know that they worksize_t oread(void *ptr, size_t size, size_t nmemb, void *datasource){return fread(ptr,size,nmemb,(FILE*)datasource);}int oseek(void *datasource, ogg_int64_t offset, int whence){return fseek((FILE*)datasource,offset,whence);}int oclose(void *datasource){return fclose((FILE*)datasource);}long otell(void *datasource){return ftell((FILE*)datasource);}//in your code://<Open the file here, do error checking, etc.>OggVorbis_File ogg;memset(&ogg,0,sizeof(OggVorbis_File));//this might not be necessary//now instead of using this: ov_open(file,&ogg,0,0)//use this:ov_callbacks cbs;cbs.read_func = &oread;cbs.seek_func = &oseek;cbs.close_func = &oclose;cbs.tell_func = &otell;ov_open_callbacks(file,&ogg,0,0,cbs)

This should fix any problems you have, and it'll let you use the dynamic libraries, rather than the static ones.

##### Share on other sites
void cOggStream::open(string path){	int result;	if(!(oggFile=fopen(path.c_str(), "rb")))		throw string("Could Not Open File");		ov_callbacks cbs;	cbs.read_func = &oread;	cbs.seek_func = &oseek;	cbs.close_func = &oclose;	cbs.tell_func = &otell;	ov_open_callbacks(oggFile,&oggStream,0,0,cbs);		/*	if((result = ov_open(oggFile, &oggStream, NULL, 0)) < 0)	{		fclose(oggFile);		throw string("Could Not Open Stream") + ErrorString(result);	};	*/	vorbisInfo=ov_info(&oggStream, -1);	vorbisComment=ov_comment(&oggStream, -1);	if(vorbisInfo->channels==1)		format=AL_FORMAT_MONO16;	else		format=AL_FORMAT_STEREO16;	alGenBuffers(2, buffers);	check();	alGenSources(1, &source);	check();	alSource3f(source, AL_POSITION,        0.0, 0.0, 0.0);	alSource3f(source, AL_VELOCITY,        0.0, 0.0, 0.0);	alSource3f(source, AL_DIRECTION,       0.0, 0.0, 0.0);	alSourcef (source, AL_ROLLOFF_FACTOR,  0.0          );	alSourcei (source, AL_SOURCE_RELATIVE, AL_TRUE      );};

##### Share on other sites
In my code, ov_info() works fine, but as for ov_comment(), I don't know, since I haven't had a use for it. I'm pretty sure it's just the file handling functions that are broken, so it should work.

##### Share on other sites
Ok, the problem isn't in "ov_info" and "ov_comment". Now it crashes on alGenBuffers and alGenSources. I just dont get it. alGenBuffers and alGenSources work just fine in my other class that covers my sound system.

##### Share on other sites
For example, if i comment out everything starting with glGenBuffers in the code posted earlier, my program starts without any errors. Where could be the problem?

##### Share on other sites
Oh. I found my mistakes. Thanks a lot for the help. Now it's working fine. Thanks again.

##### Share on other sites
So what was the problem?

1. 1
Rutin
36
2. 2
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633345
• Total Posts
3011441
• ### Who's Online (See full list)

There are no registered users currently online

×