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 | |
parent | 360330b2add6cf10776c38aaa186b0892b54e300 (diff) |
Clean up some exception messages and avoid duplicate log messages
-rw-r--r-- | alc/backends/alsa.cpp | 16 | ||||
-rw-r--r-- | alc/backends/coreaudio.cpp | 54 | ||||
-rw-r--r-- | alc/backends/dsound.cpp | 5 | ||||
-rw-r--r-- | alc/backends/jack.cpp | 6 | ||||
-rw-r--r-- | alc/backends/opensl.cpp | 12 | ||||
-rw-r--r-- | alc/backends/oss.cpp | 46 | ||||
-rw-r--r-- | alc/backends/portaudio.cpp | 5 | ||||
-rw-r--r-- | alc/backends/pulseaudio.cpp | 2 | ||||
-rw-r--r-- | alc/backends/sdl2.cpp | 12 | ||||
-rw-r--r-- | alc/backends/sndio.cpp | 47 | ||||
-rw-r--r-- | alc/backends/solaris.cpp | 3 | ||||
-rw-r--r-- | alc/backends/wasapi.cpp | 2 | ||||
-rw-r--r-- | alc/backends/wave.cpp | 3 | ||||
-rw-r--r-- | alc/backends/winmm.cpp | 17 |
14 files changed, 46 insertions, 184 deletions
diff --git a/alc/backends/alsa.cpp b/alc/backends/alsa.cpp index a9eb6d5f..7c6ce4f9 100644 --- a/alc/backends/alsa.cpp +++ b/alc/backends/alsa.cpp @@ -616,11 +616,8 @@ void AlsaPlayback::open(const ALCchar *name) TRACE("Opening device \"%s\"\n", driver); int err{snd_pcm_open(&mPcmHandle, driver, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)}; if(err < 0) - { - ERR("Could not open playback device '%s': %s\n", driver, snd_strerror(err)); - throw al::backend_exception{ALC_OUT_OF_MEMORY, "Could not open ALSA playback \"%s\"", + throw al::backend_exception{ALC_OUT_OF_MEMORY, "Could not open ALSA device \"%s\"", driver}; - } /* Free alsa's global config tree. Otherwise valgrind reports a ton of leaks. */ snd_config_update_free_global(); @@ -917,11 +914,8 @@ void AlsaCapture::open(const ALCchar *name) TRACE("Opening device \"%s\"\n", driver); int err{snd_pcm_open(&mPcmHandle, driver, SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK)}; if(err < 0) - { - ERR("Could not open capture device '%s': %s\n", driver, snd_strerror(err)); - throw al::backend_exception{ALC_OUT_OF_MEMORY, "Could not open ALSA capture \"%s\"", + throw al::backend_exception{ALC_OUT_OF_MEMORY, "Could not open ALSA device \"%s\"", driver}; - } /* Free alsa's global config tree. Otherwise valgrind reports a ton of leaks. */ snd_config_update_free_global(); @@ -989,11 +983,7 @@ void AlsaCapture::open(const ALCchar *name) if(needring) { mRing = CreateRingBuffer(mDevice->BufferSize, mDevice->frameSizeFromFmt(), false); - if(!mRing) - { - ERR("ring buffer create failed\n"); - throw al::backend_exception{ALC_INVALID_VALUE, "Failed to create ring buffer"}; - } + if(!mRing) throw al::backend_exception{ALC_INVALID_VALUE, "Failed to create ring buffer"}; } mDevice->DeviceName = name; diff --git a/alc/backends/coreaudio.cpp b/alc/backends/coreaudio.cpp index 3a97c105..9e1d4e47 100644 --- a/alc/backends/coreaudio.cpp +++ b/alc/backends/coreaudio.cpp @@ -108,26 +108,17 @@ void CoreAudioPlayback::open(const ALCchar *name) AudioComponent comp{AudioComponentFindNext(NULL, &desc)}; if(comp == nullptr) - { - ERR("AudioComponentFindNext failed\n"); throw al::backend_exception{ALC_INVALID_VALUE, "Could not find audio component"}; - } OSStatus err{AudioComponentInstanceNew(comp, &mAudioUnit)}; if(err != noErr) - { - ERR("AudioComponentInstanceNew failed\n"); throw al::backend_exception{ALC_INVALID_VALUE, "Could not create component instance: %u", err}; - } /* init and start the default audio unit... */ err = AudioUnitInitialize(mAudioUnit); if(err != noErr) - { - ERR("AudioUnitInitialize failed\n"); throw al::backend_exception{ALC_INVALID_VALUE, "Could not initialize audio unit: %u", err}; - } mDevice->DeviceName = name; } @@ -418,41 +409,29 @@ void CoreAudioCapture::open(const ALCchar *name) // Search for component with given description comp = AudioComponentFindNext(NULL, &desc); if(comp == NULL) - { - ERR("AudioComponentFindNext failed\n"); - throw al::backend_exception{ALC_INVALID_VALUE, "Could not finda udio component"}; - } + throw al::backend_exception{ALC_INVALID_VALUE, "Could not find audio component"}; // Open the component err = AudioComponentInstanceNew(comp, &mAudioUnit); if(err != noErr) - { - ERR("AudioComponentInstanceNew failed\n"); throw al::backend_exception{ALC_INVALID_VALUE, "Could not create component instance: %u", err}; - } // Turn off AudioUnit output enableIO = 0; err = AudioUnitSetProperty(mAudioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, 0, &enableIO, sizeof(ALuint)); if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); throw al::backend_exception{ALC_INVALID_VALUE, "Could not disable audio unit output property: %u", err}; - } // Turn on AudioUnit input enableIO = 1; err = AudioUnitSetProperty(mAudioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, 1, &enableIO, sizeof(ALuint)); if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); throw al::backend_exception{ALC_INVALID_VALUE, "Could not enable audio unit input property: %u", err}; - } #if !TARGET_OS_IOS { @@ -467,24 +446,15 @@ void CoreAudioCapture::open(const ALCchar *name) err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, nullptr, &propertySize, &inputDevice); if(err != noErr) - { - ERR("AudioObjectGetPropertyData failed\n"); throw al::backend_exception{ALC_INVALID_VALUE, "Could not get input device: %u", err}; - } if(inputDevice == kAudioDeviceUnknown) - { - ERR("No input device found\n"); throw al::backend_exception{ALC_INVALID_VALUE, "Unknown input device"}; - } // Track the input device err = AudioUnitSetProperty(mAudioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &inputDevice, sizeof(AudioDeviceID)); if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); throw al::backend_exception{ALC_INVALID_VALUE, "Could not set input device: %u", err}; - } } #endif @@ -495,28 +465,19 @@ void CoreAudioCapture::open(const ALCchar *name) err = AudioUnitSetProperty(mAudioUnit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, 0, &input, sizeof(AURenderCallbackStruct)); if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); throw al::backend_exception{ALC_INVALID_VALUE, "Could not set capture callback: %u", err}; - } // Initialize the device err = AudioUnitInitialize(mAudioUnit); if(err != noErr) - { - ERR("AudioUnitInitialize failed\n"); throw al::backend_exception{ALC_INVALID_VALUE, "Could not initialize audio unit: %u", err}; - } // Get the hardware format propertySize = sizeof(AudioStreamBasicDescription); err = AudioUnitGetProperty(mAudioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 1, &hardwareFormat, &propertySize); if(err != noErr || propertySize != sizeof(AudioStreamBasicDescription)) - { - ERR("AudioUnitGetProperty failed\n"); throw al::backend_exception{ALC_INVALID_VALUE, "Could not get input format: %u", err}; - } // Set up the requested format description switch(mDevice->FmtType) @@ -540,7 +501,6 @@ void CoreAudioCapture::open(const ALCchar *name) case DevFmtByte: case DevFmtUShort: case DevFmtUInt: - ERR("%s samples not supported\n", DevFmtTypeString(mDevice->FmtType)); throw al::backend_exception{ALC_INVALID_VALUE, "%s samples not suppoted", DevFmtTypeString(mDevice->FmtType)}; } @@ -560,7 +520,6 @@ void CoreAudioCapture::open(const ALCchar *name) case DevFmtX61: case DevFmtX71: case DevFmtAmbi3D: - ERR("%s not supported\n", DevFmtChannelsString(mDevice->FmtChans)); throw al::backend_exception{ALC_INVALID_VALUE, "%s not supported", DevFmtChannelsString(mDevice->FmtChans)}; } @@ -586,10 +545,7 @@ void CoreAudioCapture::open(const ALCchar *name) err = AudioUnitSetProperty(mAudioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 1, &outputFormat, sizeof(outputFormat)); if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); throw al::backend_exception{ALC_INVALID_VALUE, "Could not set input format: %u", err}; - } // Set the AudioUnit output format frame count uint64_t FrameCount64{mDevice->UpdateSize}; @@ -597,21 +553,15 @@ void CoreAudioCapture::open(const ALCchar *name) mDevice->Frequency; FrameCount64 += MAX_RESAMPLER_PADDING; if(FrameCount64 > std::numeric_limits<uint32_t>::max()/2) - { - ERR("FrameCount too large\n"); throw al::backend_exception{ALC_INVALID_VALUE, - "Calculated frame count is too lareg: %" PRIu64, FrameCount64}; - } + "Calculated frame count is too large: %" PRIu64, FrameCount64}; outputFrameCount = static_cast<uint32_t>(FrameCount64); err = AudioUnitSetProperty(mAudioUnit, kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Output, 0, &outputFrameCount, sizeof(outputFrameCount)); if(err != noErr) - { - ERR("AudioUnitSetProperty failed: %d\n", err); throw al::backend_exception{ALC_INVALID_VALUE, "Failed to set capture frame count: %u", err}; - } // Set up sample converter if needed if(outputFormat.mSampleRate != mDevice->Frequency) diff --git a/alc/backends/dsound.cpp b/alc/backends/dsound.cpp index d48b74e2..005c9584 100644 --- a/alc/backends/dsound.cpp +++ b/alc/backends/dsound.cpp @@ -341,10 +341,7 @@ void DSoundPlayback::open(const ALCchar *name) if(SUCCEEDED(hr)) hr = mDS->SetCooperativeLevel(GetForegroundWindow(), DSSCL_PRIORITY); if(FAILED(hr)) - { - ERR("Device init failed: 0x%08lx\n", hr); throw al::backend_exception{ALC_INVALID_VALUE, "Device init failed: 0x%08lx", hr}; - } mDevice->DeviceName = name; } @@ -753,8 +750,6 @@ void DSoundCapture::open(const ALCchar *name) if(FAILED(hr)) { - ERR("Device init failed: 0x%08lx\n", hr); - mRing = nullptr; if(mDSCbuffer) mDSCbuffer->Release(); diff --git a/alc/backends/jack.cpp b/alc/backends/jack.cpp index 7c3f1822..2a22ed84 100644 --- a/alc/backends/jack.cpp +++ b/alc/backends/jack.cpp @@ -336,11 +336,9 @@ void JackPlayback::open(const ALCchar *name) jack_status_t status; mClient = jack_client_open(client_name, ClientOptions, &status, nullptr); if(mClient == nullptr) - { - ERR("jack_client_open() failed, status = 0x%02x\n", status); - throw al::backend_exception{ALC_INVALID_VALUE, "Failed to connect to JACK server: 0x%02x", + throw al::backend_exception{ALC_INVALID_VALUE, "Failed to open client connection: 0x%02x", status}; - } + if((status&JackServerStarted)) TRACE("JACK server started\n"); if((status&JackNameNotUnique)) diff --git a/alc/backends/opensl.cpp b/alc/backends/opensl.cpp index f546f168..4e68da27 100644 --- a/alc/backends/opensl.cpp +++ b/alc/backends/opensl.cpp @@ -146,9 +146,9 @@ struct OpenSLPlayback final : public BackendBase { OpenSLPlayback(ALCdevice *device) noexcept : BackendBase{device} { } ~OpenSLPlayback() override; + void process(SLAndroidSimpleBufferQueueItf bq); static void processC(SLAndroidSimpleBufferQueueItf bq, void *context) { static_cast<OpenSLPlayback*>(context)->process(bq); } - void process(SLAndroidSimpleBufferQueueItf bq); int mixerProc(); @@ -339,8 +339,8 @@ void OpenSLPlayback::open(const ALCchar *name) mEngineObj = nullptr; mEngine = nullptr; - throw al::backend_exception{ALC_INVALID_VALUE, "Failed to initialize OpenSL: 0x%08x", - result}; + throw al::backend_exception{ALC_INVALID_VALUE, + "Failed to initialize OpenSL device: 0x%08x", result}; } mDevice->DeviceName = name; @@ -629,9 +629,9 @@ struct OpenSLCapture final : public BackendBase { OpenSLCapture(ALCdevice *device) noexcept : BackendBase{device} { } ~OpenSLCapture() override; + void process(SLAndroidSimpleBufferQueueItf bq); static void processC(SLAndroidSimpleBufferQueueItf bq, void *context) { static_cast<OpenSLCapture*>(context)->process(bq); } - void process(SLAndroidSimpleBufferQueueItf bq); void open(const ALCchar *name) override; bool start() override; @@ -839,8 +839,8 @@ void OpenSLCapture::open(const ALCchar* name) mEngineObj = nullptr; mEngine = nullptr; - throw al::backend_exception{ALC_INVALID_VALUE, "Failed to initialize OpenSL: 0x%08x", - result}; + throw al::backend_exception{ALC_INVALID_VALUE, + "Failed to initialize OpenSL device: 0x%08x", result}; } mDevice->DeviceName = name; diff --git a/alc/backends/oss.cpp b/alc/backends/oss.cpp index 5ab07dbe..856aceb0 100644 --- a/alc/backends/oss.cpp +++ b/alc/backends/oss.cpp @@ -350,11 +350,8 @@ void OSSPlayback::open(const ALCchar *name) mFd = ::open(devname, O_WRONLY); if(mFd == -1) - { - ERR("Could not open %s: %s\n", devname, strerror(errno)); throw al::backend_exception{ALC_INVALID_VALUE, "Could not open %s: %s", devname, strerror(errno)}; - } mDevice->DeviceName = name; } @@ -560,11 +557,8 @@ void OSScapture::open(const ALCchar *name) mFd = ::open(devname, O_RDONLY); if(mFd == -1) - { - ERR("Could not open %s: %s\n", devname, strerror(errno)); throw al::backend_exception{ALC_INVALID_VALUE, "Could not open %s: %s", devname, strerror(errno)}; - } int ossFormat{}; switch(mDevice->FmtType) @@ -582,7 +576,6 @@ void OSScapture::open(const ALCchar *name) case DevFmtInt: case DevFmtUInt: case DevFmtFloat: - ERR("%s capture samples not supported\n", DevFmtTypeString(mDevice->FmtType)); throw al::backend_exception{ALC_INVALID_VALUE, "%s capture samples not supported", DevFmtTypeString(mDevice->FmtType)}; } @@ -596,47 +589,30 @@ void OSScapture::open(const ALCchar *name) ALuint numFragmentsLogSize{(periods << 16) | log2FragmentSize}; audio_buf_info info{}; - const char *err; #define CHECKERR(func) if((func) < 0) { \ - err = #func; \ - goto err; \ + throw al::backend_exception{ALC_INVALID_VALUE, #func " failed: %s", strerror(errno)}; \ } CHECKERR(ioctl(mFd, SNDCTL_DSP_SETFRAGMENT, &numFragmentsLogSize)); CHECKERR(ioctl(mFd, SNDCTL_DSP_SETFMT, &ossFormat)); CHECKERR(ioctl(mFd, SNDCTL_DSP_CHANNELS, &numChannels)); CHECKERR(ioctl(mFd, SNDCTL_DSP_SPEED, &ossSpeed)); CHECKERR(ioctl(mFd, SNDCTL_DSP_GETISPACE, &info)); - if(0) - { - err: - ERR("%s failed: %s\n", err, strerror(errno)); - throw al::backend_exception{ALC_INVALID_VALUE, "%s failed: %s", err, strerror(errno)}; - } #undef CHECKERR if(mDevice->channelsFromFmt() != numChannels) - { - ERR("Failed to set %s, got %d channels instead\n", DevFmtChannelsString(mDevice->FmtChans), - numChannels); - throw al::backend_exception{ALC_INVALID_VALUE, "Failed to set %s capture", - DevFmtChannelsString(mDevice->FmtChans)}; - } + throw al::backend_exception{ALC_INVALID_VALUE, + "Failed to set %s, got %d channels instead", DevFmtChannelsString(mDevice->FmtChans), + numChannels}; - if(!((ossFormat == AFMT_S8 && mDevice->FmtType == DevFmtByte) || - (ossFormat == AFMT_U8 && mDevice->FmtType == DevFmtUByte) || - (ossFormat == AFMT_S16_NE && mDevice->FmtType == DevFmtShort))) - { - ERR("Failed to set %s samples, got OSS format %#x\n", DevFmtTypeString(mDevice->FmtType), ossFormat); - throw al::backend_exception{ALC_INVALID_VALUE, "Failed to set %s samples", - DevFmtTypeString(mDevice->FmtType)}; - } + if(!((ossFormat == AFMT_S8 && mDevice->FmtType == DevFmtByte) + || (ossFormat == AFMT_U8 && mDevice->FmtType == DevFmtUByte) + || (ossFormat == AFMT_S16_NE && mDevice->FmtType == DevFmtShort))) + throw al::backend_exception{ALC_INVALID_VALUE, + "Failed to set %s samples, got OSS format %#x", DevFmtTypeString(mDevice->FmtType), + ossFormat}; mRing = CreateRingBuffer(mDevice->BufferSize, frameSize, false); - if(!mRing) - { - ERR("Ring buffer create failed\n"); - throw al::backend_exception{ALC_INVALID_VALUE, "Failed to create ring buffer"}; - } + if(!mRing) throw al::backend_exception{ALC_INVALID_VALUE, "Failed to create ring buffer"}; mDevice->DeviceName = name; } diff --git a/alc/backends/portaudio.cpp b/alc/backends/portaudio.cpp index ba8e4984..7c60d2bb 100644 --- a/alc/backends/portaudio.cpp +++ b/alc/backends/portaudio.cpp @@ -166,7 +166,6 @@ retry_open: mParams.sampleFormat = paInt16; goto retry_open; } - ERR("Pa_OpenStream() returned an error: %s\n", Pa_GetErrorText(err)); throw al::backend_exception{ALC_INVALID_VALUE, "Failed to open stream: %s", Pa_GetErrorText(err)}; } @@ -314,7 +313,6 @@ void PortCapture::open(const ALCchar *name) break; case DevFmtUInt: case DevFmtUShort: - ERR("%s samples not supported\n", DevFmtTypeString(mDevice->FmtType)); throw al::backend_exception{ALC_INVALID_VALUE, "%s samples not supported", DevFmtTypeString(mDevice->FmtType)}; } @@ -323,11 +321,8 @@ void PortCapture::open(const ALCchar *name) PaError err{Pa_OpenStream(&mStream, &mParams, nullptr, mDevice->Frequency, paFramesPerBufferUnspecified, paNoFlag, &PortCapture::readCallbackC, this)}; if(err != paNoError) - { - ERR("Pa_OpenStream() returned an error: %s\n", Pa_GetErrorText(err)); throw al::backend_exception{ALC_INVALID_VALUE, "Failed to open stream: %s", Pa_GetErrorText(err)}; - } mDevice->DeviceName = name; } diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp index e4b1baa2..2521084d 100644 --- a/alc/backends/pulseaudio.cpp +++ b/alc/backends/pulseaudio.cpp @@ -1211,7 +1211,7 @@ void PulseCapture::open(const ALCchar *name) chanmap = X71ChanMap; break; case DevFmtAmbi3D: - throw al::backend_exception{ALC_INVALID_VALUE, "%s capture samples not supported", + throw al::backend_exception{ALC_INVALID_VALUE, "%s capture not supported", DevFmtChannelsString(mDevice->FmtChans)}; } SetChannelOrderFromMap(mDevice, chanmap); 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}; } diff --git a/alc/backends/sndio.cpp b/alc/backends/sndio.cpp index 5657a241..026ff2b9 100644 --- a/alc/backends/sndio.cpp +++ b/alc/backends/sndio.cpp @@ -117,10 +117,7 @@ void SndioPlayback::open(const ALCchar *name) mSndHandle = sio_open(nullptr, SIO_PLAY, 0); if(mSndHandle == nullptr) - { - ERR("Could not open device\n"); - throw al::backend_exception{ALC_INVALID_VALUE, "Could not open sound device"}; - } + throw al::backend_exception{ALC_INVALID_VALUE, "Could not open backend device"}; mDevice->DeviceName = name; } @@ -329,10 +326,7 @@ void SndioCapture::open(const ALCchar *name) mSndHandle = sio_open(nullptr, SIO_REC, 0); if(mSndHandle == nullptr) - { - ERR("Could not open device\n"); - throw al::backend_exception{ALC_INVALID_VALUE, "Could not open sound device"}; - } + throw al::backend_exception{ALC_INVALID_VALUE, "Could not open backend device"}; sio_par par; sio_initpar(&par); @@ -364,7 +358,6 @@ void SndioCapture::open(const ALCchar *name) par.sig = 0; break; case DevFmtFloat: - ERR("%s capture samples not supported\n", DevFmtTypeString(mDevice->FmtType)); throw al::backend_exception{ALC_INVALID_VALUE, "%s capture samples not supported", DevFmtTypeString(mDevice->FmtType)}; } @@ -381,40 +374,26 @@ void SndioCapture::open(const ALCchar *name) mDevice->BufferSize = par.appbufsz; if(!sio_setpar(mSndHandle, &par) || !sio_getpar(mSndHandle, &par)) - { - ERR("Failed to set device parameters\n"); throw al::backend_exception{ALC_INVALID_VALUE, "Failed to set device praameters"}; - } if(par.bits != par.bps*8) - { - ERR("Padded samples not supported (%u of %u bits)\n", par.bits, par.bps*8); throw al::backend_exception{ALC_INVALID_VALUE, "Padded samples not supported (got %u of %u bits)", par.bits, par.bps*8}; - } - if(!((mDevice->FmtType == DevFmtByte && par.bits == 8 && par.sig != 0) || - (mDevice->FmtType == DevFmtUByte && par.bits == 8 && par.sig == 0) || - (mDevice->FmtType == DevFmtShort && par.bits == 16 && par.sig != 0) || - (mDevice->FmtType == DevFmtUShort && par.bits == 16 && par.sig == 0) || - (mDevice->FmtType == DevFmtInt && par.bits == 32 && par.sig != 0) || - (mDevice->FmtType == DevFmtUInt && par.bits == 32 && par.sig == 0)) || - mDevice->channelsFromFmt() != par.rchan || mDevice->Frequency != par.rate) - { - ERR("Failed to set format %s %s %uhz, got %c%u %u-channel %uhz instead\n", - DevFmtTypeString(mDevice->FmtType), DevFmtChannelsString(mDevice->FmtChans), - mDevice->Frequency, par.sig?'s':'u', par.bits, par.rchan, par.rate); - throw al::backend_exception{ALC_INVALID_VALUE, "Could not set format %s %s %uhz", + if(!((mDevice->FmtType == DevFmtByte && par.bits == 8 && par.sig != 0) + || (mDevice->FmtType == DevFmtUByte && par.bits == 8 && par.sig == 0) + || (mDevice->FmtType == DevFmtShort && par.bits == 16 && par.sig != 0) + || (mDevice->FmtType == DevFmtUShort && par.bits == 16 && par.sig == 0) + || (mDevice->FmtType == DevFmtInt && par.bits == 32 && par.sig != 0) + || (mDevice->FmtType == DevFmtUInt && par.bits == 32 && par.sig == 0)) + || mDevice->channelsFromFmt() != par.rchan || mDevice->Frequency != par.rate) + throw al::backend_exception{ALC_INVALID_VALUE, + "Failed to set format %s %s %uhz, got %c%u %u-channel %uhz instead", DevFmtTypeString(mDevice->FmtType), DevFmtChannelsString(mDevice->FmtChans), - mDevice->Frequency}; - } + mDevice->Frequency, par.sig?'s':'u', par.bits, par.rchan, par.rate}; mRing = CreateRingBuffer(mDevice->BufferSize, par.bps*par.rchan, false); - if(!mRing) - { - ERR("Failed to allocate %u-byte ringbuffer\n", mDevice->BufferSize*par.bps*par.rchan); - throw al::backend_exception{ALC_OUT_OF_MEMORY, "Failed to allocate ring buffer"}; - } + if(!mRing) throw al::backend_exception{ALC_OUT_OF_MEMORY, "Failed to allocate ring buffer"}; SetDefaultChannelOrder(mDevice); diff --git a/alc/backends/solaris.cpp b/alc/backends/solaris.cpp index 79cc224d..7cc2606e 100644 --- a/alc/backends/solaris.cpp +++ b/alc/backends/solaris.cpp @@ -151,11 +151,8 @@ void SolarisBackend::open(const ALCchar *name) mFd = ::open(solaris_driver.c_str(), O_WRONLY); if(mFd == -1) - { - ERR("Could not open %s: %s\n", solaris_driver.c_str(), strerror(errno)); throw al::backend_exception{ALC_INVALID_VALUE, "Could not open %s: %s", solaris_driver.c_str(), strerror(errno)}; - } mDevice->DeviceName = name; } diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp index 181518d0..2c4fe130 100644 --- a/alc/backends/wasapi.cpp +++ b/alc/backends/wasapi.cpp @@ -762,7 +762,6 @@ void WasapiPlayback::open(const ALCchar *name) mDevId.clear(); - ERR("Device init failed: 0x%08lx\n", hr); throw al::backend_exception{ALC_INVALID_VALUE, "Device init failed: 0x%08lx", hr}; } } @@ -1336,7 +1335,6 @@ void WasapiCapture::open(const ALCchar *name) mDevId.clear(); - ERR("Device init failed: 0x%08lx\n", hr); throw al::backend_exception{ALC_INVALID_VALUE, "Device init failed: 0x%08lx", hr}; } diff --git a/alc/backends/wave.cpp b/alc/backends/wave.cpp index 3b0a30d8..7bcc3436 100644 --- a/alc/backends/wave.cpp +++ b/alc/backends/wave.cpp @@ -223,11 +223,8 @@ void WaveBackend::open(const ALCchar *name) mFile = fopen(fname, "wb"); #endif if(!mFile) - { - ERR("Could not open file '%s': %s\n", fname, strerror(errno)); throw al::backend_exception{ALC_INVALID_VALUE, "Could not open file '%s': %s", fname, strerror(errno)}; - } mDevice->DeviceName = name; } diff --git a/alc/backends/winmm.cpp b/alc/backends/winmm.cpp index 8f85f351..dde74304 100644 --- a/alc/backends/winmm.cpp +++ b/alc/backends/winmm.cpp @@ -127,8 +127,9 @@ struct WinMMPlayback final : public BackendBase { WinMMPlayback(ALCdevice *device) noexcept : BackendBase{device} { } ~WinMMPlayback() override; - static void CALLBACK waveOutProcC(HWAVEOUT device, UINT msg, DWORD_PTR instance, DWORD_PTR param1, DWORD_PTR param2); void CALLBACK waveOutProc(HWAVEOUT device, UINT msg, DWORD_PTR param1, DWORD_PTR param2); + static void CALLBACK waveOutProcC(HWAVEOUT device, UINT msg, DWORD_PTR instance, DWORD_PTR param1, DWORD_PTR param2) + { reinterpret_cast<WinMMPlayback*>(instance)->waveOutProc(device, msg, param1, param2); } int mixerProc(); @@ -162,10 +163,6 @@ WinMMPlayback::~WinMMPlayback() std::fill(mWaveBuffer.begin(), mWaveBuffer.end(), WAVEHDR{}); } - -void CALLBACK WinMMPlayback::waveOutProcC(HWAVEOUT device, UINT msg, DWORD_PTR instance, DWORD_PTR param1, DWORD_PTR param2) -{ reinterpret_cast<WinMMPlayback*>(instance)->waveOutProc(device, msg, param1, param2); } - /* WinMMPlayback::waveOutProc * * Posts a message to 'WinMMPlayback::mixerProc' everytime a WaveOut Buffer is @@ -256,7 +253,6 @@ retry_open: mDevice->FmtType = DevFmtShort; goto retry_open; } - ERR("waveOutOpen failed: %u\n", res); throw al::backend_exception{ALC_INVALID_VALUE, "waveOutOpen failed: %u", res}; } @@ -368,8 +364,9 @@ struct WinMMCapture final : public BackendBase { WinMMCapture(ALCdevice *device) noexcept : BackendBase{device} { } ~WinMMCapture() override; - static void CALLBACK waveInProcC(HWAVEIN device, UINT msg, DWORD_PTR instance, DWORD_PTR param1, DWORD_PTR param2); void CALLBACK waveInProc(HWAVEIN device, UINT msg, DWORD_PTR param1, DWORD_PTR param2); + static void CALLBACK waveInProcC(HWAVEIN device, UINT msg, DWORD_PTR instance, DWORD_PTR param1, DWORD_PTR param2) + { reinterpret_cast<WinMMCapture*>(instance)->waveInProc(device, msg, param1, param2); } int captureProc(); @@ -407,9 +404,6 @@ WinMMCapture::~WinMMCapture() std::fill(mWaveBuffer.begin(), mWaveBuffer.end(), WAVEHDR{}); } -void CALLBACK WinMMCapture::waveInProcC(HWAVEIN device, UINT msg, DWORD_PTR instance, DWORD_PTR param1, DWORD_PTR param2) -{ reinterpret_cast<WinMMCapture*>(instance)->waveInProc(device, msg, param1, param2); } - /* WinMMCapture::waveInProc * * Posts a message to 'WinMMCapture::captureProc' everytime a WaveIn Buffer is @@ -513,10 +507,7 @@ void WinMMCapture::open(const ALCchar *name) reinterpret_cast<DWORD_PTR>(&WinMMCapture::waveInProcC), reinterpret_cast<DWORD_PTR>(this), CALLBACK_FUNCTION)}; if(res != MMSYSERR_NOERROR) - { - ERR("waveInOpen failed: %u\n", res); throw al::backend_exception{ALC_INVALID_VALUE, "waveInOpen failed: %u", res}; - } // Ensure each buffer is 50ms each DWORD BufferSize{mFormat.nAvgBytesPerSec / 20u}; |