i’ve a crash with streams while using FSOUND_Stream_GetOpenState,
and another while closing streams with FSOUND_Stream_Stop() or

i’ve tried to surround these functions with exceptions handlers (try…catch).
The exception is caught while trying to close but not with FSOUND_Stream_GetOpenState().

The 2 crashes are unpredictable, they can occured with any mp3 or
internet streaming and at any time.

I use FSOUND_NONBLOCKING to play these musics.

This is the way i do:

for internet streaming:
[code:1zkoxy16]my_music = FSOUND_Stream_Open(music_en_cours, FSOUND_NORMAL | FSOUND_NONBLOCKING, 0, 0);
int_sound_mp3 = FSOUND_Stream_Play(FSOUND_FREE, my_music);

for mp3:
[code:1zkoxy16]my_music = FSOUND_Stream_Open(music_en_cours, FSOUND_NORMAL | FSOUND_NONBLOCKING | FSOUND_LOOP_OFF, 0, 0);
int_sound_mp3 = FSOUND_Stream_Play(FSOUND_FREE, my_music);

the way i check the open state and close the stream:
[code:1zkoxy16]if (my_music)
if (FSOUND_Stream_GetOpenState(my_music) != 0)

if (FSOUND_IsPlaying(int_sound_mp3)
if (my_music)
if (FSOUND_Stream_Stop(my_music))
my_music = NULL;


and each loop:
[code:1zkoxy16]if (int_sound_mp3 < 0)
if (my_music)
int_sound_mp3 = FSOUND_Stream_Play(FSOUND_FREE, my_music);

maybe i did something wrong… thanks

os: winxp
compiler: VC++ 7.0
fmod.dll: 3.70

  • You must to post comments

If you look in the documentation it clearly states that closing a stream when it is not ready will result in an error (returned false). You need to poll it until it is ready, (until FSOUND_Stream_GetOpenState(stream) = 0).

  • You must to post comments

yes i know. i didn’t precise the third snippet of code i gave, ie this one:

[code:1aj8c0f3]if (my_music)
if (FSOUND_Stream_GetOpenState(my_music) != 0)

if (FSOUND_IsPlaying(int_sound_mp3)
if (my_music)
if (FSOUND_Stream_Stop(my_music))
my_music = NULL;
} [/code:1aj8c0f3]

is in a function, and it returns when FSOUND_Stream_GetOpenState(my_music) != 0,
so the stream is ready when i try to close it.

anyway FSOUND_Stream_GetOpenState crashes. and when i did not
use it, ie i check the state with int_channel >= 0, the stream stop or
close functions crashes as well.

as i said it’s unpredictable, it may work with only one or tens of streams
and on one stream (not always the same of course), it crashes.

thanks for your reply.

[EDIT] I add that the debugger said the error is in fmod.dll, it’s why
of course i can’t use it to debug my app. Also i know where the functions
which causes the crashes are because i used OutputDebugString() to
surround these functions.

  • You must to post comments

thanks for your response.

i’m testing my app in depth now.

i’ve downloaded the last API as i always do now, as i know you upload
it after comments from this forum or other, which is very cool.

with the last version i’ve always the error with getopenstate but not
with stream stop or close functions for now. i need to do more tests
since the crashes are very rare presently.


[edit] about the way i did isplaying before trying to close a stream, it
was just to be sure i didn’t try to close a non-playing song (this is
inside a song closing function).
the code i gave is just snippets, sorry for that.
i will try to define the error as you recommend me, like not using
the nonblocking flag, and give some news soon.

  • You must to post comments

Sorry about the delay for giving news but i spent many time trying to fix
this issue. But now i think the problem is solved :)

Here’re the facts :

my game was in several .cpp and .h files, and i declared some
FSOUND_STREAM* and FMUSIC_MODULE* in the top of loading.cpp, as
global variables. Then i used “extern FSOUND_STREAM* …” and
so on in other files which had to access these pointers.
And it crashed, don’t ask me why i don’t know…

In fact it seems to be a programming issue (terribly sorry if this is the
case) since i discovered by chance i couldn’t access to a global char*
variable by this way in my main.cpp. So i decided to declare the char*
global variable in main.cpp with ” extern char* ” in main.h, itself included
in the other .cpp files, and it works.

So i did the same for the FSOUND pointers and it works as well.
Now i didn’t have any fmod issue since several weeks (i’ve waited to
be sure because the crashes were infrequent). So, pretty kul for me :)

But it seems i have the same problem with some 3DS objects. Arghh…
I really don’t understand what is the point because i declare all my global
variables only once in my code, and i use them in other files by
using “extern”.

My game is 10k lines long and it’s the sole problem of that type i have.
I really don’t understand.

Somebody heard something about that ?
I know this is not a programming forum, sorry again, but maybe some
fmod users had face the same problem and could give me a tip. I’m very
tired about that…

Thanks for reading.

  • You must to post comments

So you use it like this:
[code:3liydqxr]char * test;[/code:3liydqxr]
then main.h
[code:3liydqxr]extern char * test;[/code:3liydqxr]

[code:3liydqxr]#include "main.h"[/code:3liydqxr]

This should work but don’t define “char * test” somewhere else in your code i noticed this gives loads of errors.

So what i did was: make a class!
Each class has his own fmod.dll and a list of pointers to structures.
Each structure contains settings for a specified file.

[code:3liydqxr]enum TFileState {

class TFMODJingle;
typedef struct {
String FileName;
TFMODJingle *Owner; // the class
TFileState FileState;
int Index;
int Frequency;
int Duration;
int Channel;

int CurrTime; // Current played time
int CuePoint; // Loop point
int FadePoint; // Point where fading started
int FadeTime;
int BeforeFadeVolume;
int MixTime;
bool FadeingOut;
bool FadeingIn;
bool BlinkTime; // Blink time last 30 seconds
bool RemainTime; // Show remaining time
bool VinylStop; // Slow down frequency to 0
bool Start;
int VinylFreq;
float PercExactTime; // 1 = 100%
float PercCrossFader; // 1 = 100%

bool Pitching;
int PitchVal;
int Intro;
TLabel* PitchLabel;
TLabel* IntroLabel;
TRLed* VULeft;
TRLed* VURight;
TRLed* PosMeter;
TEMSlider* CueSlider;
TEMSlider* PitchSlider;
TEMSlider* VolSlider;
TEMButton* PlayButton;
TEMButton* StopButton;
TEMButton* FadeButton;
TEMButton* SetCueBtn;
TEMButton* ToCueBtn;
TEMButton* CueBackBtn;
TEMButton* CueForwBtn;
TEMButton* PitchBUp;
TEMButton* PitchBDown;
} FMOD_File;[/code:3liydqxr]

Although above code was made in Borland C++ it could work in any other C++ compiler.

Now i use the class all over the way with just 1 extern :)

  • You must to post comments

Thanks for your post :)

It seems to be a nice idea. In fact i thought about doing something like that (doing a structure to hold global vars) but it’s pretty some work for all my code to make changes. Anyway i’ll have to think seriously about this solution if i cannot solve the problem otherwise.

But it seems i have discovered another clue for my bug (not extern var relative) :) I’m doing tests and come back here for news.

Thanks again :)

  • You must to post comments

As promised, just for ending with this thread i give news.

The first issue was about extern variables (global variables used in
several files) relative to fmod. So i changed the way i handled these,
and it worked.

The second issue was about opengl in my 3ds loader. I didn’t disable
GL_TEXTURE_COORD_ARRAY when the model about to be drawn had
no texture. Sometimes it worked, sometimes not. And the crash adress
indicated by the debugger was in – fmod.dll – or other locations, in fact a
nonsense adress with no meaning as i discovered later.

So as i knew it was in the 3ds loader, i worked on it line after line, and
finaly discovered that as my 3ds loader is a class and the 3ds models are
objects, i needed to turn off – explicitly – texture array for non-textured

I don’t know if this is clear but i think that as i posted my problem i have
to explain the solution.

Now my game doesn’t crash since weeks 😛 Let me say i’m pretty happy!
Thanks all for the inconvenience, it was my last post for this thread.

  • You must to post comments
Showing 7 results
Your Answer

Please first to submit.