Don't return a bool from the backend start method

This commit is contained in:
Chris Robinson 2020-04-28 19:25:58 -07:00
parent 065775d814
commit 4094135ed7
19 changed files with 128 additions and 212 deletions

View File

@ -2026,11 +2026,12 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
device->UpdateSize, device->BufferSize);
try {
if(device->Backend->reset() == false)
return ALC_INVALID_DEVICE;
auto backend = device->Backend.get();
if(!backend->reset())
throw al::backend_exception{ALC_INVALID_DEVICE, "Device reset failure"};
}
catch(std::exception &e) {
ERR("Device reset failed: %s\n", e.what());
aluHandleDisconnect(device, "%s", e.what());
return ALC_INVALID_DEVICE;
}
@ -2365,12 +2366,11 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
{
try {
auto backend = device->Backend.get();
if(!backend->start())
throw al::backend_exception{ALC_INVALID_DEVICE, "Backend error"};
backend->start();
device->Flags.set<DeviceRunning>();
}
catch(al::backend_exception& e) {
WARN("Failed to start playback: %s\n", e.what());
aluHandleDisconnect(device, "%s", e.what());
return ALC_INVALID_DEVICE;
}
}
@ -3392,8 +3392,6 @@ START_API_FUNC
if(err != ALC_NO_ERROR)
{
alcSetError(dev.get(), err);
if(err == ALC_INVALID_DEVICE)
aluHandleDisconnect(dev.get(), "Device update failure");
return nullptr;
}
@ -3941,8 +3939,7 @@ START_API_FUNC
{
try {
auto backend = dev->Backend.get();
if(!backend->start())
throw al::backend_exception{ALC_INVALID_DEVICE, "Device start failure"};
backend->start();
dev->Flags.set<DeviceRunning>();
}
catch(al::backend_exception& e) {
@ -4153,8 +4150,7 @@ START_API_FUNC
try {
auto backend = dev->Backend.get();
if(!backend->start())
throw al::backend_exception{ALC_INVALID_DEVICE, "Device start failure"};
backend->start();
dev->Flags.set<DeviceRunning>();
}
catch(al::backend_exception& e) {
@ -4242,8 +4238,6 @@ START_API_FUNC
if LIKELY(err == ALC_NO_ERROR) return ALC_TRUE;
alcSetError(dev.get(), err);
if(err == ALC_INVALID_DEVICE)
aluHandleDisconnect(dev.get(), "Device start failure");
return ALC_FALSE;
}
END_API_FUNC

View File

@ -418,7 +418,7 @@ struct AlsaPlayback final : public BackendBase {
void open(const ALCchar *name) override;
bool reset() override;
bool start() override;
void start() override;
void stop() override;
ClockLatency getClockLatency() override;
@ -792,7 +792,7 @@ bool AlsaPlayback::reset()
return true;
}
bool AlsaPlayback::start()
void AlsaPlayback::start()
{
int err{};
snd_pcm_access_t access{};
@ -818,23 +818,19 @@ bool AlsaPlayback::start()
{
err = snd_pcm_prepare(mPcmHandle);
if(err < 0)
{
ERR("snd_pcm_prepare(data->mPcmHandle) failed: %s\n", snd_strerror(err));
return false;
}
throw al::backend_exception{ALC_INVALID_DEVICE,
"snd_pcm_prepare(data->mPcmHandle) failed: %s", snd_strerror(err)};
thread_func = &AlsaPlayback::mixerProc;
}
try {
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(thread_func), this};
return true;
}
catch(std::exception& e) {
ERR("Could not create playback thread: %s\n", e.what());
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
e.what()};
}
mBuffer.clear();
return false;
}
void AlsaPlayback::stop()
@ -871,7 +867,7 @@ struct AlsaCapture final : public BackendBase {
~AlsaCapture() override;
void open(const ALCchar *name) override;
bool start() override;
void start() override;
void stop() override;
ALCenum captureSamples(al::byte *buffer, ALCuint samples) override;
ALCuint availableSamples() override;
@ -995,7 +991,7 @@ void AlsaCapture::open(const ALCchar *name)
}
bool AlsaCapture::start()
void AlsaCapture::start()
{
int err{snd_pcm_prepare(mPcmHandle)};
if(err < 0)
@ -1008,7 +1004,6 @@ bool AlsaCapture::start()
snd_strerror(err)};
mDoCapture = true;
return true;
}
void AlsaCapture::stop()

View File

@ -22,7 +22,7 @@ struct BackendBase {
virtual void open(const ALCchar *name) = 0;
virtual bool reset();
virtual bool start() = 0;
virtual void start() = 0;
virtual void stop() = 0;
virtual ALCenum captureSamples(al::byte *buffer, ALCuint samples);

View File

@ -61,7 +61,7 @@ struct CoreAudioPlayback final : public BackendBase {
void open(const ALCchar *name) override;
bool reset() override;
bool start() override;
void start() override;
void stop() override;
AudioUnit mAudioUnit{};
@ -269,15 +269,11 @@ bool CoreAudioPlayback::reset()
return true;
}
bool CoreAudioPlayback::start()
void CoreAudioPlayback::start()
{
OSStatus err{AudioOutputUnitStart(mAudioUnit)};
const OSStatus err{AudioOutputUnitStart(mAudioUnit)};
if(err != noErr)
{
ERR("AudioOutputUnitStart failed\n");
return false;
}
return true;
throw al::backend_exception{ALC_INVALID_DEVICE, "AudioOutputUnitStart failed: %d", err};
}
void CoreAudioPlayback::stop()
@ -304,7 +300,7 @@ struct CoreAudioCapture final : public BackendBase {
}
void open(const ALCchar *name) override;
bool start() override;
void start() override;
void stop() override;
ALCenum captureSamples(al::byte *buffer, ALCuint samples) override;
ALCuint availableSamples() override;
@ -576,15 +572,11 @@ void CoreAudioCapture::open(const ALCchar *name)
}
bool CoreAudioCapture::start()
void CoreAudioCapture::start()
{
OSStatus err{AudioOutputUnitStart(mAudioUnit)};
if(err != noErr)
{
ERR("AudioOutputUnitStart failed\n");
return false;
}
return true;
throw al::backend_exception{ALC_INVALID_DEVICE, "AudioOutputUnitStart failed: %d", err};
}
void CoreAudioCapture::stop()

View File

@ -169,7 +169,7 @@ struct DSoundPlayback final : public BackendBase {
void open(const ALCchar *name) override;
bool reset() override;
bool start() override;
void start() override;
void stop() override;
IDirectSound *mDS{nullptr};
@ -563,19 +563,16 @@ retry_open:
return true;
}
bool DSoundPlayback::start()
void DSoundPlayback::start()
{
try {
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(&DSoundPlayback::mixerProc), this};
return true;
}
catch(std::exception& e) {
ERR("Failed to start mixing thread: %s\n", e.what());
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
e.what()};
}
catch(...) {
}
return false;
}
void DSoundPlayback::stop()
@ -593,7 +590,7 @@ struct DSoundCapture final : public BackendBase {
~DSoundCapture() override;
void open(const ALCchar *name) override;
bool start() override;
void start() override;
void stop() override;
ALCenum captureSamples(al::byte *buffer, ALCuint samples) override;
ALCuint availableSamples() override;
@ -762,16 +759,11 @@ void DSoundCapture::open(const ALCchar *name)
mDevice->DeviceName = name;
}
bool DSoundCapture::start()
void DSoundCapture::start()
{
HRESULT hr{mDSCbuffer->Start(DSCBSTART_LOOPING)};
const HRESULT hr{mDSCbuffer->Start(DSCBSTART_LOOPING)};
if(FAILED(hr))
{
ERR("start failed: 0x%08lx\n", hr);
aluHandleDisconnect(mDevice, "Failure starting capture: 0x%lx", hr);
return false;
}
return true;
throw al::backend_exception{ALC_INVALID_DEVICE, "Failure starting capture: 0x%lx", hr};
}
void DSoundCapture::stop()

View File

@ -163,7 +163,7 @@ struct JackPlayback final : public BackendBase {
void open(const ALCchar *name) override;
bool reset() override;
bool start() override;
void start() override;
void stop() override;
ClockLatency getClockLatency() override;
@ -380,21 +380,17 @@ bool JackPlayback::reset()
return true;
}
bool JackPlayback::start()
void JackPlayback::start()
{
if(jack_activate(mClient))
{
ERR("Failed to activate client\n");
return false;
}
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to activate client"};
const char **ports{jack_get_ports(mClient, nullptr, nullptr,
JackPortIsPhysical|JackPortIsInput)};
if(ports == nullptr)
{
ERR("No physical playback ports found\n");
jack_deactivate(mClient);
return false;
throw al::backend_exception{ALC_INVALID_DEVICE, "No physical playback ports found"};
}
std::mismatch(std::begin(mPort), std::end(mPort), ports,
[this](const jack_port_t *port, const char *pname) -> bool
@ -432,16 +428,13 @@ bool JackPlayback::start()
mPlaying.store(true, std::memory_order_release);
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(&JackPlayback::mixerProc), this};
return true;
}
catch(std::exception& e) {
ERR("Could not create playback thread: %s\n", e.what());
jack_deactivate(mClient);
mPlaying.store(false, std::memory_order_release);
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
e.what()};
}
catch(...) {
}
jack_deactivate(mClient);
mPlaying.store(false, std::memory_order_release);
return false;
}
void JackPlayback::stop()

View File

@ -33,7 +33,7 @@ struct LoopbackBackend final : public BackendBase {
void open(const ALCchar *name) override;
bool reset() override;
bool start() override;
void start() override;
void stop() override;
DEF_NEWDEL(LoopbackBackend)
@ -51,8 +51,8 @@ bool LoopbackBackend::reset()
return true;
}
bool LoopbackBackend::start()
{ return true; }
void LoopbackBackend::start()
{ }
void LoopbackBackend::stop()
{ }

View File

@ -54,7 +54,7 @@ struct NullBackend final : public BackendBase {
void open(const ALCchar *name) override;
bool reset() override;
bool start() override;
void start() override;
void stop() override;
std::atomic<bool> mKillNow{true};
@ -123,19 +123,16 @@ bool NullBackend::reset()
return true;
}
bool NullBackend::start()
void NullBackend::start()
{
try {
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(&NullBackend::mixerProc), this};
return true;
}
catch(std::exception& e) {
ERR("Failed to start mixing thread: %s\n", e.what());
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
e.what()};
}
catch(...) {
}
return false;
}
void NullBackend::stop()

View File

@ -27,7 +27,7 @@ struct OboePlayback final : public BackendBase, public oboe::AudioStreamCallback
void open(const ALCchar *name) override;
bool reset() override;
bool start() override;
void start() override;
void stop() override;
};
@ -199,13 +199,12 @@ bool OboePlayback::reset()
return true;
}
bool OboePlayback::start()
void OboePlayback::start()
{
oboe::Result result{mStream->start()};
const oboe::Result result{mStream->start()};
if(result != oboe::Result::OK)
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start stream: %s",
oboe::convertToText(result)};
return true;
}
void OboePlayback::stop()

View File

@ -155,7 +155,7 @@ struct OpenSLPlayback final : public BackendBase {
void open(const ALCchar *name) override;
bool reset() override;
bool start() override;
void start() override;
void stop() override;
ClockLatency getClockLatency() override;
@ -540,7 +540,7 @@ bool OpenSLPlayback::reset()
return true;
}
bool OpenSLPlayback::start()
void OpenSLPlayback::start()
{
mRing->reset();
@ -548,24 +548,23 @@ bool OpenSLPlayback::start()
SLresult result{VCALL(mBufferQueueObj,GetInterface)(SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
&bufferQueue)};
PRINTERR(result, "bufferQueue->GetInterface");
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(bufferQueue,RegisterCallback)(&OpenSLPlayback::processC, this);
PRINTERR(result, "bufferQueue->RegisterCallback");
}
if(SL_RESULT_SUCCESS != result)
return false;
result = VCALL(bufferQueue,RegisterCallback)(&OpenSLPlayback::processC, this);
PRINTERR(result, "bufferQueue->RegisterCallback");
if(SL_RESULT_SUCCESS != result) return false;
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to register callback: 0x%08x",
result};
try {
mKillNow.store(false, std::memory_order_release);
mThread = std::thread(std::mem_fn(&OpenSLPlayback::mixerProc), this);
return true;
}
catch(std::exception& e) {
ERR("Could not create playback thread: %s\n", e.what());
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
e.what()};
}
catch(...) {
}
return false;
}
void OpenSLPlayback::stop()
@ -631,7 +630,7 @@ struct OpenSLCapture final : public BackendBase {
{ static_cast<OpenSLCapture*>(context)->process(bq); }
void open(const ALCchar *name) override;
bool start() override;
void start() override;
void stop() override;
ALCenum captureSamples(al::byte *buffer, ALCuint samples) override;
ALCuint availableSamples() override;
@ -837,7 +836,7 @@ void OpenSLCapture::open(const ALCchar* name)
mDevice->DeviceName = name;
}
bool OpenSLCapture::start()
void OpenSLCapture::start()
{
SLRecordItf record;
SLresult result{VCALL(mRecordObj,GetInterface)(SL_IID_RECORD, &record)};
@ -848,14 +847,8 @@ bool OpenSLCapture::start()
result = VCALL(record,SetRecordState)(SL_RECORDSTATE_RECORDING);
PRINTERR(result, "record->SetRecordState");
}
if(SL_RESULT_SUCCESS != result)
{
aluHandleDisconnect(mDevice, "Failed to start capture: 0x%08x", result);
return false;
}
return true;
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start capture: 0x%08x", result};
}
void OpenSLCapture::stop()

View File

@ -251,7 +251,7 @@ struct OSSPlayback final : public BackendBase {
void open(const ALCchar *name) override;
bool reset() override;
bool start() override;
void start() override;
void stop() override;
int mFd{-1};
@ -432,19 +432,16 @@ bool OSSPlayback::reset()
return true;
}
bool OSSPlayback::start()
void OSSPlayback::start()
{
try {
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(&OSSPlayback::mixerProc), this};
return true;
}
catch(std::exception& e) {
ERR("Could not create playback thread: %s\n", e.what());
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
e.what()};
}
catch(...) {
}
return false;
}
void OSSPlayback::stop()
@ -465,7 +462,7 @@ struct OSScapture final : public BackendBase {
int recordProc();
void open(const ALCchar *name) override;
bool start() override;
void start() override;
void stop() override;
ALCenum captureSamples(al::byte *buffer, ALCuint samples) override;
ALCuint availableSamples() override;
@ -614,19 +611,16 @@ void OSScapture::open(const ALCchar *name)
mDevice->DeviceName = name;
}
bool OSScapture::start()
void OSScapture::start()
{
try {
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(&OSScapture::recordProc), this};
return true;
}
catch(std::exception& e) {
ERR("Could not create record thread: %s\n", e.what());
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start recording thread: %s",
e.what()};
}
catch(...) {
}
return false;
}
void OSScapture::stop()

View File

@ -88,7 +88,7 @@ struct PortPlayback final : public BackendBase {
void open(const ALCchar *name) override;
bool reset() override;
bool start() override;
void start() override;
void stop() override;
PaStream *mStream{nullptr};
@ -209,15 +209,12 @@ bool PortPlayback::reset()
return true;
}
bool PortPlayback::start()
void PortPlayback::start()
{
PaError err{Pa_StartStream(mStream)};
if(err != paNoError)
{
ERR("Pa_StartStream() returned an error: %s\n", Pa_GetErrorText(err));
return false;
}
return true;
const PaError err{Pa_StartStream(mStream)};
if(err == paNoError)
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start playback: %s",
Pa_GetErrorText(err)};
}
void PortPlayback::stop()
@ -243,7 +240,7 @@ struct PortCapture final : public BackendBase {
}
void open(const ALCchar *name) override;
bool start() override;
void start() override;
void stop() override;
ALCenum captureSamples(al::byte *buffer, ALCuint samples) override;
ALCuint availableSamples() override;
@ -326,15 +323,12 @@ void PortCapture::open(const ALCchar *name)
}
bool PortCapture::start()
void PortCapture::start()
{
PaError err{Pa_StartStream(mStream)};
const PaError err{Pa_StartStream(mStream)};
if(err != paNoError)
{
ERR("Error starting stream: %s\n", Pa_GetErrorText(err));
return false;
}
return true;
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start recording: %s",
Pa_GetErrorText(err)};
}
void PortCapture::stop()

View File

@ -714,7 +714,7 @@ struct PulsePlayback final : public BackendBase {
void open(const ALCchar *name) override;
bool reset() override;
bool start() override;
void start() override;
void stop() override;
ClockLatency getClockLatency() override;
@ -1047,7 +1047,7 @@ bool PulsePlayback::reset()
return true;
}
bool PulsePlayback::start()
void PulsePlayback::start()
{
auto plock = mMainloop.getUniqueLock();
@ -1080,7 +1080,6 @@ bool PulsePlayback::start()
}
mMainloop.waitForOperation(op, plock);
return true;
}
void PulsePlayback::stop()
@ -1142,7 +1141,7 @@ struct PulseCapture final : public BackendBase {
{ static_cast<PulseCapture*>(pdata)->streamMovedCallback(stream); }
void open(const ALCchar *name) override;
bool start() override;
void start() override;
void stop() override;
ALCenum captureSamples(al::byte *buffer, ALCuint samples) override;
ALCuint availableSamples() override;
@ -1308,13 +1307,12 @@ void PulseCapture::open(const ALCchar *name)
}
}
bool PulseCapture::start()
void PulseCapture::start()
{
auto plock = mMainloop.getUniqueLock();
pa_operation *op{pa_stream_cork(mStream, 0, &PulseMainloop::streamSuccessCallbackC,
&mMainloop)};
mMainloop.waitForOperation(op, plock);
return true;
}
void PulseCapture::stop()

View File

@ -58,7 +58,7 @@ struct Sdl2Backend final : public BackendBase {
void open(const ALCchar *name) override;
bool reset() override;
bool start() override;
void start() override;
void stop() override;
SDL_AudioDeviceID mDeviceID{0u};
@ -170,11 +170,8 @@ bool Sdl2Backend::reset()
return true;
}
bool Sdl2Backend::start()
{
SDL_PauseAudioDevice(mDeviceID, 0);
return true;
}
void Sdl2Backend::start()
{ SDL_PauseAudioDevice(mDeviceID, 0); }
void Sdl2Backend::stop()
{ SDL_PauseAudioDevice(mDeviceID, 1); }

View File

@ -53,7 +53,7 @@ struct SndioPlayback final : public BackendBase {
void open(const ALCchar *name) override;
bool reset() override;
bool start() override;
void start() override;
void stop() override;
sio_hdl *mSndHandle{nullptr};
@ -207,26 +207,20 @@ bool SndioPlayback::reset()
return true;
}
bool SndioPlayback::start()
void SndioPlayback::start()
{
if(!sio_start(mSndHandle))
{
ERR("Error starting playback\n");
return false;
}
throw al::backend_exception{ALC_INVALID_DEVICE, "Error starting playback"};
try {
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(&SndioPlayback::mixerProc), this};
return true;
}
catch(std::exception& e) {
ERR("Could not create playback thread: %s\n", e.what());
sio_stop(mSndHandle);
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
e.what()};
}
catch(...) {
}
sio_stop(mSndHandle);
return false;
}
void SndioPlayback::stop()
@ -247,7 +241,7 @@ struct SndioCapture final : public BackendBase {
int recordProc();
void open(const ALCchar *name) override;
bool start() override;
void start() override;
void stop() override;
ALCenum captureSamples(al::byte *buffer, ALCuint samples) override;
ALCuint availableSamples() override;
@ -398,26 +392,20 @@ void SndioCapture::open(const ALCchar *name)
mDevice->DeviceName = name;
}
bool SndioCapture::start()
void SndioCapture::start()
{
if(!sio_start(mSndHandle))
{
ERR("Error starting playback\n");
return false;
}
throw al::backend_exception{ALC_INVALID_DEVICE, "Error starting capture"};
try {
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(&SndioCapture::recordProc), this};
return true;
}
catch(std::exception& e) {
ERR("Could not create record thread: %s\n", e.what());
sio_stop(mSndHandle);
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
e.what()};
}
catch(...) {
}
sio_stop(mSndHandle);
return false;
}
void SndioCapture::stop()

View File

@ -65,7 +65,7 @@ struct SolarisBackend final : public BackendBase {
void open(const ALCchar *name) override;
bool reset() override;
bool start() override;
void start() override;
void stop() override;
int mFd{-1};
@ -228,19 +228,16 @@ bool SolarisBackend::reset()
return true;
}
bool SolarisBackend::start()
void SolarisBackend::start()
{
try {
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(&SolarisBackend::mixerProc), this};
return true;
}
catch(std::exception& e) {
ERR("Could not create playback thread: %s\n", e.what());
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
e.what()};
}
catch(...) {
}
return false;
}
void SolarisBackend::stop()

View File

@ -641,7 +641,7 @@ struct WasapiPlayback final : public BackendBase, WasapiProxy {
bool reset() override;
HRESULT resetProxy() override;
bool start() override;
void start() override;
HRESULT startProxy() override;
void stop() override;
void stopProxy() override;
@ -1108,10 +1108,11 @@ HRESULT WasapiPlayback::resetProxy()
}
bool WasapiPlayback::start()
void WasapiPlayback::start()
{
HRESULT hr{pushMessage(MsgType::StartDevice).get()};
return SUCCEEDED(hr) ? true : false;
const HRESULT hr{pushMessage(MsgType::StartDevice).get()};
if(FAILED(hr))
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start playback: 0x%lx", hr};
}
HRESULT WasapiPlayback::startProxy()
@ -1190,7 +1191,7 @@ struct WasapiCapture final : public BackendBase, WasapiProxy {
void closeProxy() override;
HRESULT resetProxy() override;
bool start() override;
void start() override;
HRESULT startProxy() override;
void stop() override;
void stopProxy() override;
@ -1650,10 +1651,11 @@ HRESULT WasapiCapture::resetProxy()
}
bool WasapiCapture::start()
void WasapiCapture::start()
{
HRESULT hr{pushMessage(MsgType::StartDevice).get()};
return SUCCEEDED(hr) ? true : false;
const HRESULT hr{pushMessage(MsgType::StartDevice).get()};
if(FAILED(hr))
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start recording: 0x%lx", hr};
}
HRESULT WasapiCapture::startProxy()

View File

@ -99,7 +99,7 @@ struct WaveBackend final : public BackendBase {
void open(const ALCchar *name) override;
bool reset() override;
bool start() override;
void start() override;
void stop() override;
FILE *mFile{nullptr};
@ -332,19 +332,16 @@ bool WaveBackend::reset()
return true;
}
bool WaveBackend::start()
void WaveBackend::start()
{
try {
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(&WaveBackend::mixerProc), this};
return true;
}
catch(std::exception& e) {
ERR("Failed to start mixing thread: %s\n", e.what());
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
e.what()};
}
catch(...) {
}
return false;
}
void WaveBackend::stop()

View File

@ -136,7 +136,7 @@ struct WinMMPlayback final : public BackendBase {
void open(const ALCchar *name) override;
bool reset() override;
bool start() override;
void start() override;
void stop() override;
std::atomic<ALuint> mWritable{0u};
@ -323,7 +323,7 @@ bool WinMMPlayback::reset()
return true;
}
bool WinMMPlayback::start()
void WinMMPlayback::start()
{
try {
std::for_each(mWaveBuffer.begin(), mWaveBuffer.end(),
@ -334,14 +334,11 @@ bool WinMMPlayback::start()
mKillNow.store(false, std::memory_order_release);
mThread = std::thread{std::mem_fn(&WinMMPlayback::mixerProc), this};
return true;
}
catch(std::exception& e) {
ERR("Failed to start mixing thread: %s\n", e.what());
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
e.what()};
}
catch(...) {
}
return false;
}
void WinMMPlayback::stop()
@ -371,7 +368,7 @@ struct WinMMCapture final : public BackendBase {
int captureProc();
void open(const ALCchar *name) override;
bool start() override;
void start() override;
void stop() override;
ALCenum captureSamples(al::byte *buffer, ALCuint samples) override;
ALCuint availableSamples() override;
@ -531,7 +528,7 @@ void WinMMCapture::open(const ALCchar *name)
mDevice->DeviceName = CaptureDevices[DeviceID];
}
bool WinMMCapture::start()
void WinMMCapture::start()
{
try {
for(size_t i{0};i < mWaveBuffer.size();++i)
@ -544,14 +541,11 @@ bool WinMMCapture::start()
mThread = std::thread{std::mem_fn(&WinMMCapture::captureProc), this};
waveInStart(mInHdl);
return true;
}
catch(std::exception& e) {
ERR("Failed to start mixing thread: %s\n", e.what());
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start recording thread: %s",
e.what()};
}
catch(...) {
}
return false;
}
void WinMMCapture::stop()