Solved

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Trigonometry for game star field help 1 119
Fix45 challenge 15 122
scoresClump  challenge 31 137
Need a nodal sequencing tool 3 92
Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

816 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

11 Experts available now in Live!

Get 1:1 Help Now