fearnsimon
asked on
Ogg Vorbis in Directsound - Access violation when locking and unlocking buffer
I am implementing ogg support for my audio engine. I have retrieved the ogg info using vorbis_info, and everything is okay. When I got to lock (or unlock) the directsound buffer in order to read in the ogg data, I receive an access violation. I can't find any reason why the following code doesn't work.
Any help would be much appreciated.
pDS->CreateSoundBuffer( &desc, &pTemp, NULL );
DWORD size = BUFSIZE;
DWORD pos = 0;
int sec = 0;
int ret = 1;
char *buf;
char *buf2;
pTemp->Lock( 0, size, (LPVOID*)&buf, &size, NULL, NULL, DSBLOCK_ENTIREBUFFER);
// now read in the bits
while(ret && pos<size)
{
ret = ov_read(&vf, buf+pos, size-pos, 0, 2, 1, &sec);
pos += ret;
}
pTemp->Unlock( buf, size, NULL, NULL );
Any help would be much appreciated.
pDS->CreateSoundBuffer( &desc, &pTemp, NULL );
DWORD size = BUFSIZE;
DWORD pos = 0;
int sec = 0;
int ret = 1;
char *buf;
char *buf2;
pTemp->Lock( 0, size, (LPVOID*)&buf, &size, NULL, NULL, DSBLOCK_ENTIREBUFFER);
// now read in the bits
while(ret && pos<size)
{
ret = ov_read(&vf, buf+pos, size-pos, 0, 2, 1, &sec);
pos += ret;
}
pTemp->Unlock( buf, size, NULL, NULL );
Does it work with (for example) MP3 and WAV?
ASKER
I'm only trying to load .ogg files. Have a separate class for .wav. Not using mp3.
I encode the .ogg file using cool edit 2 with the ogg i/o plugin. the ov_info function reads in all the info, but when I try to lock the DS buffer for writing, - ACCESS VIOLATION -
I'm using MS Visual Studio, DX SDK 8.1 (Debug), NV OpenGL SDK, and the Ogg Vorbis SDK if thats any help.
I encode the .ogg file using cool edit 2 with the ogg i/o plugin. the ov_info function reads in all the info, but when I try to lock the DS buffer for writing, - ACCESS VIOLATION -
I'm using MS Visual Studio, DX SDK 8.1 (Debug), NV OpenGL SDK, and the Ogg Vorbis SDK if thats any help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.