SFML community forums

Help => Audio => Topic started by: 93interactive on September 08, 2009, 09:22:49 am

Title: crash with audio on vista/visual studio 2008
Post by: 93interactive on September 08, 2009, 09:22:49 am
Hello,

i have tried to start playing audio samples in my game, but it crashes the application under vista / visual studio 2008 and svn branch of sfml 2.0

i have stripped everything down as much as possible, so i now have a soundfile class, that looks like this:

Code: [Select]

class SoundFile {
private:
sf::SoundBuffer buffer;

public:
sf::Sound sound;

SoundFile() {}

bool Load(const char *name);
};


i do not even have to used it, just the fact to do something like this:

Code: [Select]

class MyApp {
private:
SoundFile sound;
};


does crash the application with the following messagte:

Code: [Select]

First-chance exception at 0x76fb2f3d in MyApp.exe: 0xC0000005: Access violation reading location 0x00000044.
Windows has triggered a breakpoint in MyApp.exe.

This may be due to a corruption of the heap, which indicates a bug in MyApp.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while MyApp.exe has focus.


i have installed newest openal and libsndfile and copied it to the binary folder.

any ideas?
Title: crash with audio on vista/visual studio 2008
Post by: Laurent on September 08, 2009, 09:30:31 am
Are you mixing debug and release configurations?

Do you use the OpenAL and libsdnfile DLLs provided in the SFML SDK?

Does this code work with SFML 1.5 or the SVN trunk?
Title: crash with audio on vista/visual studio 2008
Post by: 93interactive on September 08, 2009, 10:16:11 am
Quote from: "Laurent"
Are you mixing debug and release configurations?


i dont know where to get debug versions of openal and libsndfile, so i am currently working only in release configuration.

Quote

Do you use the OpenAL and libsdnfile DLLs provided in the SFML SDK?


tried both, versions provided by sfml and the newest from original homepages

Quote
Does this code work with SFML 1.5 or the SVN trunk?


yes, both work fine, unfortunately i need 2.0 features.
Title: crash with audio on vista/visual studio 2008
Post by: Laurent on September 08, 2009, 10:26:58 am
Quote
i dont know where to get debug versions of openal and libsndfile, so i am currently working only in release configuration.

I'm just talking about SFML libraries. It makes no difference for openal and libsndfile because they are C libraries.

Quote
tried both, versions provided by sfml and the newest from original homepages

You have to use the DLLs in sfml2\extlibs (especially libsndfile which is a new version). Make sure that you don't have other versions in your systems folder (or any folder which is in the PATH).
Title: crash with audio on vista/visual studio 2008
Post by: 93interactive on September 08, 2009, 11:31:47 am
using the libs from sfml2\extlibs it still crashes. i can see in the logfile, that it loads the right libraries. one thing that makes me a bit suspicious ist, that i run a 64 bit vista, and it loads a lot of dll's from the 64 bit system directory, including for example dsound.dll

i am not a experienced windows user, but at least under linux mixing 32 bit with 64 bit is a very bad idea, could this be the problem? and if so, is there a way around?
Title: crash with audio on vista/visual studio 2008
Post by: Laurent on September 08, 2009, 11:43:21 am
I don't know. But if it works with other versions of SFML, then it may not be a problem.

The only way to get more informations about the crash would be to recompile OpenAL Soft in debug and run a debugger.
Title: crash with audio on vista/visual studio 2008
Post by: 93interactive on September 08, 2009, 06:26:48 pm
well i tried for several hours now, but it seems that you need the commercial visual c++ to compile openal

if someone out there could send me a debug version of openal i could give it a try

it seems btw, that it breaks down on initializing the device
Title: crash with audio on vista/visual studio 2008
Post by: Laurent on September 08, 2009, 08:43:26 pm
Quote
well i tried for several hours now, but it seems that you need the commercial visual c++ to compile openal

Why do you say so? The commercial version of VC++ only brings MFC and a profiler.
Title: crash with audio on vista/visual studio 2008
Post by: 93interactive on September 09, 2009, 05:21:16 am
yes, and openal wants to include atlconv.h and afxres.h which seems to be part of MFC.

but as told i am a windows noob, so maybe i am just missing something.

anyway, am i the only one experiencing a crash as soon as audio comes into play on the 2.0 branch?
Title: crash with audio on vista/visual studio 2008
Post by: Laurent on September 09, 2009, 08:46:57 am
Quote
yes, and openal wants to include atlconv.h and afxres.h which seems to be part of MFC.

Weird. What if you build it with MinGW?

Quote
anyway, am i the only one experiencing a crash as soon as audio comes into play on the 2.0 branch?

So far, yes.
Have you tried to find the exact revision at which the problem appeared?
Title: the same problem
Post by: sfPaul on September 17, 2009, 04:42:50 pm
hello laurent!
i've the same problem! i can compile my program but i cannot start it. i use sfml2 of the svn repository and msvc 2008. my operating system is windows vista.
i hope you can help us with our problem!
thank you in advance!
paul
Title: crash with audio on vista/visual studio 2008
Post by: Wolfram on September 17, 2009, 05:00:21 pm
Hello,
I've got a similar problem.
If I make a projekt with sounds it freezes or doesn't do anything!
No window, no sounds,..., just nothing.
I tried several examples/ projects, but I've got the same problem.
I use Windows 7, MSVC2008-Express and SFML2 branch from SVN.
I tried the debug and the release SFML-dlls with debug/release compilation. (no errors, no warnings)
I use the libsndfile-1.dll and the openal32.dll from extlibs/bin.
With SFML 1.5 I've got no problems, only with SFML2 from the branch.

Wolfram
Title: crash with audio on vista/visual studio 2008
Post by: Nexus on September 17, 2009, 09:12:28 pm
Wolfram, did you check the output of std::cerr (normally the console)? Isn't there any error message?

You can also try to debug your application in order to find the point where it freezes.
Title: crash with audio on vista/visual studio 2008
Post by: Wolfram on September 18, 2009, 12:22:38 pm
Quote
Wolfram, did you check the output of std::cerr (normally the console)? Isn't there any error message?

Some applications starts, but the console window/sfml window/... doesn't appear!
The application doesn't do anything.
In the task manager i can see that the application runs, but that's all :(

Quote
You can also try to debug your application in order to find the point where it freezes.

I'm not very experienced in using the debugger.
But the debugger doesn't stop running, and i can't see any errors. :(
The application runs, but it doesn't do anything! (no console window, no sfml-window)
This problems I've got only with SFML2 branch from SVN.

EDIT:
I found out, that my applications runs when I link the static sfml-libs.
But if I use the dynamic ones, it doesn't work.
I don't understand it^^
Title: crash with audio on vista/visual studio 2008
Post by: Nexus on September 18, 2009, 03:17:09 pm
Did you link the SFML and CRT (c-runtime) libraries correctly?

You should get used to the debugger because it is a very powerful tool. A good debugger can save you hours of desperation. The one of MSVC++ lets you see the runtime state of your application, read the variable's values, step statement by statement throught the code, set up conditional breakpoints, and a lot more.

Compile your project in debug mode. Place breakpoints early in your code (at the beginning of main() or even earlier, if you use static/global objects which are initialized before main()) by clicking left to the code line - a red sphere will appear. Then press "start debugging" (the green triangle) and check whether your breakpoint is reached. You can experiment a while, maybe you can use console outputs additionally.
Title: crash with audio on vista/visual studio 2008
Post by: Wolfram on September 21, 2009, 03:00:05 pm
Code: [Select]
Did you link the SFML and CRT (c-runtime) libraries correctly?
I think that I linked all correctly.
Other packages of SFML works perfectly, only the dynamic audio library don't work :(

Code: [Select]
You should get used to the debugger...
I will learn to use the debugger ;) :)
Title: crash with audio on vista/visual studio 2008
Post by: Nexus on September 21, 2009, 03:30:31 pm
Hm... Another idea: Don't download the OpenAL32 runtime, especially not from CreativeLabs. Use the libraries delivered by SFML.
(edited afterwards ;))

I can remember a case where my app froze, too, after a while. It turned out to be a bad DLL version.
Title: crash with audio on vista/visual studio 2008
Post by: Wolfram on September 21, 2009, 03:36:29 pm
Code: [Select]
Hm... Another idea: Try to download a current OpenAL32 runtime
Hmm, but the static SFML-audio library uses also OpenAl32 and haven't problems, but I will try to install the newest OpenAl32 runtime.
Title: crash with audio on vista/visual studio 2008
Post by: Laurent on September 21, 2009, 03:38:49 pm
You must use the DLLs provided in the SFML SDK, not another release (especially from Creative Labs website -- this implementation is buggy, deprecated and not used anymore by SFML).
Title: crash with audio on vista/visual studio 2008
Post by: Nexus on September 21, 2009, 03:51:32 pm
Oh, thanks for the correction. I received a more reliable impression from the website. :roll:

Anyway, I edited my post not to confuse more users.
Title: crash with audio on vista/visual studio 2008
Post by: Laurent on September 21, 2009, 03:56:17 pm
Quote
I received more reliable impression from the website

I looked at the website, and they talk about OpenAL Soft (which is the one used by SFML). But I don't know if they support/distribute it, or if they just mention it.
Title: crash with audio on vista/visual studio 2008
Post by: Wolfram on September 21, 2009, 03:59:52 pm
Code: [Select]
You must use the DLLs provided in the SFML SDK, not another release (espacially from Creative Labs website -- this implementation is buggy, deprecated and not used anymore by SFML).
I use the DLLs provided in the SFML SDK, but my applications don't work if I use the dynamic SFML-audio library.
With a static build of SFML-audio library I can use the audio-package without problems.
I think it's a bug, because I've got no problems with sounds in older SFML versions.
Title: crash with audio on vista/visual studio 2008
Post by: Laurent on September 21, 2009, 05:30:42 pm
I think this has to do with the global audio manager, I'll see if I can fix it.
Title: crash with audio on vista/visual studio 2008
Post by: Tank on October 29, 2009, 10:05:17 pm
Just did a build of SFML2 on a Windows 7 installation and the same bug happens for me. Is there any update on this one?

(program starts, but windows doesn't open)
Title: crash with audio on vista/visual studio 2008
Post by: Laurent on October 30, 2009, 09:02:36 am
Quote
Just did a build of SFML2 on a Windows 7 installation and the same bug happens for me

Can you tell me again what the bug is exactly?
Title: crash with audio on vista/visual studio 2008
Post by: Tank on October 30, 2009, 11:50:52 am
Hehe sure: As soon as you link to sfml-audio dynamically (debug or release doesn't matter), then the window doesn't show up/application's not running (I did not throw that in a debugger). You don't even have to use SFML Audio (I mean code-wise), so it might be something while initialisation happens. By the way, the binary is showing up in the task manager, eating 0% CPU power.

Linking statically isn't a problem at all, everything works fine.

I wonder that you don't have that problem. :/ I'm not an expert on programming under Windows (installed MSVC2008 to be able to test that "bug" someone reported on a lib of mine), so maybe I'm missing a setting or something.
Title: crash with audio on vista/visual studio 2008
Post by: Laurent on October 30, 2009, 11:58:04 am
Quote
You don't even have to use SFML Audio (I mean code-wise)

But it's still link to sfml-audio, right? I mean, if you unlink sfml-audio.lib then does it work fine?

Quote
I wonder that you don't have that problem

I always use the static libraries for testing.
Title: crash with audio on vista/visual studio 2008
Post by: Tank on October 30, 2009, 02:45:09 pm
Quote from: "Laurent"
But it's still link to sfml-audio, right? I mean, if you unlink sfml-audio.lib then does it work fine?

Exactly.

Quote
I always use the static libraries for testing.

Okay I see.
Title: crash with audio on vista/visual studio 2008
Post by: Laurent on October 30, 2009, 02:59:12 pm
Ok, so it must really be related to the global audio manager. Too bad...