0
0

[b:2t4amgjt]Detailed description:[/b:2t4amgjt]
While a number of different startup sequences are possible, there is one that is specifically endorsed by Firelight Technologies to be effective in a wide variety of projects.

[b:2t4amgjt]Solution 1:[/b:2t4amgjt]
1. Implement the following reccomended startup sequence:
[code:2t4amgjt]
FMOD::System *system;
FMOD_RESULT result;
unsigned int version;
int numdrivers;
FMOD_SPEAKERMODE speakermode;
FMOD_CAPS caps;
char name[256];

/*
    Create a System object and initialize.
*/
result = FMOD::System_Create(&system);
ERRCHECK(result);

result = system->getVersion(&version);
ERRCHECK(result);

if (version < FMOD_VERSION)
{
    printf("Error!  You are using an old version of FMOD %08x.  This program requires %08x\n", version, FMOD_VERSION);
    return 0;
}

result = system->getNumDrivers(&numdrivers);
ERRCHECK(result);

result = system->setHardwareChannels(0,0,0,0);  /* Skip EAX probe which can crash/corrupt some bad drivers. */
ERRCHECK(result);

if (numdrivers == 0)
{
    result = system->setOutput(FMOD_OUTPUTTYPE_NOSOUND);
    ERRCHECK(result);
}
else
{
    result = system->getDriverCaps(0, &caps, 0, 0, &speakermode);
    ERRCHECK(result);

    result = system->setSpeakerMode(speakermode);       /* Set the user selected speaker mode. */
    ERRCHECK(result);

    if (caps & FMOD_CAPS_HARDWARE_EMULATED)             /* The user has the 'Acceleration' slider set to off!  This is really bad for latency!. */
    {                                                   /* You might want to warn the user about this. */
        result = system->setDSPBufferSize(1024, 10);
        ERRCHECK(result);
    }

    result = system->getDriverInfo(0, name, 256, 0);
    ERRCHECK(result);

    if (strstr(name, "SigmaTel"))   /* Sigmatel sound devices crackle for some reason if the format is PCM 16bit.  PCM floating point output seems to solve it. */
    {
        result = system->setSoftwareFormat(48000, FMOD_SOUND_FORMAT_PCMFLOAT, 0,0, FMOD_DSP_RESAMPLER_LINEAR);
        ERRCHECK(result);
    }
}

result = system->init(100, FMOD_INIT_NORMAL, 0);
if (result == FMOD_ERR_OUTPUT_CREATEBUFFER)         /* Ok, the speaker mode selected isn't supported by this soundcard.  Switch it back to stereo... */
{
    result = system->setSpeakerMode(FMOD_SPEAKERMODE_STEREO);
    ERRCHECK(result);

    result = system->init(100, FMOD_INIT_NORMAL, 0);/* ... and re-init. */
    if (result == FMOD_ERR_OUTPUT_CREATEBUFFER)         /* Now the directsound driver can't even create a stereo buffer - great, let's try WINMM ... */
    {
        result = system->setOutput(FMOD_OUTPUTTYPE_WINMM);
        ERRCHECK(result);

        result = system->init(100, FMOD_INIT_NORMAL, 0);/* ... and re-init. */
        ERRCHECK(result);
    }
}

[/code:2t4amgjt]2. Modify the above code to use the number of channels appropriate for the game, rather than the default 100.
This sequence handles windows speaker settings, not having a sound card, various bad sound card drivers, and init errors.

[b:2t4amgjt]Notes:[/b:2t4amgjt]
(No known-to-be-relevant example, tutorial or documentation exists for this issue.)

  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.