From d3153c28f0b82ca047a892f6dbcd9d5f9344e3d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sat, 17 Aug 2019 13:04:33 +0200 Subject: Replace last occurrences of 'ERR_EXPLAIN' with 'ERR_FAIL_*_MSG' The last remaining ERR_EXPLAIN call is in FreeType code and makes sense as is (conditionally defines the error message). There are a few ERR_EXPLAINC calls for C-strings where String is not included which can stay as is to avoid adding additional _MSGC macros just for that. Part of #31244. --- drivers/xaudio2/audio_driver_xaudio2.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'drivers/xaudio2') diff --git a/drivers/xaudio2/audio_driver_xaudio2.cpp b/drivers/xaudio2/audio_driver_xaudio2.cpp index 8674d24af6..6d729c50ab 100644 --- a/drivers/xaudio2/audio_driver_xaudio2.cpp +++ b/drivers/xaudio2/audio_driver_xaudio2.cpp @@ -63,15 +63,10 @@ Error AudioDriverXAudio2::init() { HRESULT hr; hr = XAudio2Create(&xaudio, 0, XAUDIO2_DEFAULT_PROCESSOR); - if (hr != S_OK) { - ERR_EXPLAIN("Error creating XAudio2 engine."); - ERR_FAIL_V(ERR_UNAVAILABLE); - } + ERR_FAIL_COND_V_MSG(hr != S_OK, ERR_UNAVAILABLE, "Error creating XAudio2 engine."); + hr = xaudio->CreateMasteringVoice(&mastering_voice); - if (hr != S_OK) { - ERR_EXPLAIN("Error creating XAudio2 mastering voice."); - ERR_FAIL_V(ERR_UNAVAILABLE); - } + ERR_FAIL_COND_V_MSG(hr != S_OK, ERR_UNAVAILABLE, "Error creating XAudio2 mastering voice."); wave_format.nChannels = channels; wave_format.cbSize = 0; @@ -82,10 +77,7 @@ Error AudioDriverXAudio2::init() { wave_format.nAvgBytesPerSec = mix_rate * wave_format.nBlockAlign; hr = xaudio->CreateSourceVoice(&source_voice, &wave_format, 0, XAUDIO2_MAX_FREQ_RATIO, &voice_callback); - if (hr != S_OK) { - ERR_EXPLAIN("Error creating XAudio2 source voice. " + itos(hr)); - ERR_FAIL_V(ERR_UNAVAILABLE); - } + ERR_FAIL_COND_V_MSG(hr != S_OK, ERR_UNAVAILABLE, "Error creating XAudio2 source voice. Error code: " + itos(hr) + "."); mutex = Mutex::create(); thread = Thread::create(AudioDriverXAudio2::thread_func, this); @@ -140,10 +132,7 @@ void AudioDriverXAudio2::start() { active = true; HRESULT hr = source_voice->Start(0); - if (hr != S_OK) { - ERR_EXPLAIN("XAudio2 start error " + itos(hr)); - ERR_FAIL(); - } + ERR_FAIL_COND_MSG(hr != S_OK, "Error starting XAudio2 driver. Error code: " + itos(hr) + "."); } int AudioDriverXAudio2::get_mix_rate() const { -- cgit v1.2.3