Commit 97c7c0a7 authored by David Reid's avatar David Reid

API CHANGE: Remove the onLog parameter from mal_context_config_init().

This commit also renames the onLog member of mal_context_config to
logCallback for consistency with mal_device_config callback naming
convention.
parent 88b75fdb
...@@ -261,7 +261,7 @@ OPTIONS ...@@ -261,7 +261,7 @@ OPTIONS
#define MAL_DEBUT_OUTPUT #define MAL_DEBUT_OUTPUT
Enable printf() debug output. Enable printf() debug output.
#ifndef MAL_COINIT_VALUE #define MAL_COINIT_VALUE
Windows only. The value to pass to internal calls to CoInitializeEx(). Defaults to COINIT_MULTITHREADED. Windows only. The value to pass to internal calls to CoInitializeEx(). Defaults to COINIT_MULTITHREADED.
...@@ -1600,7 +1600,7 @@ typedef struct ...@@ -1600,7 +1600,7 @@ typedef struct
typedef struct typedef struct
{ {
mal_log_proc onLog; mal_log_proc logCallback;
mal_thread_priority threadPriority; mal_thread_priority threadPriority;
struct struct
...@@ -1646,7 +1646,7 @@ struct mal_context ...@@ -1646,7 +1646,7 @@ struct mal_context
mal_result (* onDeviceStop )(mal_device* pDevice); mal_result (* onDeviceStop )(mal_device* pDevice);
mal_result (* onDeviceWrite )(mal_device* pDevice, const void* pPCMFrames, mal_uint32 frameCount); /* Data is in internal device format. */ mal_result (* onDeviceWrite )(mal_device* pDevice, const void* pPCMFrames, mal_uint32 frameCount); /* Data is in internal device format. */
mal_result (* onDeviceRead )(mal_device* pDevice, void* pPCMFrames, mal_uint32 frameCount); /* Data is in internal device format. */ mal_result (* onDeviceRead )(mal_device* pDevice, void* pPCMFrames, mal_uint32 frameCount); /* Data is in internal device format. */
mal_result (* onDeviceMainLoop )(mal_device* pDevice); mal_result (* onDeviceMainLoop)(mal_device* pDevice);
union union
{ {
...@@ -1659,7 +1659,7 @@ struct mal_context ...@@ -1659,7 +1659,7 @@ struct mal_context
#ifdef MAL_SUPPORT_DSOUND #ifdef MAL_SUPPORT_DSOUND
struct struct
{ {
/*HMODULE*/ mal_handle hDSoundDLL; mal_handle hDSoundDLL;
mal_proc DirectSoundCreate; mal_proc DirectSoundCreate;
mal_proc DirectSoundEnumerateA; mal_proc DirectSoundEnumerateA;
mal_proc DirectSoundCaptureCreate; mal_proc DirectSoundCaptureCreate;
...@@ -1669,7 +1669,7 @@ struct mal_context ...@@ -1669,7 +1669,7 @@ struct mal_context
#ifdef MAL_SUPPORT_WINMM #ifdef MAL_SUPPORT_WINMM
struct struct
{ {
/*HMODULE*/ mal_handle hWinMM; mal_handle hWinMM;
mal_proc waveOutGetNumDevs; mal_proc waveOutGetNumDevs;
mal_proc waveOutGetDevCapsA; mal_proc waveOutGetDevCapsA;
mal_proc waveOutOpen; mal_proc waveOutOpen;
...@@ -2212,7 +2212,7 @@ MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_device ...@@ -2212,7 +2212,7 @@ MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_device
// - Web Audio / Emscripten // - Web Audio / Emscripten
// - Null // - Null
// //
// <pConfig> is used to configure the context. Use the onLog config to set a callback for whenever a // <pConfig> is used to configure the context. Use the logCallback config to set a callback for whenever a
// log message is posted. The priority of the worker thread can be set with the threadPriority config. // log message is posted. The priority of the worker thread can be set with the threadPriority config.
// //
// It is recommended that only a single context is active at any given time because it's a bulky data // It is recommended that only a single context is active at any given time because it's a bulky data
...@@ -2318,8 +2318,8 @@ mal_result mal_context_get_device_info(mal_context* pContext, mal_device_type de ...@@ -2318,8 +2318,8 @@ mal_result mal_context_get_device_info(mal_context* pContext, mal_device_type de
// //
// The device's configuration is controlled with pConfig. This allows you to configure the sample // The device's configuration is controlled with pConfig. This allows you to configure the sample
// format, channel count, sample rate, etc. Before calling mal_device_init(), you will need to // format, channel count, sample rate, etc. Before calling mal_device_init(), you will need to
// initialize a mal_device_config object using mal_device_config_init(), mal_device_config_init_playback(), // initialize a mal_device_config object using mal_device_config_init(). You must set the callback in
// etc. You must set the callback in the device config. // the device config.
// //
// Passing in 0 to any property in pConfig will force the use of a default value. In the case of // Passing in 0 to any property in pConfig will force the use of a default value. In the case of
// sample format, channel count, sample rate and channel map it will default to the values used by // sample format, channel count, sample rate and channel map it will default to the values used by
...@@ -2450,7 +2450,7 @@ mal_uint32 mal_device_get_buffer_size_in_bytes(mal_device* pDevice); ...@@ -2450,7 +2450,7 @@ mal_uint32 mal_device_get_buffer_size_in_bytes(mal_device* pDevice);
// Helper function for initializing a mal_context_config object. // Helper function for initializing a mal_context_config object.
mal_context_config mal_context_config_init(mal_log_proc onLog); mal_context_config mal_context_config_init();
// Initializes a device config. // Initializes a device config.
// //
...@@ -4480,7 +4480,7 @@ void mal_log(mal_context* pContext, mal_device* pDevice, mal_uint32 logLevel, co ...@@ -4480,7 +4480,7 @@ void mal_log(mal_context* pContext, mal_device* pDevice, mal_uint32 logLevel, co
} }
#endif #endif
mal_log_proc onLog = pContext->config.onLog; mal_log_proc onLog = pContext->config.logCallback;
if (onLog) { if (onLog) {
onLog(pContext, pDevice, logLevel, message); onLog(pContext, pDevice, logLevel, message);
} }
...@@ -20560,8 +20560,8 @@ mal_result mal_device_init(mal_context* pContext, const mal_device_config* pConf ...@@ -20560,8 +20560,8 @@ mal_result mal_device_init(mal_context* pContext, const mal_device_config* pConf
pDevice->onStop = config.stopCallback; pDevice->onStop = config.stopCallback;
if (((size_t)pDevice % sizeof(pDevice)) != 0) { if (((size_t)pDevice % sizeof(pDevice)) != 0) {
if (pContext->config.onLog) { if (pContext->config.logCallback) {
pContext->config.onLog(pContext, pDevice, MAL_LOG_LEVEL_WARNING, "WARNING: mal_device_init() called for a device that is not properly aligned. Thread safety is not supported."); pContext->config.logCallback(pContext, pDevice, MAL_LOG_LEVEL_WARNING, "WARNING: mal_device_init() called for a device that is not properly aligned. Thread safety is not supported.");
} }
} }
...@@ -21009,13 +21009,11 @@ mal_uint32 mal_device_get_buffer_size_in_bytes(mal_device* pDevice) ...@@ -21009,13 +21009,11 @@ mal_uint32 mal_device_get_buffer_size_in_bytes(mal_device* pDevice)
return pDevice->bufferSizeInFrames * pDevice->channels * mal_get_bytes_per_sample(pDevice->format); return pDevice->bufferSizeInFrames * pDevice->channels * mal_get_bytes_per_sample(pDevice->format);
} }
mal_context_config mal_context_config_init(mal_log_proc onLog) mal_context_config mal_context_config_init()
{ {
mal_context_config config; mal_context_config config;
mal_zero_object(&config); mal_zero_object(&config);
config.onLog = onLog;
return config; return config;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment