0
0

greetings,

i’ve a little problem here.
i’m trying to write a simple streamripper adaptet do the examples and my problem is, that fmod is munching my pointer for the callbacks to get my class back.

Here the pointer is given using setuserdata.
[code:2292t24g]/*** snip ***/
result = FMOD_System_Create(&system);
ERRCHECK(result);

result = FMOD_System_SetUserData (system, this);
ERRCHECK(result);

result = FMOD_System_Init(system, 100, FMOD_INIT_NORMAL, NULL);
ERRCHECK(result);

result = FMOD_System_SetStreamBufferSize(system, FileBufferSize, FMOD_TIMEUNIT_RAWBYTES);
ERRCHECK(result);

result = FMOD_System_AttachFileSystem(system, myopen, myclose, myread, NULL);
ERRCHECK(result);

/*** snap ***/[/code:2292t24g]

At this point userdata still contains the pointer
[code:2292t24g]FMOD_RESULT F_CALLBACK howlingStreamRipper::myopen(const char *name, int unicode, unsigned int *filesize, void **handle, void **userdata) {
howlingStreamRipper * cls = reinterpret_cast<howlingStreamRipper *>(userdata);

cls-&gt;FileHandle = fopen(cls-&gt;OutputFileName, &quot;wb&quot;);
if (!cls-&gt;FileHandle)
{
    return FMOD_ERR_FILE_NOTFOUND;
}

return FMOD_OK;

}[/code:2292t24g]

And here it is gone and userdata is NULL
[code:2292t24g]FMOD_RESULT F_CALLBACK howlingStreamRipper::myread(void *handle, void *buffer, unsigned int sizebytes, unsigned int *bytesread, void *userdata)
{
howlingStreamRipper * cls = reinterpret_cast<howlingStreamRipper *>(userdata);

if (!cls-&gt;FileHandle)
{
    return FMOD_ERR_INVALID_PARAM;
}

/*** snip ***/
[/code:2292t24g]

Any ideas where it could be hidden ?

  • You must to post comments
0
0

ah ok, thank you, didn’t got it before ;).

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.