mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-21 15:56:58 +02:00
API CHANGE: Move pUserData from device_init() to device_config_init().
This change makes it consistent with mal_pcm_converter, mal_src, etc.
This commit is contained in:
@@ -98,14 +98,15 @@ int main(int argc, char** argv)
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
mal_device_config config = mal_device_config_init_playback(
|
mal_device_config config = mal_device_config_init_playback(
|
||||||
decoder.outputFormat,
|
decoder.outputFormat,
|
||||||
decoder.outputChannels,
|
decoder.outputChannels,
|
||||||
decoder.outputSampleRate,
|
decoder.outputSampleRate,
|
||||||
on_send_frames_to_device);
|
on_send_frames_to_device,
|
||||||
|
&decoder);
|
||||||
|
|
||||||
mal_device device;
|
mal_device device;
|
||||||
if (mal_device_init(NULL, mal_device_type_playback, NULL, &config, &decoder, &device) != MAL_SUCCESS) {
|
if (mal_device_init(NULL, mal_device_type_playback, NULL, &config, &device) != MAL_SUCCESS) {
|
||||||
printf("Failed to open playback device.\n");
|
printf("Failed to open playback device.\n");
|
||||||
mal_decoder_uninit(&decoder);
|
mal_decoder_uninit(&decoder);
|
||||||
return -3;
|
return -3;
|
||||||
|
|||||||
@@ -91,9 +91,9 @@ int main(int argc, char** argv)
|
|||||||
mal_backend_pulseaudio,
|
mal_backend_pulseaudio,
|
||||||
mal_backend_alsa,
|
mal_backend_alsa,
|
||||||
mal_backend_jack,
|
mal_backend_jack,
|
||||||
|
mal_backend_aaudio
|
||||||
mal_backend_opensl,
|
mal_backend_opensl,
|
||||||
mal_backend_openal,
|
mal_backend_webaudio,
|
||||||
mal_backend_sdl,
|
|
||||||
mal_backend_null // Lowest priority.
|
mal_backend_null // Lowest priority.
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ int main(int argc, char** argv)
|
|||||||
// initialize a config object called mal_device_config_init(). There are an additional two helper APIs to make
|
// initialize a config object called mal_device_config_init(). There are an additional two helper APIs to make
|
||||||
// it easy for you to initialize playback or capture configs specifically: mal_device_config_init_playback()
|
// it easy for you to initialize playback or capture configs specifically: mal_device_config_init_playback()
|
||||||
// and mal_device_config_init_capture().
|
// and mal_device_config_init_capture().
|
||||||
mal_device_config deviceConfig = mal_device_config_init(mal_format_s16, 2, 48000, NULL, on_send_frames_to_device);
|
mal_device_config deviceConfig = mal_device_config_init(mal_format_s16, 2, 48000, NULL, on_send_frames_to_device, NULL);
|
||||||
|
|
||||||
// Applications can specify a callback for when a device is stopped.
|
// Applications can specify a callback for when a device is stopped.
|
||||||
deviceConfig.onStopCallback = on_device_stop;
|
deviceConfig.onStopCallback = on_device_stop;
|
||||||
@@ -174,7 +174,7 @@ int main(int argc, char** argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
mal_device playbackDevice;
|
mal_device playbackDevice;
|
||||||
if (mal_device_init(&context, mal_device_type_playback, NULL, &deviceConfig, NULL, &playbackDevice) != MAL_SUCCESS) {
|
if (mal_device_init(&context, mal_device_type_playback, NULL, &deviceConfig, &playbackDevice) != MAL_SUCCESS) {
|
||||||
printf("Failed to initialize playback device.\n");
|
printf("Failed to initialize playback device.\n");
|
||||||
mal_context_uninit(&context);
|
mal_context_uninit(&context);
|
||||||
return -7;
|
return -7;
|
||||||
|
|||||||
@@ -53,11 +53,11 @@ int main()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
mal_device_config config = mal_device_config_init(mal_format_s16, 2, 48000, on_recv_frames, on_send_frames);
|
mal_device_config config = mal_device_config_init(mal_format_s16, 2, 48000, on_recv_frames, on_send_frames, NULL);
|
||||||
|
|
||||||
printf("Recording...\n");
|
printf("Recording...\n");
|
||||||
mal_device captureDevice;
|
mal_device captureDevice;
|
||||||
if (mal_device_init(&context, mal_device_type_capture, NULL, &config, NULL, &captureDevice) != MAL_SUCCESS) {
|
if (mal_device_init(&context, mal_device_type_capture, NULL, &config, &captureDevice) != MAL_SUCCESS) {
|
||||||
mal_context_uninit(&context);
|
mal_context_uninit(&context);
|
||||||
printf("Failed to initialize capture device.\n");
|
printf("Failed to initialize capture device.\n");
|
||||||
return -2;
|
return -2;
|
||||||
@@ -79,7 +79,7 @@ int main()
|
|||||||
|
|
||||||
printf("Playing...\n");
|
printf("Playing...\n");
|
||||||
mal_device playbackDevice;
|
mal_device playbackDevice;
|
||||||
if (mal_device_init(&context, mal_device_type_playback, NULL, &config, NULL, &playbackDevice) != MAL_SUCCESS) {
|
if (mal_device_init(&context, mal_device_type_playback, NULL, &config, &playbackDevice) != MAL_SUCCESS) {
|
||||||
mal_context_uninit(&context);
|
mal_context_uninit(&context);
|
||||||
printf("Failed to initialize playback device.\n");
|
printf("Failed to initialize playback device.\n");
|
||||||
return -4;
|
return -4;
|
||||||
|
|||||||
@@ -38,10 +38,11 @@ int main(int argc, char** argv)
|
|||||||
decoder.outputFormat,
|
decoder.outputFormat,
|
||||||
decoder.outputChannels,
|
decoder.outputChannels,
|
||||||
decoder.outputSampleRate,
|
decoder.outputSampleRate,
|
||||||
on_send_frames_to_device);
|
on_send_frames_to_device,
|
||||||
|
&decoder);
|
||||||
|
|
||||||
mal_device device;
|
mal_device device;
|
||||||
if (mal_device_init(NULL, mal_device_type_playback, NULL, &config, &decoder, &device) != MAL_SUCCESS) {
|
if (mal_device_init(NULL, mal_device_type_playback, NULL, &config, &device) != MAL_SUCCESS) {
|
||||||
printf("Failed to open playback device.\n");
|
printf("Failed to open playback device.\n");
|
||||||
mal_decoder_uninit(&decoder);
|
mal_decoder_uninit(&decoder);
|
||||||
return -3;
|
return -3;
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ int main(int argc, char** argv)
|
|||||||
mal_sine_wave sineWave;
|
mal_sine_wave sineWave;
|
||||||
mal_sine_wave_init(0.2, 400, DEVICE_SAMPLE_RATE, &sineWave);
|
mal_sine_wave_init(0.2, 400, DEVICE_SAMPLE_RATE, &sineWave);
|
||||||
|
|
||||||
mal_device_config config = mal_device_config_init_playback(DEVICE_FORMAT, DEVICE_CHANNELS, DEVICE_SAMPLE_RATE, on_send_frames_to_device);
|
mal_device_config config = mal_device_config_init_playback(DEVICE_FORMAT, DEVICE_CHANNELS, DEVICE_SAMPLE_RATE, on_send_frames_to_device, &sineWave);
|
||||||
mal_device device;
|
mal_device device;
|
||||||
if (mal_device_init(NULL, mal_device_type_playback, NULL, &config, &sineWave, &device) != MAL_SUCCESS) {
|
if (mal_device_init(NULL, mal_device_type_playback, NULL, &config, &device) != MAL_SUCCESS) {
|
||||||
printf("Failed to open playback device.\n");
|
printf("Failed to open playback device.\n");
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,10 +62,10 @@ Playback Example
|
|||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
mal_device_config config = mal_device_config_init_playback(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, on_send_frames_to_device);
|
mal_device_config config = mal_device_config_init_playback(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, on_send_frames_to_device, &decoder);
|
||||||
|
|
||||||
mal_device device;
|
mal_device device;
|
||||||
mal_result result = mal_device_init(NULL, mal_device_type_playback, NULL, &config, &decoder, &device);
|
mal_result result = mal_device_init(NULL, mal_device_type_playback, NULL, &config, &device);
|
||||||
if (result != MAL_SUCCESS) {
|
if (result != MAL_SUCCESS) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -1492,12 +1492,11 @@ typedef struct
|
|||||||
mal_recv_proc onRecvCallback;
|
mal_recv_proc onRecvCallback;
|
||||||
mal_send_proc onSendCallback;
|
mal_send_proc onSendCallback;
|
||||||
mal_stop_proc onStopCallback;
|
mal_stop_proc onStopCallback;
|
||||||
|
void* pUserData;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
mal_bool32 noMMap; // Disables MMap mode.
|
mal_bool32 noMMap; // Disables MMap mode.
|
||||||
} alsa;
|
} alsa;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
const char* pStreamName;
|
const char* pStreamName;
|
||||||
@@ -2257,13 +2256,13 @@ mal_result mal_context_get_device_info(mal_context* pContext, mal_device_type ty
|
|||||||
// It is not safe to call this function simultaneously for different devices because some backends
|
// It is not safe to call this function simultaneously for different devices because some backends
|
||||||
// depend on and mutate global state (such as OpenSL|ES). The same applies to calling this at the
|
// depend on and mutate global state (such as OpenSL|ES). The same applies to calling this at the
|
||||||
// same time as mal_device_uninit().
|
// same time as mal_device_uninit().
|
||||||
mal_result mal_device_init(mal_context* pContext, mal_device_type type, mal_device_id* pDeviceID, const mal_device_config* pConfig, void* pUserData, mal_device* pDevice);
|
mal_result mal_device_init(mal_context* pContext, mal_device_type type, mal_device_id* pDeviceID, const mal_device_config* pConfig, mal_device* pDevice);
|
||||||
|
|
||||||
// Initializes a device without a context, with extra parameters for controlling the configuration
|
// Initializes a device without a context, with extra parameters for controlling the configuration
|
||||||
// of the internal self-managed context.
|
// of the internal self-managed context.
|
||||||
//
|
//
|
||||||
// See mal_device_init() and mal_context_init().
|
// See mal_device_init() and mal_context_init().
|
||||||
mal_result mal_device_init_ex(const mal_backend backends[], mal_uint32 backendCount, const mal_context_config* pContextConfig, mal_device_type type, mal_device_id* pDeviceID, const mal_device_config* pConfig, void* pUserData, mal_device* pDevice);
|
mal_result mal_device_init_ex(const mal_backend backends[], mal_uint32 backendCount, const mal_context_config* pContextConfig, mal_device_type type, mal_device_id* pDeviceID, const mal_device_config* pConfig, mal_device* pDevice);
|
||||||
|
|
||||||
// Uninitializes a device.
|
// Uninitializes a device.
|
||||||
//
|
//
|
||||||
@@ -2346,9 +2345,9 @@ mal_context_config mal_context_config_init(mal_log_proc onLog);
|
|||||||
//
|
//
|
||||||
// mal_device_config_init(), mal_device_config_init_playback(), etc. will allow you to explicitly set the sample format,
|
// mal_device_config_init(), mal_device_config_init_playback(), etc. will allow you to explicitly set the sample format,
|
||||||
// channel count, etc.
|
// channel count, etc.
|
||||||
mal_device_config mal_device_config_init_default(void);
|
mal_device_config mal_device_config_init_default(void* pUserData);
|
||||||
mal_device_config mal_device_config_init_default_capture(mal_recv_proc onRecvCallback);
|
mal_device_config mal_device_config_init_default_capture(mal_recv_proc onRecvCallback, void* pUserData);
|
||||||
mal_device_config mal_device_config_init_default_playback(mal_send_proc onSendCallback);
|
mal_device_config mal_device_config_init_default_playback(mal_send_proc onSendCallback, void* pUserData);
|
||||||
|
|
||||||
// Helper function for initializing a mal_device_config object.
|
// Helper function for initializing a mal_device_config object.
|
||||||
//
|
//
|
||||||
@@ -2413,18 +2412,18 @@ mal_device_config mal_device_config_init_default_playback(mal_send_proc onSendCa
|
|||||||
//
|
//
|
||||||
// Efficiency: HIGH
|
// Efficiency: HIGH
|
||||||
// This just returns a stack allocated object and consists of just a few assignments.
|
// This just returns a stack allocated object and consists of just a few assignments.
|
||||||
mal_device_config mal_device_config_init_ex(mal_format format, mal_uint32 channels, mal_uint32 sampleRate, mal_channel channelMap[MAL_MAX_CHANNELS], mal_recv_proc onRecvCallback, mal_send_proc onSendCallback);
|
mal_device_config mal_device_config_init_ex(mal_format format, mal_uint32 channels, mal_uint32 sampleRate, mal_channel channelMap[MAL_MAX_CHANNELS], mal_recv_proc onRecvCallback, mal_send_proc onSendCallback, void* pUserData);
|
||||||
|
|
||||||
// A simplified version of mal_device_config_init_ex().
|
// A simplified version of mal_device_config_init_ex().
|
||||||
static MAL_INLINE mal_device_config mal_device_config_init(mal_format format, mal_uint32 channels, mal_uint32 sampleRate, mal_recv_proc onRecvCallback, mal_send_proc onSendCallback) { return mal_device_config_init_ex(format, channels, sampleRate, NULL, onRecvCallback, onSendCallback); }
|
static MAL_INLINE mal_device_config mal_device_config_init(mal_format format, mal_uint32 channels, mal_uint32 sampleRate, mal_recv_proc onRecvCallback, mal_send_proc onSendCallback, void* pUserData) { return mal_device_config_init_ex(format, channels, sampleRate, NULL, onRecvCallback, onSendCallback, pUserData); }
|
||||||
|
|
||||||
// A simplified version of mal_device_config_init() for capture devices.
|
// A simplified version of mal_device_config_init() for capture devices.
|
||||||
static MAL_INLINE mal_device_config mal_device_config_init_capture_ex(mal_format format, mal_uint32 channels, mal_uint32 sampleRate, mal_channel channelMap[MAL_MAX_CHANNELS], mal_recv_proc onRecvCallback) { return mal_device_config_init_ex(format, channels, sampleRate, channelMap, onRecvCallback, NULL); }
|
static MAL_INLINE mal_device_config mal_device_config_init_capture_ex(mal_format format, mal_uint32 channels, mal_uint32 sampleRate, mal_channel channelMap[MAL_MAX_CHANNELS], mal_recv_proc onRecvCallback, void* pUserData) { return mal_device_config_init_ex(format, channels, sampleRate, channelMap, onRecvCallback, NULL, pUserData); }
|
||||||
static MAL_INLINE mal_device_config mal_device_config_init_capture(mal_format format, mal_uint32 channels, mal_uint32 sampleRate, mal_recv_proc onRecvCallback) { return mal_device_config_init_capture_ex(format, channels, sampleRate, NULL, onRecvCallback); }
|
static MAL_INLINE mal_device_config mal_device_config_init_capture(mal_format format, mal_uint32 channels, mal_uint32 sampleRate, mal_recv_proc onRecvCallback, void* pUserData) { return mal_device_config_init_capture_ex(format, channels, sampleRate, NULL, onRecvCallback, pUserData); }
|
||||||
|
|
||||||
// A simplified version of mal_device_config_init() for playback devices.
|
// A simplified version of mal_device_config_init() for playback devices.
|
||||||
static MAL_INLINE mal_device_config mal_device_config_init_playback_ex(mal_format format, mal_uint32 channels, mal_uint32 sampleRate, mal_channel channelMap[MAL_MAX_CHANNELS], mal_send_proc onSendCallback) { return mal_device_config_init_ex(format, channels, sampleRate, channelMap, NULL, onSendCallback); }
|
static MAL_INLINE mal_device_config mal_device_config_init_playback_ex(mal_format format, mal_uint32 channels, mal_uint32 sampleRate, mal_channel channelMap[MAL_MAX_CHANNELS], mal_send_proc onSendCallback, void* pUserData) { return mal_device_config_init_ex(format, channels, sampleRate, channelMap, NULL, onSendCallback, pUserData); }
|
||||||
static MAL_INLINE mal_device_config mal_device_config_init_playback(mal_format format, mal_uint32 channels, mal_uint32 sampleRate, mal_send_proc onSendCallback) { return mal_device_config_init_playback_ex(format, channels, sampleRate, NULL, onSendCallback); }
|
static MAL_INLINE mal_device_config mal_device_config_init_playback(mal_format format, mal_uint32 channels, mal_uint32 sampleRate, mal_send_proc onSendCallback, void* pUserData) { return mal_device_config_init_playback_ex(format, channels, sampleRate, NULL, onSendCallback, pUserData); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -20236,10 +20235,10 @@ mal_result mal_context_get_device_info(mal_context* pContext, mal_device_type ty
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mal_result mal_device_init(mal_context* pContext, mal_device_type type, mal_device_id* pDeviceID, const mal_device_config* pConfig, void* pUserData, mal_device* pDevice)
|
mal_result mal_device_init(mal_context* pContext, mal_device_type type, mal_device_id* pDeviceID, const mal_device_config* pConfig, mal_device* pDevice)
|
||||||
{
|
{
|
||||||
if (pContext == NULL) {
|
if (pContext == NULL) {
|
||||||
return mal_device_init_ex(NULL, 0, NULL, type, pDeviceID, pConfig, pUserData, pDevice);
|
return mal_device_init_ex(NULL, 0, NULL, type, pDeviceID, pConfig, pDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pDevice == NULL) {
|
if (pDevice == NULL) {
|
||||||
@@ -20249,7 +20248,7 @@ mal_result mal_device_init(mal_context* pContext, mal_device_type type, mal_devi
|
|||||||
// The config is allowed to be NULL, in which case we default to mal_device_config_init_default().
|
// The config is allowed to be NULL, in which case we default to mal_device_config_init_default().
|
||||||
mal_device_config config;
|
mal_device_config config;
|
||||||
if (pConfig == NULL) {
|
if (pConfig == NULL) {
|
||||||
config = mal_device_config_init_default();
|
config = mal_device_config_init_default(NULL);
|
||||||
} else {
|
} else {
|
||||||
config = *pConfig;
|
config = *pConfig;
|
||||||
}
|
}
|
||||||
@@ -20268,7 +20267,7 @@ mal_result mal_device_init(mal_context* pContext, mal_device_type type, mal_devi
|
|||||||
pDevice->initConfig = config;
|
pDevice->initConfig = config;
|
||||||
|
|
||||||
// Set the user data and log callback ASAP to ensure it is available for the entire initialization process.
|
// Set the user data and log callback ASAP to ensure it is available for the entire initialization process.
|
||||||
pDevice->pUserData = pUserData;
|
pDevice->pUserData = config.pUserData;
|
||||||
pDevice->onStop = config.onStopCallback;
|
pDevice->onStop = config.onStopCallback;
|
||||||
pDevice->onSend = config.onSendCallback;
|
pDevice->onSend = config.onSendCallback;
|
||||||
pDevice->onRecv = config.onRecvCallback;
|
pDevice->onRecv = config.onRecvCallback;
|
||||||
@@ -20419,7 +20418,7 @@ mal_result mal_device_init(mal_context* pContext, mal_device_type type, mal_devi
|
|||||||
return MAL_SUCCESS;
|
return MAL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
mal_result mal_device_init_ex(const mal_backend backends[], mal_uint32 backendCount, const mal_context_config* pContextConfig, mal_device_type type, mal_device_id* pDeviceID, const mal_device_config* pConfig, void* pUserData, mal_device* pDevice)
|
mal_result mal_device_init_ex(const mal_backend backends[], mal_uint32 backendCount, const mal_context_config* pContextConfig, mal_device_type type, mal_device_id* pDeviceID, const mal_device_config* pConfig, mal_device* pDevice)
|
||||||
{
|
{
|
||||||
mal_context* pContext = (mal_context*)mal_malloc(sizeof(*pContext));
|
mal_context* pContext = (mal_context*)mal_malloc(sizeof(*pContext));
|
||||||
if (pContext == NULL) {
|
if (pContext == NULL) {
|
||||||
@@ -20443,7 +20442,7 @@ mal_result mal_device_init_ex(const mal_backend backends[], mal_uint32 backendCo
|
|||||||
for (mal_uint32 iBackend = 0; iBackend < backendsToIterateCount; ++iBackend) {
|
for (mal_uint32 iBackend = 0; iBackend < backendsToIterateCount; ++iBackend) {
|
||||||
result = mal_context_init(&pBackendsToIterate[iBackend], 1, pContextConfig, pContext);
|
result = mal_context_init(&pBackendsToIterate[iBackend], 1, pContextConfig, pContext);
|
||||||
if (result == MAL_SUCCESS) {
|
if (result == MAL_SUCCESS) {
|
||||||
result = mal_device_init(pContext, type, pDeviceID, pConfig, pUserData, pDevice);
|
result = mal_device_init(pContext, type, pDeviceID, pConfig, pDevice);
|
||||||
if (result == MAL_SUCCESS) {
|
if (result == MAL_SUCCESS) {
|
||||||
break; // Success.
|
break; // Success.
|
||||||
} else {
|
} else {
|
||||||
@@ -20608,34 +20607,35 @@ mal_context_config mal_context_config_init(mal_log_proc onLog)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mal_device_config mal_device_config_init_default()
|
mal_device_config mal_device_config_init_default(void* pUserData)
|
||||||
{
|
{
|
||||||
mal_device_config config;
|
mal_device_config config;
|
||||||
mal_zero_object(&config);
|
mal_zero_object(&config);
|
||||||
|
config.pUserData = pUserData;
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
mal_device_config mal_device_config_init_default_capture(mal_recv_proc onRecvCallback)
|
mal_device_config mal_device_config_init_default_capture(mal_recv_proc onRecvCallback, void* pUserData)
|
||||||
{
|
{
|
||||||
mal_device_config config = mal_device_config_init_default();
|
mal_device_config config = mal_device_config_init_default(pUserData);
|
||||||
config.onRecvCallback = onRecvCallback;
|
config.onRecvCallback = onRecvCallback;
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
mal_device_config mal_device_config_init_default_playback(mal_send_proc onSendCallback)
|
mal_device_config mal_device_config_init_default_playback(mal_send_proc onSendCallback, void* pUserData)
|
||||||
{
|
{
|
||||||
mal_device_config config = mal_device_config_init_default();
|
mal_device_config config = mal_device_config_init_default(pUserData);
|
||||||
config.onSendCallback = onSendCallback;
|
config.onSendCallback = onSendCallback;
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mal_device_config mal_device_config_init_ex(mal_format format, mal_uint32 channels, mal_uint32 sampleRate, mal_channel channelMap[MAL_MAX_CHANNELS], mal_recv_proc onRecvCallback, mal_send_proc onSendCallback)
|
mal_device_config mal_device_config_init_ex(mal_format format, mal_uint32 channels, mal_uint32 sampleRate, mal_channel channelMap[MAL_MAX_CHANNELS], mal_recv_proc onRecvCallback, mal_send_proc onSendCallback, void* pUserData)
|
||||||
{
|
{
|
||||||
mal_device_config config = mal_device_config_init_default();
|
mal_device_config config = mal_device_config_init_default(pUserData);
|
||||||
|
|
||||||
config.format = format;
|
config.format = format;
|
||||||
config.channels = channels;
|
config.channels = channels;
|
||||||
|
|||||||
@@ -52,12 +52,12 @@ mal_uint32 on_send_to_device__dithered(mal_device* pDevice, mal_uint32 frameCoun
|
|||||||
|
|
||||||
int do_dithering_test()
|
int do_dithering_test()
|
||||||
{
|
{
|
||||||
mal_device_config config = mal_device_config_init_playback(mal_format_f32, 1, 0, on_send_to_device__original);
|
mal_device_config config = mal_device_config_init_playback(mal_format_f32, 1, 0, on_send_to_device__original, NULL);
|
||||||
mal_device device;
|
mal_device device;
|
||||||
mal_result result;
|
mal_result result;
|
||||||
|
|
||||||
// We first play the sound the way it's meant to be played.
|
// We first play the sound the way it's meant to be played.
|
||||||
result = mal_device_init(NULL, mal_device_type_playback, NULL, &config, NULL, &device);
|
result = mal_device_init(NULL, mal_device_type_playback, NULL, &config, &device);
|
||||||
if (result != MAL_SUCCESS) {
|
if (result != MAL_SUCCESS) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -102,9 +102,9 @@ int do_dithering_test()
|
|||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
config = mal_device_config_init_playback(converterOutConfig.formatOut, 1, 0, on_send_to_device__dithered);
|
config = mal_device_config_init_playback(converterOutConfig.formatOut, 1, 0, on_send_to_device__dithered, &converterOut);
|
||||||
|
|
||||||
result = mal_device_init(NULL, mal_device_type_playback, NULL, &config, &converterOut, &device);
|
result = mal_device_init(NULL, mal_device_type_playback, NULL, &config, &device);
|
||||||
if (result != MAL_SUCCESS) {
|
if (result != MAL_SUCCESS) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -2289,14 +2289,14 @@ int do_playback_test(mal_backend backend)
|
|||||||
printf(" Opening Device... ");
|
printf(" Opening Device... ");
|
||||||
{
|
{
|
||||||
mal_context_config contextConfig = mal_context_config_init(on_log);
|
mal_context_config contextConfig = mal_context_config_init(on_log);
|
||||||
mal_device_config deviceConfig = mal_device_config_init_default_playback(on_send__playback_test);
|
mal_device_config deviceConfig = mal_device_config_init_default_playback(on_send__playback_test, &callbackData);
|
||||||
deviceConfig.onStopCallback = on_stop__playback_test;
|
deviceConfig.onStopCallback = on_stop__playback_test;
|
||||||
|
|
||||||
#if defined(__EMSCRIPTEN__)
|
#if defined(__EMSCRIPTEN__)
|
||||||
deviceConfig.format = mal_format_f32;
|
deviceConfig.format = mal_format_f32;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
result = mal_device_init_ex(&backend, 1, &contextConfig, mal_device_type_playback, NULL, &deviceConfig, &callbackData, &device);
|
result = mal_device_init_ex(&backend, 1, &contextConfig, mal_device_type_playback, NULL, &deviceConfig, &device);
|
||||||
if (result == MAL_SUCCESS) {
|
if (result == MAL_SUCCESS) {
|
||||||
printf("Done\n");
|
printf("Done\n");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user