Solved

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

Posted on 2003-12-03
5
700 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ckserve 7 200
Python TKinter installation needs version advice 1 345
Creating an Android APP / Iphone APP for a beginner having a windows machine 1 366
factorial example challenge 10 142
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

710 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