Solved

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

Posted on 2003-12-03
5
694 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

939 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

6 Experts available now in Live!

Get 1:1 Help Now