set_minimum_audio_latency

Function set_minimum_audio_latency 

Source
pub unsafe fn set_minimum_audio_latency(
    callback: retro_environment_t,
    latency: u32,
) -> bool
Expand description

Sets minimum frontend audio latency in milliseconds. Resultant audio latency may be larger than set value, or smaller if a hardware limit is encountered. A frontend is expected to honour requests up to 512 ms.

  • If value is less than current frontend audio latency, callback has no effect
  • If value is zero, default frontend audio latency is set

May be used by a core to increase audio latency and therefore decrease the probability of buffer under-runs (crackling) when performing ‘intensive’ operations. A core utilising RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK to implement audio-buffer-based frame skipping may achieve optimal results by setting the audio latency to a ‘high’ (typically 6x or 8x) integer multiple of the expected frame time.

Calling this can require a full reinitialization of audio drivers in the frontend, so it is important to call it very sparingly, and usually only with the users explicit consent. An eventual driver reinitialize will happen so that audio callbacks happening after this call within the same Core::on_run call will target the newly initialized driver.