Archived

This topic is now archived and is closed to further replies.

billybob

help with a directsound crash on IDirectSoundBuffer::Release

Recommended Posts

billybob    134
My sound class is crashing in the destructor on the IDirectSoundBuffer::Release call (it is through CComPtr, but that shouldn''t matter). the confusing part for me is that it crashes if I lock the buffer and fill it with my sound data, but if I comment that part out (just have it do nothing basically) it doesn''t crash. I was thinking I might be overrunning the end of the lock by < than a sample size due to rounding errors, but I would think that would cause a crash on IDirectSoundBuffer::Unlock. it works perfectly, plays the sound and everything until exit. any ideas? I know I''m not being particularly helpful without code, but it will be a bit of a pain in the butt to get it all together, I was hoping someone might have the answer due to experience first... I can post the code if someone wants though.

Share this post


Link to post
Share on other sites
don    431
It sounds like you have your reference counts screwed up and the object has already been destroyed by the time you attempt to call Release.

Share this post


Link to post
Share on other sites
billybob    134
well, I did something and it stops crashing. I hate it when this happens, because its going to start crashing somewhere down the road and I won''t know how to fix it then either.

Share this post


Link to post
Share on other sites
alnite    3436
Usually it happens when you Release() the DirectSound device before you Release() your buffer. Your buffer has a reference to the device it''s using. If you release the device first, it would try to access the released device, thus an access violation occurs.

Try this:

ds_device->Release();
ds_buffer->Release();

And this:

ds_buffer->Release();
ds_device->Release();

See if they cause the problem. Otherwise, I have no idea why else it crashes.

Share this post


Link to post
Share on other sites