ma_device_data_proc typedef

The callback for processing audio data from the device.

The data callback is fired by miniaudio whenever the device needs to have more data delivered to a playback device, or when a capture device has some data available. This is called as soon as the backend asks for more data which means it may be called with inconsistent frame counts. You cannot assume the callback will be fired with a consistent frame count.

Parameters

pDevice (in) A pointer to the relevant device.

pOutput (out) A pointer to the output buffer that will receive audio data that will later be played back through the speakers. This will be non-null for a playback or full-duplex device and null for a capture and loopback device.

pInput (in) A pointer to the buffer containing input data from a recording device. This will be non-null for a capture, full-duplex or loopback device and null for a playback device.

frameCount (in) The number of PCM frames to process. Note that this will not necessarily be equal to what you requested when you initialized the device. The periodSizeInFrames and periodSizeInMilliseconds members of the device config are just hints, and are not necessarily exactly what you'll get. You must not assume this will always be the same value each time the callback is fired.

Remarks

You cannot stop and start the device from inside the callback or else you'll get a deadlock. You must also not uninitialize the device from inside the callback. The following APIs cannot be called from inside the callback:

ma_device_init() ma_device_init_ex() ma_device_uninit() ma_device_start() ma_device_stop()

The proper way to stop the device is to call ma_device_stop() from a different thread, normally the main application thread.

Implementation

typedef ma_device_data_proc
    = ffi.Pointer<ffi.NativeFunction<ma_device_data_procFunction>>;