libretro.drivers.audio.driver

Interface for audio output.

See also

libretro.api.audio

Provides the C callback and struct types that AudioDriver implementations use.

Classes

AudioDriver

Protocol for drivers that receive audio output from the core.

class AudioDriver[source]

Bases: Protocol

Protocol for drivers that receive audio output from the core.

Can be used with isinstance().

See also

libretro.api.audio

The C callback types and sample function signatures that implementations of this protocol accept.

abstractmethod sample(left, right)[source]

Receives a single stereo audio sample from the core.

Parameters:
  • left (int) – The left-channel sample as a signed 16-bit integer.

  • right (int) – The right-channel sample as a signed 16-bit integer.

See also

retro_audio_sample_t

The C function pointer type whose signature this method implements.

Return type:

None

abstractmethod sample_batch(frames)[source]

Receives a batch of interleaved stereo audio frames from the core.

Parameters:

frames (memoryview) – A read-only memoryview of interleaved signed 16-bit stereo frames.

Return type:

int

Returns:

The number of frames consumed.

See also

retro_audio_sample_batch_t

The C function pointer type whose signature this method implements.

abstract property callbacks

The asynchronous audio callback registered by the core, if any.

Set via RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK.

See also

retro_audio_callback

The C struct registered by the core that contains this callback.

set_state(enabled)[source]

Enable or disables the registered asynchronous audio callback.

Calls retro_audio_callback.set_state if a callback is registered.

Parameters:

enabled (bool) – Whether to enable the audio callback.

Return type:

None

callback()[source]

Invoke the registered asynchronous audio callback, if any.

Calls retro_audio_callback.callback if a callback is registered.

Return type:

None

abstract property buffer_status

The buffer-status callback registered by the core, if any.

Set via RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK.

See also

retro_audio_buffer_status_callback

The C struct registered by the core that contains this callback.

report_buffer_status(active, occupancy, underrun_likely)[source]

Invoke the registered buffer-status callback, if any.

Parameters:
  • active (bool) – Whether the audio buffer is actively being filled.

  • occupancy (int) – The percentage of the buffer that is currently filled (0–100).

  • underrun_likely (bool) – Whether a buffer underrun is likely on the next frame.

Return type:

None

__init__(*args, **kwargs)
classmethod __new__(*args, **kwargs)
abstract property minimum_latency

The minimum audio latency in milliseconds requested by the core, if any.

Set via RETRO_ENVIRONMENT_SET_MINIMUM_AUDIO_LATENCY. None if the core has not set a minimum latency.

abstract property system_av_info

The AV info most recently set by the core.

Used by the driver to configure audio parameters such as sample rate.