MIX_LoadRawAudioNoCopy(3)

NAME
MIX_LoadRawAudioNoCopy - Load raw PCM data from a memory buffer without making a copy.

SYNOPSIS
#include <SDL3_mixer/SDL_mixer.h>

MIX_Audio * MIX_LoadRawAudioNoCopy(MIX_Mixer *mixer, const void *data, size_t datalen, const SDL_AudioSpec *spec, bool free_when_done);

DESCRIPTION
This buffer must live for the entire time the returned MIX_Audio lives, as the mixer will access the buffer whenever it needs to mix more data.

This function is meant to maximize efficiency: if the data is already in memory and can remain there, don't copy it. But it can also lead to some interesting tricks, like changing the buffer's contents to alter multiple playing tracks at once. (But, of course, be careful when being too clever.)

MIX_Audio objects can be shared between multiple mixers. The mixer parameter just suggests the most likely mixer to use this audio, in case some optimization might be applied, but this is not required, and a NULL mixer may be specified.

If free_when_done is true, SDL_mixer will call SDL_free(data) when the returned MIX_Audio is eventually destroyed. This can be useful when the data is not static, but rather composed dynamically for this specific MIX_Audio and simply wants to avoid the extra copy.

FUNCTION PARAMETERS

mixer
    a mixer this audio is intended to be used with. May be NULL.

data
    the buffer where the raw PCM data lives.

datalen
    the size, in bytes, of the buffer.

spec
    what format the raw data is in.

free_when_done
    if true, data will be given to SDL_free() when the MIX_Audio is destroyed.

RETURN VALUE
Returns an audio object that can be used to make sound on a mixer, or NULL on failure; call SDL_GetError() for more information.

THREAD SAFETY
It is safe to call this function from any thread.

AVAILABILITY
This function is available since SDL_mixer 3.0.0.

SEE ALSO
MIX_DestroyAudio(3), MIX_SetTrackAudio(3), MIX_LoadRawAudio(3), MIX_LoadRawAudio_IO(3), MIX_LoadAudio_IO(3)