diff options
author | Chris Robinson <[email protected]> | 2019-10-08 05:44:38 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-10-08 05:44:38 -0700 |
commit | 7726a06d26e59dc6a8e109af2e268de878c4f606 (patch) | |
tree | 3fdea7f120e21def8e52b89d335f63aa38372497 /alc/backends/sdl2.cpp | |
parent | 360330b2add6cf10776c38aaa186b0892b54e300 (diff) |
Clean up some exception messages and avoid duplicate log messages
Diffstat (limited to 'alc/backends/sdl2.cpp')
-rw-r--r-- | alc/backends/sdl2.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/alc/backends/sdl2.cpp b/alc/backends/sdl2.cpp index 1063ca7a..4cdf05b4 100644 --- a/alc/backends/sdl2.cpp +++ b/alc/backends/sdl2.cpp @@ -52,8 +52,9 @@ struct Sdl2Backend final : public BackendBase { Sdl2Backend(ALCdevice *device) noexcept : BackendBase{device} { } ~Sdl2Backend() override; - static void audioCallbackC(void *ptr, Uint8 *stream, int len); void audioCallback(Uint8 *stream, int len); + static void audioCallbackC(void *ptr, Uint8 *stream, int len) + { static_cast<Sdl2Backend*>(ptr)->audioCallback(stream, len); } void open(const ALCchar *name) override; bool reset() override; @@ -80,9 +81,6 @@ Sdl2Backend::~Sdl2Backend() mDeviceID = 0; } -void Sdl2Backend::audioCallbackC(void *ptr, Uint8 *stream, int len) -{ static_cast<Sdl2Backend*>(ptr)->audioCallback(stream, len); } - void Sdl2Backend::audioCallback(Uint8 *stream, int len) { const auto ulen = static_cast<unsigned int>(len); @@ -130,16 +128,15 @@ void Sdl2Backend::open(const ALCchar *name) throw al::backend_exception{ALC_INVALID_VALUE, "%s", SDL_GetError()}; mDevice->Frequency = static_cast<ALuint>(have.freq); + if(have.channels == 1) mDevice->FmtChans = DevFmtMono; else if(have.channels == 2) mDevice->FmtChans = DevFmtStereo; else - { - ERR("Got unhandled SDL channel count: %d\n", int{have.channels}); throw al::backend_exception{ALC_INVALID_VALUE, "Unhandled SDL channel count: %d", int{have.channels}}; - } + switch(have.format) { case AUDIO_U8: mDevice->FmtType = DevFmtUByte; break; @@ -149,7 +146,6 @@ void Sdl2Backend::open(const ALCchar *name) case AUDIO_S32SYS: mDevice->FmtType = DevFmtInt; break; case AUDIO_F32SYS: mDevice->FmtType = DevFmtFloat; break; default: - ERR("Got unsupported SDL format: 0x%04x\n", have.format); throw al::backend_exception{ALC_INVALID_VALUE, "Unhandled SDL format: 0x%04x", have.format}; } |