Solved

Ogg Vorbis in Directsound - Access violation when locking and unlocking buffer

Posted on 2003-12-03
5
693 Views
Last Modified: 2007-12-19
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 );

0
Comment
Question by:fearnsimon
  • 2
5 Comments
 
LVL 4

Expert Comment

by:void_main
ID: 9867095
Does it work with (for example) MP3 and WAV?
0
 

Author Comment

by:fearnsimon
ID: 9867845
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.
0
 
LVL 4

Accepted Solution

by:
void_main earned 500 total points
ID: 9872708
I am not a DirectX programmer (I am using BASS.DLL, which can play OGG, MP3, MP2.....) but I think you don't have any RAM allocated. Since I don't know how LOCK works exactly I suggest this:

in your code
//------------------------
 char    *buf;
 char    *buf2;

 pTemp->Lock( 0, size, (LPVOID*)&buf, &size, NULL, NULL, DSBLOCK_ENTIREBUFFER);
//------------------------
Lock tries to lock the buffer "buf" (or is this wrong), and when you create some variables local you have a -not defined-
value stored in them. My suggestions are
1st: I would set buf1 and buf2 to zero before use them.
2nd: If the 1st suggestion does not work you may add the next line between "char *buf2;"     and    "pTemp->Lock ....."
buf = new char[size];

I also can see that buf2 is never used (but I think you did not post your whole code.)

I hope that helped you, or gave an idea.

regards
void_main
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now