Jump to content
  • Advertisement

Archived

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

billybob

ogg vorbis ov_open isn't working

This topic is 5655 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

the problem is it doesn''t even return an error, just an access violation on the ov_open line. what am i doing wrong?
    OggVorbis_File VorbisFile;

    FILE * oggfile = NULL;

    oggfile = fopen("a.ogg", "r");
    if (!oggfile) 
        return false;
	
    int result = ov_open(oggfile, &VorbisFile, NULL, 0);

	if(result == OV_EREAD)
	{
		MessageBox(NULL, "OV_READ", NULL, NULL);
	}
	if(result == OV_ENOTVORBIS)
	{
		MessageBox(NULL, "OV_ENOTVORBIS", NULL, NULL);
	}
	if(result == OV_EVERSION)
	{
		MessageBox(NULL, "OV_EVERSION", NULL, NULL);
	}
	if(result == OV_EBADHEADER)
	{
		MessageBox(NULL, "OV_EBADHEADER", NULL, NULL);
	}
	if(result == OV_EFAULT)
	{
		MessageBox(NULL, "OV_EFAULT", NULL, NULL);
	}
 

Share this post


Link to post
Share on other sites
Advertisement
I really don''t know but try opening the file in binary format.
oggfile = fopen("a.ogg", "rb");

Update GameDev.net system time campaign: ''date ddmmHHMMYYYY''

Share this post


Link to post
Share on other sites
What OS? Most of the problems I''ve seen people have with vorbis file are Windows related, so I''ll assume that.

You must link to the same C runtime as the ogg, vorbis, and vorbis file libraries (the DLL''s are most likely built with the MSVC multithreaded runtime, and MSVC itself links with the single threaded runtimes by default). Statically linking avoids this, but isn''t as nice.

Also, like Dalleboy said, you must open it in binary mode.

Share this post


Link to post
Share on other sites
i linked by putting ogg_static.lib vorbis_static.lib vorbisfile.lib in project-settings-link.

i put it in binary, "rb", and it still doesn''t work. same deal.

i''m on windows XP

Share this post


Link to post
Share on other sites
I''ve had to deal with the very same problem as you do. Fortunately though, I have the solution for you

I suppose you are using Microsoft Visual C++ (if not, try to find similar options in your compiler options). You always need to use the same CRT library as the DLLs you''re linking to, otherwise you''ll get access violations like you did. In other words, the Ogg Vorbis DLLs were compiled with the Multithreaded DLL CRT library. However, all new projects in VC++ have the Singlethreaded CRT library setup by default, thus causing the problems you''re experiencing.

To fix this, go in the "Project\Settings" menu, on the "C/C++" tab, select the "Code Generation" category, and on the "Use run-time library" option, select "Multithreaded DLL". Compile and run, this should be working now. Please note that this is for the release configuration of your project, using the release OGG DLLs.

So you should be aware that you also need to match the debug version of your program with the debug OGG DLLs, and the debug CRT library. So for the debug configuration of your project, you need to use the OGG debug DLLs (the libs suffixed by a _d), and the "Multithreaded Debug DLL" CRT library.

There might be a few things I missed, but this is guaranteed to work.

Good luck!
- Veldhar Windrider

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!