Jump to content
  • Advertisement
Sign in to follow this  
Devil_Inside

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.

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

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 this post


Link to post
Share on other sites
Advertisement
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 work
size_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 this post


Link to post
Share on other sites
Ok, thanks, that worked. But, what about ov_info, ov_comment..... The loader uses them to continue loading the file.

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!