System::setCallback

FMOD Studio API

Firelight Technologies FMOD Studio API

System::setCallback

Sets a system callback to catch various fatal or informational events.

C++ Syntax

FMOD_RESULT System::setCallback(
  FMOD_SYSTEM_CALLBACK callback,
  FMOD_SYSTEM_CALLBACK_TYPE callbackmask
);

C Syntax

FMOD_RESULT FMOD_System_SetCallback(
  FMOD_SYSTEM *system,
  FMOD_SYSTEM_CALLBACK callback,
  FMOD_SYSTEM_CALLBACK_TYPE callbackmask
);

C# Syntax

RESULT System.setCallback(
  SYSTEM_CALLBACK callback,
  SYSTEM_CALLBACK_TYPE callbackmask
);

JavaScript Syntax

System.setCallback(
  callback,                        
  callbackmask                     
);

Parameters

callback
Pointer to a callback to receive the event callback when it happens.
callbackmask
A bitfield describing which callbacks are required to be triggered. Masking out some callback types can help avoid a flood of irrelevant callbacks being triggered.

Return Values

If the function succeeds then the return value is FMOD_OK.
If the function fails then the return value will be one of the values defined in the FMOD_RESULT enumeration.

Remarks

System callbacks are not asynchronous and are bound by the latency caused by the rate the user calls the update command.

Callbacks are stdcall. Use F_CALLBACK inbetween your return type and function name.

The 'userdata' parameter passed to the callback is the userdata assigned to the system from System::setUserData function.

Example:

FMOD_RESULT F_CALLBACK systemcallback(FMOD_SYSTEM *system, FMOD_SYSTEM_CALLBACK_TYPE type, void *commanddata1, void *commanddata2, void* userdata)
{
    FMOD::System *sys = (FMOD::System *)system;

    switch (type)
    {
        case FMOD_SYSTEM_CALLBACK_DEVICELISTCHANGED:
        {
            int numdrivers;

            printf("NOTE : FMOD_SYSTEM_CALLBACK_DEVICELISTCHANGED occured.\n");

            sys->getNumDrivers(&numdrivers);

            printf("Numdevices = %d\n", numdrivers);
            break;
        }
        case FMOD_SYSTEM_CALLBACK_MEMORYALLOCATIONFAILED:
        {
            printf("ERROR : FMOD_SYSTEM_CALLBACK_MEMORYALLOCATIONFAILED occured.\n");
            printf("%s.\n", commanddata1);
            printf("%d bytes.\n", commanddata2);
            break;
        }
        case FMOD_SYSTEM_CALLBACK_THREADCREATED:
        {
            printf("NOTE : FMOD_SYSTEM_CALLBACK_THREADCREATED occured.\n");
            printf("Thread ID = %d\n", (int)commanddata1);
            printf("Thread Name = %s\n", (char *)commanddata2);
            break;
        }
        case FMOD_SYSTEM_CALLBACK_BADDSPCONNECTION:
        {
            FMOD::DSP *source = (FMOD::DSP *)commanddata1;
            FMOD::DSP *dest = (FMOD::DSP *)commanddata2;

            printf("ERROR : FMOD_SYSTEM_CALLBACK_BADDSPCONNECTION occured.\n");
            if (source)
            {
                char name[256];
                source->getInfo(name, 0,0,0,0);
                printf("SOURCE = %s\n", name);
            }
            if (dest)
            {
                char name[256];
                dest->getInfo(name, 0,0,0,0);
                printf("DEST = %s\n", name);
            }
            break;
        }
        case FMOD_SYSTEM_CALLBACK_BADDSPLEVEL:
        {
            printf("NOTE : FMOD_SYSTEM_CALLBACK_BADDSPLEVEL occured.\n");
            break;
        }
        case FMOD_SYSTEM_CALLBACK_PREMIX:
        {
            printf("NOTE : FMOD_SYSTEM_CALLBACK_PREMIX occured.\n");
            break;
        }
        case FMOD_SYSTEM_CALLBACK_MIDMIX:
        {
            printf("NOTE : FMOD_SYSTEM_CALLBACK_MIDMIX occured.\n");
            break;
        }
        case FMOD_SYSTEM_CALLBACK_POSTMIX:
        {
            printf("NOTE : FMOD_SYSTEM_CALLBACK_POSTMIX occured.\n");
            break;
        }
    }

    return FMOD_OK;
}

See Also




Version 1.10.03 Built on Feb 1, 2018