Add context initialisation to miniaudio backend
This is used for mutexes in the enhanced backend
This commit is contained in:
parent
bf8d824b70
commit
8e2d8ab962
1 changed files with 27 additions and 14 deletions
|
@ -82,52 +82,63 @@ bool AudioBackend_Init(void)
|
|||
|
||||
ma_result return_value;
|
||||
|
||||
return_value = ma_device_init(NULL, &config, &device);
|
||||
return_value = ma_context_init(NULL, 0, NULL, &context);
|
||||
|
||||
if (return_value == MA_SUCCESS)
|
||||
{
|
||||
return_value = ma_mutex_init(device.pContext, &mutex);
|
||||
return_value = ma_device_init(&context, &config, &device);
|
||||
|
||||
if (return_value == MA_SUCCESS)
|
||||
{
|
||||
return_value = ma_mutex_init(device.pContext, &organya_mutex);
|
||||
return_value = ma_mutex_init(device.pContext, &mutex);
|
||||
|
||||
if (return_value == MA_SUCCESS)
|
||||
{
|
||||
return_value = ma_device_start(&device);
|
||||
return_value = ma_mutex_init(device.pContext, &organya_mutex);
|
||||
|
||||
if (return_value == MA_SUCCESS)
|
||||
{
|
||||
output_frequency = device.sampleRate;
|
||||
return_value = ma_device_start(&device);
|
||||
|
||||
Mixer_Init(device.sampleRate);
|
||||
if (return_value == MA_SUCCESS)
|
||||
{
|
||||
output_frequency = device.sampleRate;
|
||||
|
||||
return true;
|
||||
Mixer_Init(device.sampleRate);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Backend_PrintError("Failed to start playback device: %s", ma_result_description(return_value));
|
||||
}
|
||||
|
||||
ma_mutex_uninit(&organya_mutex);
|
||||
}
|
||||
else
|
||||
{
|
||||
Backend_PrintError("Failed to start playback device: %s", ma_result_description(return_value));
|
||||
Backend_PrintError("Failed to create organya mutex: %s", ma_result_description(return_value));
|
||||
}
|
||||
|
||||
ma_mutex_uninit(&organya_mutex);
|
||||
ma_mutex_uninit(&mutex);
|
||||
}
|
||||
else
|
||||
{
|
||||
Backend_PrintError("Failed to create organya mutex: %s", ma_result_description(return_value));
|
||||
Backend_PrintError("Failed to create mutex: %s", ma_result_description(return_value));
|
||||
}
|
||||
|
||||
ma_mutex_uninit(&mutex);
|
||||
ma_device_uninit(&device);
|
||||
}
|
||||
else
|
||||
{
|
||||
Backend_PrintError("Failed to create mutex: %s", ma_result_description(return_value));
|
||||
Backend_PrintError("Failed to initialize playback device: %s", ma_result_description(return_value));
|
||||
}
|
||||
|
||||
ma_device_uninit(&device);
|
||||
ma_context_uninit(&context);
|
||||
}
|
||||
else
|
||||
{
|
||||
Backend_PrintError("Failed to initialize playback device: %s", ma_result_description(return_value));
|
||||
Backend_PrintError("Failed to initialize context: %s", ma_result_description(return_value));
|
||||
}
|
||||
|
||||
|
||||
|
@ -146,6 +157,8 @@ void AudioBackend_Deinit(void)
|
|||
ma_mutex_uninit(&mutex);
|
||||
|
||||
ma_device_uninit(&device);
|
||||
|
||||
ma_context_uninit(&context);
|
||||
}
|
||||
|
||||
AudioBackend_Sound* AudioBackend_CreateSound(unsigned int frequency, const unsigned char *samples, size_t length)
|
||||
|
|
Loading…
Add table
Reference in a new issue