0
0

I try to handle the situation when the user removes and insert audio device during the application running. I using System::setCallback and FMOD_SYSTEM_CALLBACKTYPE_DEVICELISTCHANGED. In callback just System::setDriver(0) called. It works fine at the most of machines. But at one of the machines setDriver returns FMOD_ERR_OUTPUT_INIT.
Documentation says: "The driver that you wish to change to must support the current output format, sample rate, and number of channels."
How can I figure out "support output format, sample rate and numer of channels"? I can’t call System::getDriverCaps() after System::init()

Here is the code:
[code:lkyeiqqp]
FMOD_RESULT F_CALLBACK SystemCallback(FMOD_SYSTEM *system, FMOD_SYSTEM_CALLBACKTYPE type, void *commanddata1, void *commanddata2)
{
FMOD::System *sys = (FMOD::System *)system;
FMOD_RESULT result;
switch (type)
{
case FMOD_SYSTEM_CALLBACKTYPE_DEVICELISTCHANGED:
{
int nDrivers;

        result = sys->getNumDrivers(&nDrivers);
        ASSERT(result == FMOD_OK);
        if (nDrivers <= 0)
            break;

        for (int i = 0; i < nDrivers; ++i)
        {
            result = sys->setDriver(i);
            if (result == FMOD_OK)
                break;
        }
        break;
    }
}
return FMOD_OK;

}
[/code:lkyeiqqp]

  • You must to post comments
0
0

The issue resolved. The problem was with a mute built-in monitor speakers. They were a default driver when application was running without headphones. So after insertion headphones there was no any sound. I have disabled monitor speakes. Now everything is ok.

  • You must to post comments
0
0

Regarding your question, that comment means the sound card must be the same channel format for it to work, otherwise it would return an error.
In FMOD Studio low level API this limitation is not there any more – in fact the recommended startup sequence is removed , the mixer will set itself to a certain format to begin with, then even if the sound device changes channelcounts or frequency or bit depth, the mixer will run as normal and Studio automatically handles the output device format change (by upmixing/downmixing/resampling).

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.