I want to make a playlist. This requires to know when a song is over.
I read a possible way is to use FSOUND_Stream_SetEndCallback.
The callback runs well, but I have a problem to access on members
of my class in the callback-function.

static signed char F_CALLBACKAPI endcallback(FSOUND_STREAM *stream, void *buff, int len, void *param);

void CMyListView::Init()

pMain1->song.stream = FSOUND_Stream_Open(filename, FSOUND_NORMAL ,0,0);
FSOUND_Stream_SetEndCallback(pMain1->song.stream, endcallback, NULL);
pMain1->song.channel = FSOUND_Stream_Play(FSOUND_FREE, pMain1->song.stream);


signed char F_CALLBACKAPI CMyListView::endcallback(FSOUND_STREAM *stream, void *buff, int len, void *param)
AfxMessageBox(“Song is over …”);
return 0;

Now, I want to access on member variables in the endcallback-Funktion.
I know it’s possible by casting the void param to an object-typ of my class, like:
myself = (CMyListView*) param;
myself->Play(next); //Play() and next are members of CMyListView

I do this often when I implement a thread-funktion, there is no problem
But when I use the void *param in this way my app crash while executing the endcallback-function.

Please, give me a hint. What’s going wrong.
How can I access on members in fmods-Callbacks

Thanks a lot


  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.