Jump to content

  • Log In with Google      Sign In   
  • Create Account


LoadSound() causing unhandled exception; access violation


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 Akashi   Members   -  Reputation: 268

Like
0Likes
Like

Posted 06 April 2012 - 12:56 AM

I created a program from my book again that's pretty much syntactically identical, but I'm getting an error in regards to one of the wrappers I'm using.

I'll organize this post so this thread isn't cluttered and unattractive. I know some topics get dropped just because people don't format their code in a way that's easy to look through.

Also, I am using a 32-bit Windows 7 machine. These are my specs. I am using Microsoft Visual Studio 2010 as my IDE.

The problem:
Spoiler


Steps I took to solve it:
Spoiler


My code:
Spoiler


I hope you guys can help me with this problem! I honestly can't really advance much without solving this first.
Thanks!

Sponsor:

#2 Akashi   Members   -  Reputation: 268

Like
0Likes
Like

Posted 08 April 2012 - 01:48 PM

I hope you guys have a 48-hour rule, because I'll probably keep posting every 48 hours until I can get a suggestion as to why my program doesn't work.

#3 Madhed   Crossbones+   -  Reputation: 2492

Like
1Likes
Like

Posted 08 April 2012 - 05:38 PM

The error message gives you a big hint to what's going wrong. "Access violation reading location 0x00000000" Looks like a pointer wasn't initialized. The code pointer in the first screenshot points to line 179 in dsutil.cpp where you are comparing m_pDS to NULL. My guess is that you are calling the Create function on a null pointer. i.e You havent created a soundmanager instance yet.

#4 Akashi   Members   -  Reputation: 268

Like
0Likes
Like

Posted 08 April 2012 - 08:34 PM

How would I go about doing that? I checked and double checked, but the class constructor says it's initialized to NULL.

#5 Endurion   Crossbones+   -  Reputation: 3330

Like
1Likes
Like

Posted 08 April 2012 - 11:05 PM

Your LoadSound function code is missing in the code you posted.

What Madhed meant is that your SoundManager instance doesn't seem to have been created yet. You probably have a SoundManager pointer, but not set it to new SoundManager.

Inside the SoundManager::CreateFunction the member m_pDS is being access while "this" is NULL. Which crashes.
Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

#6 Akashi   Members   -  Reputation: 268

Like
0Likes
Like

Posted 09 April 2012 - 11:54 AM

Yes, but how do I fix that? I tried setting it to a new CSoundManager type, or a new LPDIRECTSOUND8 object, but both don't work. Further, where would I even initialize it? The m_pDS pointer was initialized to NULL in the constructor, so it does have a value to test against. If it wasn't modified on the way to the Create function, then it should return CO_E_NOTINITIALIZED. However, instead, it gives me an unhandled exception error. It is a NULL pointer, rather than an uninitialized one.

Oh wait, wow. I checked with breakpoints, and apparently, it skips completely over the constructor, which initializes my value to NULL. So there isn't a new CSoundManager. Where would I put one? I tried just brute forcing it in order to get a result, by setting m_pDS to NULL right before the if statement, but it still gave me the error.

I'm pretty new to DirectX, so please don't assume I know exactly what you're talking about lol. Please tell me what I need to do in order to fix this, and understanding will come later.

#7 Madhed   Crossbones+   -  Reputation: 2492

Like
0Likes
Like

Posted 09 April 2012 - 12:04 PM

I think you need to show us the LoadSound function

#8 Akashi   Members   -  Reputation: 268

Like
0Likes
Like

Posted 09 April 2012 - 03:20 PM

Oh, wow. I apologize, lol. I didn't know that it wasn't there, and I was getting confused signals.

Alright, here it is:

LoadSound()
Spoiler


dxaudio.cpp
Spoiler


#9 Madhed   Crossbones+   -  Reputation: 2492

Like
1Likes
Like

Posted 09 April 2012 - 03:45 PM

Well as I see it you are never calling Init_DirectSound...

#10 Akashi   Members   -  Reputation: 268

Like
0Likes
Like

Posted 09 April 2012 - 04:43 PM

Another +1 to you lol. I put it in. I skipped over where my book says to put it the first time, apparently. However, it's still giving me the same error. If it gets too convoluted then I'll probably just link both folders and ask what the significant difference is between them.

#11 Akashi   Members   -  Reputation: 268

Like
0Likes
Like

Posted 14 April 2012 - 11:14 AM

I found the problem lol. I was initializing my game that implemented the sound before I initialized my sound. So it was like I was trying to make tomato sauce without first obtaining the tomatoes I grew.

And oddly fitting analogy.

Thanks for your help, though, guys!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS