The callback for processing audio data from the device.
The callback for processing audio data from the device.
pOutput is a pointer to a buffer that will receive audio data that will later be played back through the speakers. This will be non-null
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
for a playback or full-duplex device and null for a capture device.
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.
pInput is a pointer to a buffer containing input data from the device. This will be non-null for a capture or full-duplex device, and
frameCount (in)
null for a playback device.
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
`bufferSizeInFrames` and `bufferSizeInMilliseconds` 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.
frameCount is the number of PCM frames to process. If an output buffer is provided (pOutput is not null), applications should write out
Remarks
to the entire output buffer. Note that frameCount will not necessarily be exactly what you asked for when you initialized the deviced.
-------
The bufferSizeInFrames and bufferSizeInMilliseconds members of the device config are just hints, and are not necessarily exactly what
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
you'll get.
callback. The following APIs cannot be called from inside the callback:
Do _not_ call any miniaudio APIs from the callback. Attempting the stop the device can result in a deadlock. The proper way to stop the
ma_device_init()
device is to call ma_device_stop() from a different thread, normally the main application thread.
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.
The callback for when the device has been stopped.
The callback for when the device has been stopped.
This will be called when the device is stopped explicitly with ma_device_stop() and also called implicitly when the device is stopped
This will be called when the device is stopped explicitly with `ma_device_stop()` and also called implicitly when the device is stopped through external forces
through external forces such as being unplugged or an internal error occuring.
such as being unplugged or an internal error occuring.
Do not restart the device from the callback.
Do not restart or uninitialize the device from the callback.