Skip to content

Manual Audio Initialization

Finalspace edited this page May 29, 2026 · 1 revision

Table of Contents

Overview

If you want to initialize and release the audio system yourself, you can call fplAudioInit() and fplAudioRelease() respectively.

In addition you can set fplAudioSettings::manualLoad to true, so that fplPlatformInit() won't do any audio backend initialization.

 audioSettings;
fplDefaultAudioSettings(&audioSettings);

 settings = ;
fplDefaultSettings(&settings);
settings.. = true;

const char *newMediaFilePath = ;

// Initialize
if ((, &settings)) {

    // Main loop
    bool isAppRunning = true;
    while (isAppRunning) {

        // Use case: Loading media file from a request
        MediaFormat mediaFormat = ;
        if (newMediaFilePath !=  && MyMediaLoad(newMediaFilePath, &mediaFormat)) {
             newAudioSettings;
            fplDefaultAudioSettings(&newAudioSettings);
            newAudioSettings.channels = mediaFormat.channels;
            newAudioSettings.format = mediaFormat.type;
            newAudioSettings.sampleRate = mediaFormat.sampleRate;

            // Manual initialize the audio system
             resultType = (&newAudioSettings);
            if (resultType != newAudioSettings_Success) {
                // Handle error
                // No need to stop or release the audio system, this is done automatically
            } else {
                // Success, you can start the playback now
                ();
            }
        }

    }

    // Manually release the audio system
    ();

    // Release the platform
    ();
}

Warning: Do not remove the

fplInitFlags_Audio from

fplPlatformInit() , otherwise the audio system initialization in

fplAudioInit() will always fail!

Final Platform Layer

Pages

Topics

Data Structures

Clone this wiki locally