OggVorbis ov_open() Throws Access Violation Exception

1

I'm trying to open an OggVorbis file using the Vorbis SDK/DLLs. ov_open() throws an Access Violation exception 0x00000014. I have checked the file exists: I've opened it with fopen and printed the contents to the console just to check - all went fine!

Might not make a difference, but the DLLs have been compiled as DEBUG Win32, and my project is compiling under the same configuration.

I'm using an absolute path to the file, for reassurance, and the file does exist. As stated before, I can open and read it myself.

The *.ogg file was rendered using FL Studio at 192kbps, and it also opens and plays fine in Adobe Audition and VLC Media Player.

This is the code I have to open the file and send it to the Vorbis library (the code came from this tutorial):

FILE* oggFile;
const char* path = "C:\\absolute\\path\\to\\file.ogg";
const char* openMode = "rb";
int result;

if (!(oggFile = fopen(path, openMode)))
{
    throw std::string("Could not open file.");
}

if ((result = ov_open(oggFile, &oggStream, NULL, 0)) < 0)
{
    // Never gets here
    fclose(oggFile);
    throw std::string("Could not open Ogg stream: ");
}

The "Vorbis" code where the exception is thrown:

// vorbisfile.c: line #827

static int _fseek64_wrap(FILE *f,ogg_int64_t off,int whence) {
    if(f==NULL)return(-1);
    return fseek(f,off,whence); // Exception thrown here
}

At this point, off == 0 and whence == 1.

I do see the method name contains "64". Could this be wanting to read a 64bit encoded file? Or is it trying to run as 64bit when it's actually compiled as 32bit? Or is this not the issue at all? :P

Also, as I followed the tutorial I noticed there were a couple of mistakes in the code that I had to correct. So I'm wondering if the tutorial is "complete" enough, ie: perhaps there is some variable I should #define, or something else that's possibly missing prior to sending the opened file to ov_open in order for it to be handled accordingly.

Tech Specs:

  • Windows 10
  • Visual Studio Express 2013
  • _MSC_VER 1800
  • libogg.dll v1.3.2 (current)
  • libvorbis.dll v1.3.5 (current)

NOTE: The downloaded Vorbis source code only contained Solution and Project files up to VS2010. I opened the VS2010 Solutions in Visual Studio Express 2013 to compile them in order to attain compatibility with my project. I'm also wondering if this might lead to some issues.

c++
windows
fseek
oggvorbis
asked on Stack Overflow Sep 9, 2016 by Aaron • edited Sep 10, 2016 by Aaron

1 Answer

1

The OggVorbis documentation recommends not using ov_open on windows (https://xiph.org/vorbis/doc/vorbisfile/ov_open.html).

Use ov_open_callbacks instead.

Something like this should work:

ov_open_callbacks(oggFile, &oggStream, NULL, 0, OV_CALLBACKS_DEFAULT);
answered on Stack Overflow Sep 9, 2016 by John Franklin

User contributions licensed under CC BY-SA 3.0