mixStopTag function mixer
Halt all tracks with a specific tag, possibly fading out over time.
If fade_out_ms
is > 0, the tracks do not stop mixing immediately, but
rather fades to silence over that many milliseconds before stopping. Note
that this is different than MIX_StopTrack(), which wants sample frames;
this function takes milliseconds because different tracks might have
different sample rates.
If a track ends normally while the fade-out is still in progress, the audio stops there; the fade is not adjusted to be shorter if it will last longer than the audio remaining.
Once a track has completed any fadeout and come to a stop, it will call its MIX_TrackStoppedCallback, if any. It is legal to assign the track a new input and/or restart it during this callback. This function does not prevent new play requests from being made.
\param mixer the mixer on which to stop tracks. \param tag the tag to use when searching for tracks. \param fade_out_ms the number of milliseconds to spend fading out to silence before halting. 0 to stop immediately. \returns true on success, false on error; call SDL_GetError() for details.
\threadsafety It is safe to call this function from any thread.
\since This function is available since SDL_mixer 3.0.0.
\sa MIX_StopTrack \sa MIX_TagTrack
extern SDL_DECLSPEC bool SDLCALL MIX_StopTag(MIX_Mixer *mixer, const char *tag, Sint64 fade_out_ms)
Implementation
bool mixStopTag(Pointer<MixMixer> mixer, String? tag, int fadeOutMs) {
final mixStopTagLookupFunction = _libMixer
.lookupFunction<
Uint8 Function(
Pointer<MixMixer> mixer,
Pointer<Utf8> tag,
Int64 fadeOutMs,
),
int Function(Pointer<MixMixer> mixer, Pointer<Utf8> tag, int fadeOutMs)
>('MIX_StopTag');
final tagPointer = tag != null ? tag.toNativeUtf8() : nullptr;
final result = mixStopTagLookupFunction(mixer, tagPointer, fadeOutMs) == 1;
calloc.free(tagPointer);
return result;
}