0
0

Hi,

I have a plugin in a DLL file. Note that this DLL file is already loaded.

It contains the following functions:

Header:
[code:c2pgwcb3]
//Taken from the output example
FMOD_RESULT F_CALLBACK OutputMP3_GetNumDriversCallback(FMOD_OUTPUT_STATE *output, int *numdrivers);
FMOD_RESULT F_CALLBACK OutputMP3_GetDriverNameCallback(FMOD_OUTPUT_STATE *output, int id, char *name, int namelen);
FMOD_RESULT F_CALLBACK OutputMP3_InitCallback(FMOD_OUTPUT_STATE *output, int selecteddriver, FMOD_INITFLAGS flags, int *outputrate, int outputchannels, FMOD_SOUND_FORMAT *outputformat, int dspbufferlength, int dspnumbuffers, const void *hwnd);
FMOD_RESULT F_CALLBACK OutputMP3_CloseCallback(FMOD_OUTPUT_STATE *output);
FMOD_RESULT F_CALLBACK OutputMP3_UpdateCallback(FMOD_OUTPUT_STATE *output);
FMOD_RESULT F_CALLBACK OutputMP3_GetHandleCallback(FMOD_OUTPUT_STATE *output, void **handle);
[/code:c2pgwcb3]

Cpp:
[code:c2pgwcb3]
//Taken from the output example

FMOD_OUTPUT_DESCRIPTION mp3output;

extern "C" F_DECLSPEC F_DLLEXPORT FMOD_OUTPUT_DESCRIPTION * __cdecl FMODGetOutputDescription()
{
memset(&mp3output, 0, sizeof(FMOD_OUTPUT_DESCRIPTION));

mp3output.name          = "Act-3D Encoder Output";
mp3output.version       = 0x00010000;
mp3output.polling       = 0;                                    /* False = no thread is created.  Plugin must drive FMOD's mixer */
mp3output.getnumdrivers = OutputMP3_GetNumDriversCallback;
mp3output.getdrivername = OutputMP3_GetDriverNameCallback;
mp3output.getdrivercaps = 0;
mp3output.init          = (FMOD_OUTPUT_INITCALLBACK)OutputMP3_InitCallback;
mp3output.close         = OutputMP3_CloseCallback;
mp3output.update        = OutputMP3_UpdateCallback;
mp3output.gethandle     = OutputMP3_GetHandleCallback;
mp3output.getposition   = 0;                                    /* Not a polling output so getposition is never called */
mp3output.lock          = 0;                                    /* Not a polling output so lock is never called */
mp3output.unlock        = 0;                                    /* Not a polling output so unlock is never called */

return &mp3output;

}

//Implementations of the function in the header

[/code:c2pgwcb3]

The plugin loads and functions perfect fine in a 64 bit environment (VC++)
When compiling to 32 bit, the exact same code returns FMOD_ERR_FILE_BAD on loadPlugin
LoadLibrary succeeds and dependency viewer shows no errors.

What could be the cause of my problem?

Arthur

  • You must to post comments
0
0

I found out that the output_plugin example works fine. The only difference seems the way FMODGetOutputDescription is written.

The difference is that if I remove the cast operator at OutputMP3_InitCallback I will get an error:

[code:1kq4eztv]
F_DECLSPEC F_DLLEXPORT FMOD_OUTPUT_DESCRIPTION * F_API FMODGetOutputDescription()
{
memset(&mp3output, 0, sizeof(FMOD_OUTPUT_DESCRIPTION));

mp3output.name          = "FMOD MP3 Output";
mp3output.version       = 0x00010000;
mp3output.polling       = 0;                                    /* False = no thread is created.  Plugin must drive FMOD's mixer */
mp3output.getnumdrivers = OutputMP3_GetNumDriversCallback;
mp3output.getdrivername = OutputMP3_GetDriverNameCallback;
mp3output.getdrivercaps = 0;
mp3output.init          = OutputMP3_InitCallback;
mp3output.close         = OutputMP3_CloseCallback;
mp3output.update        = OutputMP3_UpdateCallback;
mp3output.gethandle     = OutputMP3_GetHandleCallback;
mp3output.getposition   = 0;                                    /* Not a polling output so getposition is never called */
mp3output.lock          = 0;                                    /* Not a polling output so lock is never called */
mp3output.unlock        = 0;                                    /* Not a polling output so unlock is never called */

return &mp3output;

}[/code:1kq4eztv]

I get the following error:

[code:1kq4eztv]
: error C2440: ‘=’ : cannot convert from ‘FMOD_RESULT (__stdcall *)(FMOD_OUTPUT_STATE *,int,FMOD_INITFLAGS,int *,int,FMOD_SOUND_FORMAT *,int,int,const void *)’ to ‘FMOD_OUTPUT_INITCALLBACK’
1> This conversion requires a reinterpret_cast, a C-style cast or function-style cast
[/code:1kq4eztv]

The error occurs ONLY on OutputMP3_InitCallback, not the other functions!

  • You must to post comments
0
0

A couple of things I have noticed:

  1. FMOD_OUTPUT_INITCALLBACK describes extradriverdata as ‘void *’ where your code uses ‘const void *’
  2. The example FMODGetOutputDescription is declared as _stdcall where you have it as _cdecl.
  • You must to post comments
0
0

That did the trick.

Really weird, since the function definitions come from the output_mp3 example (which works). Anyway it works now and you saved my christmas holliday, thanks.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.