From 11779975998bd3c191fbca5abda1f050f140074c Mon Sep 17 00:00:00 2001 From: David Reid Date: Mon, 5 Jun 2023 09:01:30 +1000 Subject: [PATCH] Add support for supplying a custom device data callback to ma_engine. When this is used, the data callback should at some point call ma_engine_read_pcm_frames() in order to do some processing. --- miniaudio.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/miniaudio.h b/miniaudio.h index b5bc8398..12976de0 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -11147,6 +11147,7 @@ typedef struct ma_context* pContext; ma_device* pDevice; /* If set, the caller is responsible for calling ma_engine_data_callback() in the device's data callback. */ ma_device_id* pPlaybackDeviceID; /* The ID of the playback device to use with the default listener. */ + ma_device_data_proc dataCallback; /* Can be null. Can be used to provide a custom device data callback. */ ma_device_notification_proc notificationCallback; #endif ma_log* pLog; /* When set to NULL, will use the context's log. */ @@ -74228,7 +74229,7 @@ MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEng deviceConfig.playback.format = ma_format_f32; deviceConfig.playback.channels = engineConfig.channels; deviceConfig.sampleRate = engineConfig.sampleRate; - deviceConfig.dataCallback = ma_engine_data_callback_internal; + deviceConfig.dataCallback = (engineConfig.dataCallback != NULL) ? engineConfig.dataCallback : ma_engine_data_callback_internal; deviceConfig.pUserData = pEngine; deviceConfig.notificationCallback = engineConfig.notificationCallback; deviceConfig.periodSizeInFrames = engineConfig.periodSizeInFrames;