Don't use ALC error enums for the backend error code
This commit is contained in:
+7
-4
@@ -1944,7 +1944,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
|
||||
try {
|
||||
auto backend = device->Backend.get();
|
||||
if(!backend->reset())
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Device reset failure"};
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "Device reset failure"};
|
||||
}
|
||||
catch(std::exception &e) {
|
||||
device->handleDisconnect("%s", e.what());
|
||||
@@ -3518,7 +3518,8 @@ START_API_FUNC
|
||||
}
|
||||
catch(al::backend_exception &e) {
|
||||
WARN("Failed to open playback device: %s\n", e.what());
|
||||
alcSetError(nullptr, e.errorCode());
|
||||
alcSetError(nullptr, (e.errorCode() == al::backend_error::OutOfMemory)
|
||||
? ALC_OUT_OF_MEMORY : ALC_INVALID_VALUE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -3771,7 +3772,8 @@ START_API_FUNC
|
||||
}
|
||||
catch(al::backend_exception &e) {
|
||||
WARN("Failed to open capture device: %s\n", e.what());
|
||||
alcSetError(nullptr, e.errorCode());
|
||||
alcSetError(nullptr, (e.errorCode() == al::backend_error::OutOfMemory)
|
||||
? ALC_OUT_OF_MEMORY : ALC_INVALID_VALUE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -3944,7 +3946,8 @@ START_API_FUNC
|
||||
}
|
||||
catch(al::backend_exception &e) {
|
||||
WARN("Failed to open loopback device: %s\n", e.what());
|
||||
alcSetError(nullptr, e.errorCode());
|
||||
alcSetError(nullptr, (e.errorCode() == al::backend_error::OutOfMemory)
|
||||
? ALC_OUT_OF_MEMORY : ALC_INVALID_VALUE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
+22
-19
@@ -629,7 +629,8 @@ void AlsaPlayback::open(const ALCchar *name)
|
||||
{ return entry.name == name; }
|
||||
);
|
||||
if(iter == PlaybackDevices.cend())
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice,
|
||||
"Device name \"%s\" not found", name};
|
||||
driver = iter->device_name.c_str();
|
||||
}
|
||||
else
|
||||
@@ -641,8 +642,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)
|
||||
throw al::backend_exception{ALC_OUT_OF_MEMORY, "Could not open ALSA device \"%s\"",
|
||||
driver};
|
||||
throw al::backend_exception{al::backend_error::NoDevice,
|
||||
"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();
|
||||
@@ -687,7 +688,8 @@ bool AlsaPlayback::reset()
|
||||
HwParamsPtr hp{CreateHwParams()};
|
||||
#define CHECK(x) do { \
|
||||
if((err=(x)) < 0) \
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, #x " failed: %s", snd_strerror(err)}; \
|
||||
throw al::backend_exception{al::backend_error::DeviceError, #x " failed: %s", \
|
||||
snd_strerror(err)}; \
|
||||
} while(0)
|
||||
CHECK(snd_pcm_hw_params_any(mPcmHandle, hp.get()));
|
||||
/* set interleaved access */
|
||||
@@ -799,12 +801,12 @@ void AlsaPlayback::start()
|
||||
HwParamsPtr hp{CreateHwParams()};
|
||||
#define CHECK(x) do { \
|
||||
if((err=(x)) < 0) \
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, #x " failed: %s", snd_strerror(err)}; \
|
||||
throw al::backend_exception{al::backend_error::DeviceError, #x " failed: %s", \
|
||||
snd_strerror(err)}; \
|
||||
} while(0)
|
||||
CHECK(snd_pcm_hw_params_current(mPcmHandle, hp.get()));
|
||||
/* retrieve configuration info */
|
||||
CHECK(snd_pcm_hw_params_get_access(hp.get(), &access));
|
||||
#undef CHECK
|
||||
hp = nullptr;
|
||||
|
||||
int (AlsaPlayback::*thread_func)(){};
|
||||
@@ -816,20 +818,18 @@ void AlsaPlayback::start()
|
||||
}
|
||||
else
|
||||
{
|
||||
err = snd_pcm_prepare(mPcmHandle);
|
||||
if(err < 0)
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE,
|
||||
"snd_pcm_prepare(data->mPcmHandle) failed: %s", snd_strerror(err)};
|
||||
CHECK(snd_pcm_prepare(mPcmHandle));
|
||||
thread_func = &AlsaPlayback::mixerProc;
|
||||
}
|
||||
#undef CHECK
|
||||
|
||||
try {
|
||||
mKillNow.store(false, std::memory_order_release);
|
||||
mThread = std::thread{std::mem_fn(thread_func), this};
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
|
||||
e.what()};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to start mixing thread: %s", e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -909,7 +909,8 @@ void AlsaCapture::open(const ALCchar *name)
|
||||
{ return entry.name == name; }
|
||||
);
|
||||
if(iter == CaptureDevices.cend())
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice,
|
||||
"Device name \"%s\" not found", name};
|
||||
driver = iter->device_name.c_str();
|
||||
}
|
||||
else
|
||||
@@ -921,8 +922,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)
|
||||
throw al::backend_exception{ALC_OUT_OF_MEMORY, "Could not open ALSA device \"%s\"",
|
||||
driver};
|
||||
throw al::backend_exception{al::backend_error::NoDevice,
|
||||
"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();
|
||||
@@ -960,7 +961,8 @@ void AlsaCapture::open(const ALCchar *name)
|
||||
HwParamsPtr hp{CreateHwParams()};
|
||||
#define CHECK(x) do { \
|
||||
if((err=(x)) < 0) \
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, #x " failed: %s", snd_strerror(err)}; \
|
||||
throw al::backend_exception{al::backend_error::DeviceError, #x " failed: %s", \
|
||||
snd_strerror(err)}; \
|
||||
} while(0)
|
||||
CHECK(snd_pcm_hw_params_any(mPcmHandle, hp.get()));
|
||||
/* set interleaved access */
|
||||
@@ -998,12 +1000,12 @@ void AlsaCapture::start()
|
||||
{
|
||||
int err{snd_pcm_prepare(mPcmHandle)};
|
||||
if(err < 0)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "snd_pcm_prepare failed: %s",
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "snd_pcm_prepare failed: %s",
|
||||
snd_strerror(err)};
|
||||
|
||||
err = snd_pcm_start(mPcmHandle);
|
||||
if(err < 0)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "snd_pcm_start failed: %s",
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "snd_pcm_start failed: %s",
|
||||
snd_strerror(err)};
|
||||
|
||||
mDoCapture = true;
|
||||
@@ -1019,7 +1021,8 @@ void AlsaCapture::stop()
|
||||
if(!mRing && avail > 0)
|
||||
{
|
||||
/* The ring buffer implicitly captures when checking availability.
|
||||
* Direct access needs to explicitly capture it into temp storage. */
|
||||
* Direct access needs to explicitly capture it into temp storage.
|
||||
*/
|
||||
auto temp = al::vector<al::byte>(
|
||||
static_cast<size_t>(snd_pcm_frames_to_bytes(mPcmHandle, avail)));
|
||||
captureSamples(temp.data(), avail);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
|
||||
bool BackendBase::reset()
|
||||
{ throw al::backend_exception{ALC_INVALID_DEVICE, "Invalid BackendBase call"}; }
|
||||
{ throw al::backend_exception{al::backend_error::DeviceError, "Invalid BackendBase call"}; }
|
||||
|
||||
void BackendBase::captureSamples(al::byte*, uint)
|
||||
{ }
|
||||
@@ -150,7 +150,7 @@ void BackendBase::setDefaultChannelOrder()
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
void BackendBase::setChannelOrderFromWFXMask(ALuint chanmask)
|
||||
void BackendBase::setChannelOrderFromWFXMask(uint chanmask)
|
||||
{
|
||||
auto get_channel = [](const DWORD chanbit) noexcept -> al::optional<Channel>
|
||||
{
|
||||
|
||||
+11
-5
@@ -19,7 +19,7 @@ struct ClockLatency {
|
||||
};
|
||||
|
||||
struct BackendBase {
|
||||
virtual void open(const ALCchar *name) = 0;
|
||||
virtual void open(const char *name) = 0;
|
||||
|
||||
virtual bool reset();
|
||||
virtual void start() = 0;
|
||||
@@ -43,7 +43,7 @@ protected:
|
||||
|
||||
#ifdef _WIN32
|
||||
/** Sets the channel order given the WaveFormatEx mask. */
|
||||
void setChannelOrderFromWFXMask(ALuint chanmask);
|
||||
void setChannelOrderFromWFXMask(uint chanmask);
|
||||
#endif
|
||||
};
|
||||
using BackendPtr = std::unique_ptr<BackendBase>;
|
||||
@@ -93,19 +93,25 @@ protected:
|
||||
|
||||
namespace al {
|
||||
|
||||
enum class backend_error {
|
||||
NoDevice,
|
||||
DeviceError,
|
||||
OutOfMemory
|
||||
};
|
||||
|
||||
class backend_exception final : public base_exception {
|
||||
ALCenum mErrorCode;
|
||||
backend_error mErrorCode;
|
||||
|
||||
public:
|
||||
[[gnu::format(printf, 3, 4)]]
|
||||
backend_exception(ALCenum code, const char *msg, ...) : mErrorCode{code}
|
||||
backend_exception(backend_error code, const char *msg, ...) : mErrorCode{code}
|
||||
{
|
||||
std::va_list args;
|
||||
va_start(args, msg);
|
||||
setMessage(msg, args);
|
||||
va_end(args);
|
||||
}
|
||||
ALCenum errorCode() const noexcept { return mErrorCode; }
|
||||
backend_error errorCode() const noexcept { return mErrorCode; }
|
||||
};
|
||||
|
||||
} // namespace al
|
||||
|
||||
+36
-25
@@ -100,7 +100,8 @@ void CoreAudioPlayback::open(const ALCchar *name)
|
||||
if(!name)
|
||||
name = ca_device;
|
||||
else if(strcmp(name, ca_device) != 0)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found",
|
||||
name};
|
||||
|
||||
/* open the default output unit */
|
||||
AudioComponentDescription desc{};
|
||||
@@ -116,17 +117,18 @@ void CoreAudioPlayback::open(const ALCchar *name)
|
||||
|
||||
AudioComponent comp{AudioComponentFindNext(NULL, &desc)};
|
||||
if(comp == nullptr)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not find audio component"};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Could not find audio component"};
|
||||
|
||||
OSStatus err{AudioComponentInstanceNew(comp, &mAudioUnit)};
|
||||
if(err != noErr)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not create component instance: %u",
|
||||
err};
|
||||
throw al::backend_exception{al::backend_error::NoDevice,
|
||||
"Could not create component instance: %u", err};
|
||||
|
||||
/* init and start the default audio unit... */
|
||||
err = AudioUnitInitialize(mAudioUnit);
|
||||
if(err != noErr)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not initialize audio unit: %u", err};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Could not initialize audio unit: %u", err};
|
||||
|
||||
mDevice->DeviceName = name;
|
||||
}
|
||||
@@ -280,7 +282,8 @@ void CoreAudioPlayback::start()
|
||||
{
|
||||
const OSStatus err{AudioOutputUnitStart(mAudioUnit)};
|
||||
if(err != noErr)
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "AudioOutputUnitStart failed: %d", err};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"AudioOutputUnitStart failed: %d", err};
|
||||
}
|
||||
|
||||
void CoreAudioPlayback::stop()
|
||||
@@ -394,7 +397,8 @@ void CoreAudioCapture::open(const ALCchar *name)
|
||||
if(!name)
|
||||
name = ca_device;
|
||||
else if(strcmp(name, ca_device) != 0)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found",
|
||||
name};
|
||||
|
||||
desc.componentType = kAudioUnitType_Output;
|
||||
#if TARGET_OS_IOS
|
||||
@@ -409,20 +413,20 @@ void CoreAudioCapture::open(const ALCchar *name)
|
||||
// Search for component with given description
|
||||
comp = AudioComponentFindNext(NULL, &desc);
|
||||
if(comp == NULL)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not find audio component"};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Could not find audio component"};
|
||||
|
||||
// Open the component
|
||||
err = AudioComponentInstanceNew(comp, &mAudioUnit);
|
||||
if(err != noErr)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not create component instance: %u",
|
||||
err};
|
||||
throw al::backend_exception{al::backend_error::NoDevice,
|
||||
"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)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE,
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Could not disable audio unit output property: %u", err};
|
||||
|
||||
// Turn on AudioUnit input
|
||||
@@ -430,7 +434,7 @@ void CoreAudioCapture::open(const ALCchar *name)
|
||||
err = AudioUnitSetProperty(mAudioUnit, kAudioOutputUnitProperty_EnableIO,
|
||||
kAudioUnitScope_Input, 1, &enableIO, sizeof(ALuint));
|
||||
if(err != noErr)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE,
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Could not enable audio unit input property: %u", err};
|
||||
|
||||
#if !TARGET_OS_IOS
|
||||
@@ -447,15 +451,17 @@ void CoreAudioCapture::open(const ALCchar *name)
|
||||
err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, nullptr,
|
||||
&propertySize, &inputDevice);
|
||||
if(err != noErr)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not get input device: %u", err};
|
||||
throw al::backend_exception{al::backend_error::NoDevice,
|
||||
"Could not get input device: %u", err};
|
||||
if(inputDevice == kAudioDeviceUnknown)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Unknown input device"};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Unknown input device"};
|
||||
|
||||
// Track the input device
|
||||
err = AudioUnitSetProperty(mAudioUnit, kAudioOutputUnitProperty_CurrentDevice,
|
||||
kAudioUnitScope_Global, 0, &inputDevice, sizeof(AudioDeviceID));
|
||||
if(err != noErr)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not set input device: %u", err};
|
||||
throw al::backend_exception{al::backend_error::NoDevice,
|
||||
"Could not set input device: %u", err};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -466,27 +472,30 @@ void CoreAudioCapture::open(const ALCchar *name)
|
||||
err = AudioUnitSetProperty(mAudioUnit, kAudioOutputUnitProperty_SetInputCallback,
|
||||
kAudioUnitScope_Global, 0, &input, sizeof(AURenderCallbackStruct));
|
||||
if(err != noErr)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not set capture callback: %u", err};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Could not set capture callback: %u", err};
|
||||
|
||||
// Disable buffer allocation for capture
|
||||
UInt32 flag{0};
|
||||
err = AudioUnitSetProperty(mAudioUnit, kAudioUnitProperty_ShouldAllocateBuffer,
|
||||
kAudioUnitScope_Output, 1, &flag, sizeof(flag));
|
||||
if(err != noErr)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE,
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Could not disable buffer allocation property: %u", err};
|
||||
|
||||
// Initialize the device
|
||||
err = AudioUnitInitialize(mAudioUnit);
|
||||
if(err != noErr)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not initialize audio unit: %u", err};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"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))
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not get input format: %u", err};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Could not get input format: %u", err};
|
||||
|
||||
// Set up the requested format description
|
||||
switch(mDevice->FmtType)
|
||||
@@ -536,7 +545,7 @@ void CoreAudioCapture::open(const ALCchar *name)
|
||||
case DevFmtX61:
|
||||
case DevFmtX71:
|
||||
case DevFmtAmbi3D:
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s not supported",
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "%s not supported",
|
||||
DevFmtChannelsString(mDevice->FmtChans)};
|
||||
}
|
||||
|
||||
@@ -561,7 +570,8 @@ void CoreAudioCapture::open(const ALCchar *name)
|
||||
err = AudioUnitSetProperty(mAudioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output,
|
||||
1, &outputFormat, sizeof(outputFormat));
|
||||
if(err != noErr)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not set input format: %u", err};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Could not set input format: %u", err};
|
||||
|
||||
/* Calculate the minimum AudioUnit output format frame count for the pre-
|
||||
* conversion ring buffer. Ensure at least 100ms for the total buffer.
|
||||
@@ -571,7 +581,7 @@ void CoreAudioCapture::open(const ALCchar *name)
|
||||
static_cast<UInt32>(outputFormat.mSampleRate)/10);
|
||||
FrameCount64 += MaxResamplerPadding;
|
||||
if(FrameCount64 > std::numeric_limits<int32_t>::max())
|
||||
throw al::backend_exception{ALC_INVALID_VALUE,
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Calculated frame count is too large: %" PRIu64, FrameCount64};
|
||||
|
||||
UInt32 outputFrameCount{};
|
||||
@@ -579,8 +589,8 @@ void CoreAudioCapture::open(const ALCchar *name)
|
||||
err = AudioUnitGetProperty(mAudioUnit, kAudioUnitProperty_MaximumFramesPerSlice,
|
||||
kAudioUnitScope_Global, 0, &outputFrameCount, &propertySize);
|
||||
if(err != noErr || propertySize != sizeof(outputFrameCount))
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not get input frame count: %u",
|
||||
err};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Could not get input frame count: %u", err};
|
||||
|
||||
outputFrameCount = static_cast<UInt32>(maxu64(outputFrameCount, FrameCount64));
|
||||
mRing = RingBuffer::Create(outputFrameCount, mFrameSize, false);
|
||||
@@ -599,7 +609,8 @@ void CoreAudioCapture::start()
|
||||
{
|
||||
OSStatus err{AudioOutputUnitStart(mAudioUnit)};
|
||||
if(err != noErr)
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "AudioOutputUnitStart failed: %d", err};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"AudioOutputUnitStart failed: %d", err};
|
||||
}
|
||||
|
||||
void CoreAudioCapture::stop()
|
||||
|
||||
+15
-12
@@ -338,8 +338,8 @@ void DSoundPlayback::open(const ALCchar *name)
|
||||
iter = std::find_if(PlaybackDevices.cbegin(), PlaybackDevices.cend(),
|
||||
[&id](const DevMap &entry) -> bool { return entry.guid == id; });
|
||||
if(iter == PlaybackDevices.cend())
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found",
|
||||
name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice,
|
||||
"Device name \"%s\" not found", name};
|
||||
}
|
||||
guid = &iter->guid;
|
||||
}
|
||||
@@ -354,7 +354,8 @@ void DSoundPlayback::open(const ALCchar *name)
|
||||
if(SUCCEEDED(hr))
|
||||
hr = mDS->SetCooperativeLevel(GetForegroundWindow(), DSSCL_PRIORITY);
|
||||
if(FAILED(hr))
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device init failed: 0x%08lx", hr};
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "Device init failed: 0x%08lx",
|
||||
hr};
|
||||
|
||||
mDevice->DeviceName = name;
|
||||
}
|
||||
@@ -542,8 +543,8 @@ void DSoundPlayback::start()
|
||||
mThread = std::thread{std::mem_fn(&DSoundPlayback::mixerProc), this};
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
|
||||
e.what()};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to start mixing thread: %s", e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -624,8 +625,8 @@ void DSoundCapture::open(const ALCchar *name)
|
||||
iter = std::find_if(CaptureDevices.cbegin(), CaptureDevices.cend(),
|
||||
[&id](const DevMap &entry) -> bool { return entry.guid == id; });
|
||||
if(iter == CaptureDevices.cend())
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found",
|
||||
name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice,
|
||||
"Device name \"%s\" not found", name};
|
||||
}
|
||||
guid = &iter->guid;
|
||||
}
|
||||
@@ -636,8 +637,8 @@ void DSoundCapture::open(const ALCchar *name)
|
||||
case DevFmtUShort:
|
||||
case DevFmtUInt:
|
||||
WARN("%s capture samples not supported\n", DevFmtTypeString(mDevice->FmtType));
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s capture samples not supported",
|
||||
DevFmtTypeString(mDevice->FmtType)};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"%s capture samples not supported", DevFmtTypeString(mDevice->FmtType)};
|
||||
|
||||
case DevFmtUByte:
|
||||
case DevFmtShort:
|
||||
@@ -658,7 +659,7 @@ void DSoundCapture::open(const ALCchar *name)
|
||||
case DevFmtX71: InputType.dwChannelMask = X7DOT1; break;
|
||||
case DevFmtAmbi3D:
|
||||
WARN("%s capture not supported\n", DevFmtChannelsString(mDevice->FmtChans));
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s capture not supported",
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "%s capture not supported",
|
||||
DevFmtChannelsString(mDevice->FmtChans)};
|
||||
}
|
||||
|
||||
@@ -709,7 +710,8 @@ void DSoundCapture::open(const ALCchar *name)
|
||||
mDSC->Release();
|
||||
mDSC = nullptr;
|
||||
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device init failed: 0x%08lx", hr};
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "Device init failed: 0x%08lx",
|
||||
hr};
|
||||
}
|
||||
|
||||
mBufferBytes = DSCBDescription.dwBufferBytes;
|
||||
@@ -722,7 +724,8 @@ void DSoundCapture::start()
|
||||
{
|
||||
const HRESULT hr{mDSCbuffer->Start(DSCBSTART_LOOPING)};
|
||||
if(FAILED(hr))
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failure starting capture: 0x%lx", hr};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failure starting capture: 0x%lx", hr};
|
||||
}
|
||||
|
||||
void DSoundCapture::stop()
|
||||
|
||||
@@ -366,7 +366,8 @@ void JackPlayback::open(const ALCchar *name)
|
||||
{ return entry.mName == name; };
|
||||
auto iter = std::find_if(PlaybackList.cbegin(), PlaybackList.cend(), check_name);
|
||||
if(iter == PlaybackList.cend())
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice,
|
||||
"Device name \"%s\" not found", name};
|
||||
mPortPattern = iter->mPattern;
|
||||
}
|
||||
|
||||
@@ -374,8 +375,8 @@ void JackPlayback::open(const ALCchar *name)
|
||||
jack_status_t status;
|
||||
mClient = jack_client_open(client_name, ClientOptions, &status, nullptr);
|
||||
if(mClient == nullptr)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to open client connection: 0x%02x",
|
||||
status};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to open client connection: 0x%02x", status};
|
||||
|
||||
if((status&JackServerStarted))
|
||||
TRACE("JACK server started\n");
|
||||
@@ -448,7 +449,7 @@ bool JackPlayback::reset()
|
||||
void JackPlayback::start()
|
||||
{
|
||||
if(jack_activate(mClient))
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to activate client"};
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "Failed to activate client"};
|
||||
|
||||
const char *devname{mDevice->DeviceName.c_str()};
|
||||
if(ConfigValueBool(devname, "jack", "connect-ports").value_or(true))
|
||||
@@ -458,7 +459,8 @@ void JackPlayback::start()
|
||||
if(ports == nullptr)
|
||||
{
|
||||
jack_deactivate(mClient);
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "No physical playback ports found"};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"No physical playback ports found"};
|
||||
}
|
||||
auto connect_port = [this](const jack_port_t *port, const char *pname) -> bool
|
||||
{
|
||||
@@ -500,8 +502,8 @@ void JackPlayback::start()
|
||||
catch(std::exception& e) {
|
||||
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()};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to start mixing thread: %s", e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,8 @@ void NullBackend::open(const ALCchar *name)
|
||||
if(!name)
|
||||
name = nullDevice;
|
||||
else if(strcmp(name, nullDevice) != 0)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found",
|
||||
name};
|
||||
|
||||
mDevice->DeviceName = name;
|
||||
}
|
||||
@@ -129,8 +130,8 @@ void NullBackend::start()
|
||||
mThread = std::thread{std::mem_fn(&NullBackend::mixerProc), this};
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
|
||||
e.what()};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to start mixing thread: %s", e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-9
@@ -60,14 +60,15 @@ void OboePlayback::open(const ALCchar *name)
|
||||
if(!name)
|
||||
name = device_name;
|
||||
else if(std::strcmp(name, device_name) != 0)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found",
|
||||
name};
|
||||
|
||||
/* Open a basic output stream, just to ensure it can work. */
|
||||
oboe::Result result{oboe::AudioStreamBuilder{}.setDirection(oboe::Direction::Output)
|
||||
->setPerformanceMode(oboe::PerformanceMode::LowLatency)
|
||||
->openManagedStream(mStream)};
|
||||
if(result != oboe::Result::OK)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to create stream: %s",
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "Failed to create stream: %s",
|
||||
oboe::convertToText(result)};
|
||||
|
||||
mDevice->DeviceName = name;
|
||||
@@ -132,7 +133,7 @@ bool OboePlayback::reset()
|
||||
result = builder.openManagedStream(mStream);
|
||||
}
|
||||
if(result != oboe::Result::OK)
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to create stream: %s",
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "Failed to create stream: %s",
|
||||
oboe::convertToText(result)};
|
||||
TRACE("Got stream with properties:\n%s", oboe::convertToText(mStream.get()));
|
||||
|
||||
@@ -161,8 +162,8 @@ bool OboePlayback::reset()
|
||||
break;
|
||||
default:
|
||||
if(mStream->getChannelCount() < 1)
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Got unhandled channel count: %d",
|
||||
mStream->getChannelCount()};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Got unhandled channel count: %d", mStream->getChannelCount()};
|
||||
/* Assume first two channels are front left/right. We can do a stereo
|
||||
* mix and keep the other channels silent.
|
||||
*/
|
||||
@@ -181,8 +182,8 @@ bool OboePlayback::reset()
|
||||
break;
|
||||
case oboe::AudioFormat::Unspecified:
|
||||
case oboe::AudioFormat::Invalid:
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Got unhandled sample type: %s",
|
||||
oboe::convertToText(mStream->getFormat())};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Got unhandled sample type: %s", oboe::convertToText(mStream->getFormat())};
|
||||
}
|
||||
mDevice->Frequency = static_cast<uint32_t>(mStream->getSampleRate());
|
||||
|
||||
@@ -203,7 +204,7 @@ void OboePlayback::start()
|
||||
{
|
||||
const oboe::Result result{mStream->start()};
|
||||
if(result != oboe::Result::OK)
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start stream: %s",
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "Failed to start stream: %s",
|
||||
oboe::convertToText(result)};
|
||||
}
|
||||
|
||||
@@ -211,7 +212,7 @@ void OboePlayback::stop()
|
||||
{
|
||||
oboe::Result result{mStream->stop()};
|
||||
if(result != oboe::Result::OK)
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to stop stream: %s",
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "Failed to stop stream: %s",
|
||||
oboe::convertToText(result)};
|
||||
}
|
||||
|
||||
|
||||
+12
-9
@@ -306,7 +306,8 @@ void OpenSLPlayback::open(const ALCchar *name)
|
||||
if(!name)
|
||||
name = opensl_device;
|
||||
else if(strcmp(name, opensl_device) != 0)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found",
|
||||
name};
|
||||
|
||||
// create engine
|
||||
SLresult result{slCreateEngine(&mEngineObj, 0, nullptr, 0, nullptr, nullptr)};
|
||||
@@ -343,7 +344,7 @@ void OpenSLPlayback::open(const ALCchar *name)
|
||||
mEngineObj = nullptr;
|
||||
mEngine = nullptr;
|
||||
|
||||
throw al::backend_exception{ALC_INVALID_VALUE,
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to initialize OpenSL device: 0x%08x", result};
|
||||
}
|
||||
|
||||
@@ -554,16 +555,16 @@ void OpenSLPlayback::start()
|
||||
PRINTERR(result, "bufferQueue->RegisterCallback");
|
||||
}
|
||||
if(SL_RESULT_SUCCESS != result)
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to register callback: 0x%08x",
|
||||
result};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to register callback: 0x%08x", result};
|
||||
|
||||
try {
|
||||
mKillNow.store(false, std::memory_order_release);
|
||||
mThread = std::thread(std::mem_fn(&OpenSLPlayback::mixerProc), this);
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
|
||||
e.what()};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to start mixing thread: %s", e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -675,7 +676,8 @@ void OpenSLCapture::open(const ALCchar* name)
|
||||
if(!name)
|
||||
name = opensl_device;
|
||||
else if(strcmp(name, opensl_device) != 0)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found",
|
||||
name};
|
||||
|
||||
SLresult result{slCreateEngine(&mEngineObj, 0, nullptr, 0, nullptr, nullptr)};
|
||||
PRINTERR(result, "slCreateEngine");
|
||||
@@ -829,7 +831,7 @@ void OpenSLCapture::open(const ALCchar* name)
|
||||
mEngineObj = nullptr;
|
||||
mEngine = nullptr;
|
||||
|
||||
throw al::backend_exception{ALC_INVALID_VALUE,
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to initialize OpenSL device: 0x%08x", result};
|
||||
}
|
||||
|
||||
@@ -848,7 +850,8 @@ void OpenSLCapture::start()
|
||||
PRINTERR(result, "record->SetRecordState");
|
||||
}
|
||||
if(SL_RESULT_SUCCESS != result)
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start capture: 0x%08x", result};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to start capture: 0x%08x", result};
|
||||
}
|
||||
|
||||
void OpenSLCapture::stop()
|
||||
|
||||
+16
-13
@@ -325,13 +325,14 @@ void OSSPlayback::open(const ALCchar *name)
|
||||
{ return entry.name == name; }
|
||||
);
|
||||
if(iter == PlaybackDevices.cend())
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice,
|
||||
"Device name \"%s\" not found", name};
|
||||
devname = iter->device_name.c_str();
|
||||
}
|
||||
|
||||
mFd = ::open(devname, O_WRONLY);
|
||||
if(mFd == -1)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not open %s: %s", devname,
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Could not open %s: %s", devname,
|
||||
strerror(errno)};
|
||||
|
||||
mDevice->DeviceName = name;
|
||||
@@ -422,8 +423,8 @@ void OSSPlayback::start()
|
||||
mThread = std::thread{std::mem_fn(&OSSPlayback::mixerProc), this};
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
|
||||
e.what()};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to start mixing thread: %s", e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -528,13 +529,14 @@ void OSScapture::open(const ALCchar *name)
|
||||
{ return entry.name == name; }
|
||||
);
|
||||
if(iter == CaptureDevices.cend())
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice,
|
||||
"Device name \"%s\" not found", name};
|
||||
devname = iter->device_name.c_str();
|
||||
}
|
||||
|
||||
mFd = ::open(devname, O_RDONLY);
|
||||
if(mFd == -1)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not open %s: %s", devname,
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Could not open %s: %s", devname,
|
||||
strerror(errno)};
|
||||
|
||||
int ossFormat{};
|
||||
@@ -553,8 +555,8 @@ void OSScapture::open(const ALCchar *name)
|
||||
case DevFmtInt:
|
||||
case DevFmtUInt:
|
||||
case DevFmtFloat:
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s capture samples not supported",
|
||||
DevFmtTypeString(mDevice->FmtType)};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"%s capture samples not supported", DevFmtTypeString(mDevice->FmtType)};
|
||||
}
|
||||
|
||||
ALuint periods{4};
|
||||
@@ -567,7 +569,8 @@ void OSScapture::open(const ALCchar *name)
|
||||
|
||||
audio_buf_info info{};
|
||||
#define CHECKERR(func) if((func) < 0) { \
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, #func " failed: %s", strerror(errno)}; \
|
||||
throw al::backend_exception{al::backend_error::DeviceError, #func " failed: %s", \
|
||||
strerror(errno)}; \
|
||||
}
|
||||
CHECKERR(ioctl(mFd, SNDCTL_DSP_SETFRAGMENT, &numFragmentsLogSize));
|
||||
CHECKERR(ioctl(mFd, SNDCTL_DSP_SETFMT, &ossFormat));
|
||||
@@ -577,14 +580,14 @@ void OSScapture::open(const ALCchar *name)
|
||||
#undef CHECKERR
|
||||
|
||||
if(mDevice->channelsFromFmt() != numChannels)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE,
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"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)))
|
||||
throw al::backend_exception{ALC_INVALID_VALUE,
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to set %s samples, got OSS format %#x", DevFmtTypeString(mDevice->FmtType),
|
||||
ossFormat};
|
||||
|
||||
@@ -600,8 +603,8 @@ void OSScapture::start()
|
||||
mThread = std::thread{std::mem_fn(&OSScapture::recordProc), this};
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start recording thread: %s",
|
||||
e.what()};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to start recording thread: %s", e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,8 @@ void PortPlayback::open(const ALCchar *name)
|
||||
if(!name)
|
||||
name = pa_device;
|
||||
else if(strcmp(name, pa_device) != 0)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found",
|
||||
name};
|
||||
|
||||
mUpdateSize = mDevice->UpdateSize;
|
||||
|
||||
@@ -166,7 +167,7 @@ retry_open:
|
||||
mParams.sampleFormat = paInt16;
|
||||
goto retry_open;
|
||||
}
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to open stream: %s",
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Failed to open stream: %s",
|
||||
Pa_GetErrorText(err)};
|
||||
}
|
||||
|
||||
@@ -213,7 +214,7 @@ void PortPlayback::start()
|
||||
{
|
||||
const PaError err{Pa_StartStream(mStream)};
|
||||
if(err == paNoError)
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start playback: %s",
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "Failed to start playback: %s",
|
||||
Pa_GetErrorText(err)};
|
||||
}
|
||||
|
||||
@@ -275,7 +276,8 @@ void PortCapture::open(const ALCchar *name)
|
||||
if(!name)
|
||||
name = pa_device;
|
||||
else if(strcmp(name, pa_device) != 0)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found",
|
||||
name};
|
||||
|
||||
ALuint samples{mDevice->BufferSize};
|
||||
samples = maxu(samples, 100 * mDevice->Frequency / 1000);
|
||||
@@ -308,7 +310,7 @@ void PortCapture::open(const ALCchar *name)
|
||||
break;
|
||||
case DevFmtUInt:
|
||||
case DevFmtUShort:
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s samples not supported",
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "%s samples not supported",
|
||||
DevFmtTypeString(mDevice->FmtType)};
|
||||
}
|
||||
mParams.channelCount = static_cast<int>(mDevice->channelsFromFmt());
|
||||
@@ -316,7 +318,7 @@ void PortCapture::open(const ALCchar *name)
|
||||
PaError err{Pa_OpenStream(&mStream, &mParams, nullptr, mDevice->Frequency,
|
||||
paFramesPerBufferUnspecified, paNoFlag, &PortCapture::readCallbackC, this)};
|
||||
if(err != paNoError)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to open stream: %s",
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Failed to open stream: %s",
|
||||
Pa_GetErrorText(err)};
|
||||
|
||||
mDevice->DeviceName = name;
|
||||
@@ -327,8 +329,8 @@ void PortCapture::start()
|
||||
{
|
||||
const PaError err{Pa_StartStream(mStream)};
|
||||
if(err != paNoError)
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start recording: %s",
|
||||
Pa_GetErrorText(err)};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to start recording: %s", Pa_GetErrorText(err)};
|
||||
}
|
||||
|
||||
void PortCapture::stop()
|
||||
|
||||
+17
-14
@@ -511,7 +511,8 @@ pa_context *PulseMainloop::connectContext(std::unique_lock<std::mutex> &plock)
|
||||
}
|
||||
|
||||
pa_context *context{pa_context_new(pa_mainloop_get_api(mMainloop), name)};
|
||||
if(!context) throw al::backend_exception{ALC_OUT_OF_MEMORY, "pa_context_new() failed"};
|
||||
if(!context) throw al::backend_exception{al::backend_error::OutOfMemory,
|
||||
"pa_context_new() failed"};
|
||||
|
||||
pa_context_set_state_callback(context, &contextStateCallbackC, this);
|
||||
|
||||
@@ -536,7 +537,7 @@ pa_context *PulseMainloop::connectContext(std::unique_lock<std::mutex> &plock)
|
||||
if(err < 0)
|
||||
{
|
||||
pa_context_unref(context);
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Context did not connect (%s)",
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "Context did not connect (%s)",
|
||||
pa_strerror(err)};
|
||||
}
|
||||
|
||||
@@ -550,7 +551,7 @@ pa_stream *PulseMainloop::connectStream(const char *device_name,
|
||||
const char *stream_id{(type==BackendType::Playback) ? "Playback Stream" : "Capture Stream"};
|
||||
pa_stream *stream{pa_stream_new(context, stream_id, spec, chanmap)};
|
||||
if(!stream)
|
||||
throw al::backend_exception{ALC_OUT_OF_MEMORY, "pa_stream_new() failed (%s)",
|
||||
throw al::backend_exception{al::backend_error::OutOfMemory, "pa_stream_new() failed (%s)",
|
||||
pa_strerror(pa_context_errno(context))};
|
||||
|
||||
pa_stream_set_state_callback(stream, &streamStateCallbackC, this);
|
||||
@@ -561,8 +562,8 @@ pa_stream *PulseMainloop::connectStream(const char *device_name,
|
||||
if(err < 0)
|
||||
{
|
||||
pa_stream_unref(stream);
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s did not connect (%s)", stream_id,
|
||||
pa_strerror(err)};
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "%s did not connect (%s)",
|
||||
stream_id, pa_strerror(err)};
|
||||
}
|
||||
|
||||
pa_stream_state_t state;
|
||||
@@ -572,8 +573,8 @@ pa_stream *PulseMainloop::connectStream(const char *device_name,
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
pa_stream_unref(stream);
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s did not get ready (%s)", stream_id,
|
||||
pa_strerror(err)};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"%s did not get ready (%s)", stream_id, pa_strerror(err)};
|
||||
}
|
||||
|
||||
mCondVar.wait(plock);
|
||||
@@ -869,7 +870,8 @@ void PulsePlayback::open(const ALCchar *name)
|
||||
auto iter = std::find_if(PlaybackDevices.cbegin(), PlaybackDevices.cend(),
|
||||
[name](const DevMap &entry) -> bool { return entry.name == name; });
|
||||
if(iter == PlaybackDevices.cend())
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice,
|
||||
"Device name \"%s\" not found", name};
|
||||
pulse_name = iter->device_name.c_str();
|
||||
dev_name = iter->name.c_str();
|
||||
}
|
||||
@@ -1003,7 +1005,7 @@ bool PulsePlayback::reset()
|
||||
mSpec.rate = mDevice->Frequency;
|
||||
mSpec.channels = static_cast<uint8_t>(mDevice->channelsFromFmt());
|
||||
if(pa_sample_spec_valid(&mSpec) == 0)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Invalid sample spec"};
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "Invalid sample spec"};
|
||||
|
||||
const ALuint frame_size{static_cast<ALuint>(pa_frame_size(&mSpec))};
|
||||
mAttr.maxlength = ~0u;
|
||||
@@ -1221,7 +1223,8 @@ void PulseCapture::open(const ALCchar *name)
|
||||
auto iter = std::find_if(CaptureDevices.cbegin(), CaptureDevices.cend(),
|
||||
[name](const DevMap &entry) -> bool { return entry.name == name; });
|
||||
if(iter == CaptureDevices.cend())
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice,
|
||||
"Device name \"%s\" not found", name};
|
||||
pulse_name = iter->device_name.c_str();
|
||||
mDevice->DeviceName = iter->name;
|
||||
}
|
||||
@@ -1254,7 +1257,7 @@ void PulseCapture::open(const ALCchar *name)
|
||||
chanmap = X71ChanMap;
|
||||
break;
|
||||
case DevFmtAmbi3D:
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s capture not supported",
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "%s capture not supported",
|
||||
DevFmtChannelsString(mDevice->FmtChans)};
|
||||
}
|
||||
SetChannelOrderFromMap(mDevice, chanmap);
|
||||
@@ -1277,13 +1280,13 @@ void PulseCapture::open(const ALCchar *name)
|
||||
case DevFmtByte:
|
||||
case DevFmtUShort:
|
||||
case DevFmtUInt:
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s capture samples not supported",
|
||||
DevFmtTypeString(mDevice->FmtType)};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"%s capture samples not supported", DevFmtTypeString(mDevice->FmtType)};
|
||||
}
|
||||
mSpec.rate = mDevice->Frequency;
|
||||
mSpec.channels = static_cast<uint8_t>(mDevice->channelsFromFmt());
|
||||
if(pa_sample_spec_valid(&mSpec) == 0)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Invalid sample format"};
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "Invalid sample format"};
|
||||
|
||||
const ALuint frame_size{static_cast<ALuint>(pa_frame_size(&mSpec))};
|
||||
const ALuint samples{maxu(mDevice->BufferSize, 100 * mDevice->Frequency / 1000)};
|
||||
|
||||
@@ -123,7 +123,7 @@ void Sdl2Backend::open(const ALCchar *name)
|
||||
SDL_AUDIO_ALLOW_ANY_CHANGE);
|
||||
}
|
||||
if(mDeviceID == 0)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s", SDL_GetError()};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "%s", SDL_GetError()};
|
||||
|
||||
mDevice->Frequency = static_cast<ALuint>(have.freq);
|
||||
|
||||
@@ -132,8 +132,8 @@ void Sdl2Backend::open(const ALCchar *name)
|
||||
else if(have.channels == 2)
|
||||
mDevice->FmtChans = DevFmtStereo;
|
||||
else
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Unhandled SDL channel count: %d",
|
||||
int{have.channels}};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Unhandled SDL channel count: %d", int{have.channels}};
|
||||
|
||||
switch(have.format)
|
||||
{
|
||||
@@ -144,7 +144,7 @@ void Sdl2Backend::open(const ALCchar *name)
|
||||
case AUDIO_S32SYS: mDevice->FmtType = DevFmtInt; break;
|
||||
case AUDIO_F32SYS: mDevice->FmtType = DevFmtFloat; break;
|
||||
default:
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Unhandled SDL format: 0x%04x",
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "Unhandled SDL format: 0x%04x",
|
||||
have.format};
|
||||
}
|
||||
mDevice->UpdateSize = have.samples;
|
||||
|
||||
+18
-15
@@ -120,11 +120,12 @@ void SndioPlayback::open(const ALCchar *name)
|
||||
if(!name)
|
||||
name = sndio_device;
|
||||
else if(strcmp(name, sndio_device) != 0)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found",
|
||||
name};
|
||||
|
||||
mSndHandle = sio_open(nullptr, SIO_PLAY, 0);
|
||||
if(mSndHandle == nullptr)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not open backend device"};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Could not open backend device"};
|
||||
|
||||
mDevice->DeviceName = name;
|
||||
}
|
||||
@@ -263,7 +264,7 @@ bool SndioPlayback::reset()
|
||||
void SndioPlayback::start()
|
||||
{
|
||||
if(!sio_start(mSndHandle))
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Error starting playback"};
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "Error starting playback"};
|
||||
|
||||
try {
|
||||
mKillNow.store(false, std::memory_order_release);
|
||||
@@ -271,8 +272,8 @@ void SndioPlayback::start()
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
sio_stop(mSndHandle);
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
|
||||
e.what()};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to start mixing thread: %s", e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,11 +369,12 @@ void SndioCapture::open(const ALCchar *name)
|
||||
if(!name)
|
||||
name = sndio_device;
|
||||
else if(strcmp(name, sndio_device) != 0)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found",
|
||||
name};
|
||||
|
||||
mSndHandle = sio_open(nullptr, SIO_REC, 0);
|
||||
if(mSndHandle == nullptr)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not open backend device"};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Could not open backend device"};
|
||||
|
||||
sio_par par;
|
||||
sio_initpar(&par);
|
||||
@@ -404,8 +406,8 @@ void SndioCapture::open(const ALCchar *name)
|
||||
par.sig = 0;
|
||||
break;
|
||||
case DevFmtFloat:
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s capture samples not supported",
|
||||
DevFmtTypeString(mDevice->FmtType)};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"%s capture samples not supported", DevFmtTypeString(mDevice->FmtType)};
|
||||
}
|
||||
par.bits = par.bps * 8;
|
||||
par.le = SIO_LE_NATIVE;
|
||||
@@ -420,10 +422,11 @@ void SndioCapture::open(const ALCchar *name)
|
||||
mDevice->BufferSize = par.appbufsz;
|
||||
|
||||
if(!sio_setpar(mSndHandle, &par) || !sio_getpar(mSndHandle, &par))
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to set device praameters"};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to set device praameters"};
|
||||
|
||||
if(par.bits != par.bps*8)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE,
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Padded samples not supported (got %u of %u bits)", par.bits, par.bps*8};
|
||||
|
||||
if(!((mDevice->FmtType == DevFmtByte && par.bits == 8 && par.sig != 0)
|
||||
@@ -433,7 +436,7 @@ void SndioCapture::open(const ALCchar *name)
|
||||
|| (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,
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to set format %s %s %uhz, got %c%u %u-channel %uhz instead",
|
||||
DevFmtTypeString(mDevice->FmtType), DevFmtChannelsString(mDevice->FmtChans),
|
||||
mDevice->Frequency, par.sig?'s':'u', par.bits, par.rchan, par.rate};
|
||||
@@ -448,7 +451,7 @@ void SndioCapture::open(const ALCchar *name)
|
||||
void SndioCapture::start()
|
||||
{
|
||||
if(!sio_start(mSndHandle))
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Error starting capture"};
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "Error starting capture"};
|
||||
|
||||
try {
|
||||
mKillNow.store(false, std::memory_order_release);
|
||||
@@ -456,8 +459,8 @@ void SndioCapture::start()
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
sio_stop(mSndHandle);
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
|
||||
e.what()};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to start capture thread: %s", e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -144,11 +144,12 @@ void SolarisBackend::open(const ALCchar *name)
|
||||
if(!name)
|
||||
name = solaris_device;
|
||||
else if(strcmp(name, solaris_device) != 0)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found",
|
||||
name};
|
||||
|
||||
mFd = ::open(solaris_driver.c_str(), O_WRONLY);
|
||||
if(mFd == -1)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not open %s: %s",
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Could not open %s: %s",
|
||||
solaris_driver.c_str(), strerror(errno)};
|
||||
|
||||
mDevice->DeviceName = name;
|
||||
@@ -233,8 +234,8 @@ void SolarisBackend::start()
|
||||
mThread = std::thread{std::mem_fn(&SolarisBackend::mixerProc), this};
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
|
||||
e.what()};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to start mixing thread: %s", e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-7
@@ -844,7 +844,8 @@ void WasapiPlayback::open(const ALCchar *name)
|
||||
|
||||
mDevId.clear();
|
||||
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device init failed: 0x%08lx", hr};
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "Device init failed: 0x%08lx",
|
||||
hr};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -887,7 +888,7 @@ bool WasapiPlayback::reset()
|
||||
{
|
||||
HRESULT hr{pushMessage(MsgType::ResetDevice).get()};
|
||||
if(FAILED(hr))
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "0x%08lx", hr};
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "0x%08lx", hr};
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1151,7 +1152,8 @@ void WasapiPlayback::start()
|
||||
{
|
||||
const HRESULT hr{pushMessage(MsgType::StartDevice).get()};
|
||||
if(FAILED(hr))
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start playback: 0x%lx", hr};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to start playback: 0x%lx", hr};
|
||||
}
|
||||
|
||||
HRESULT WasapiPlayback::startProxy()
|
||||
@@ -1410,15 +1412,16 @@ void WasapiCapture::open(const ALCchar *name)
|
||||
|
||||
mDevId.clear();
|
||||
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device init failed: 0x%08lx", hr};
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "Device init failed: 0x%08lx",
|
||||
hr};
|
||||
}
|
||||
|
||||
hr = pushMessage(MsgType::ResetDevice).get();
|
||||
if(FAILED(hr))
|
||||
{
|
||||
if(hr == E_OUTOFMEMORY)
|
||||
throw al::backend_exception{ALC_OUT_OF_MEMORY, "Out of memory"};
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device reset failed"};
|
||||
throw al::backend_exception{al::backend_error::OutOfMemory, "Out of memory"};
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "Device reset failed"};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1714,7 +1717,8 @@ void WasapiCapture::start()
|
||||
{
|
||||
const HRESULT hr{pushMessage(MsgType::StartDevice).get()};
|
||||
if(FAILED(hr))
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start recording: 0x%lx", hr};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to start recording: 0x%lx", hr};
|
||||
}
|
||||
|
||||
HRESULT WasapiCapture::startProxy()
|
||||
|
||||
@@ -205,12 +205,14 @@ int WaveBackend::mixerProc()
|
||||
void WaveBackend::open(const ALCchar *name)
|
||||
{
|
||||
const char *fname{GetConfigValue(nullptr, "wave", "file", "")};
|
||||
if(!fname[0]) throw al::backend_exception{ALC_INVALID_VALUE, "No wave output filename"};
|
||||
if(!fname[0]) throw al::backend_exception{al::backend_error::NoDevice,
|
||||
"No wave output filename"};
|
||||
|
||||
if(!name)
|
||||
name = waveDevice;
|
||||
else if(strcmp(name, waveDevice) != 0)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found",
|
||||
name};
|
||||
|
||||
#ifdef _WIN32
|
||||
{
|
||||
@@ -221,8 +223,8 @@ void WaveBackend::open(const ALCchar *name)
|
||||
mFile = fopen(fname, "wb");
|
||||
#endif
|
||||
if(!mFile)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not open file '%s': %s", fname,
|
||||
strerror(errno)};
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "Could not open file '%s': %s",
|
||||
fname, strerror(errno)};
|
||||
|
||||
mDevice->DeviceName = name;
|
||||
}
|
||||
@@ -339,8 +341,8 @@ void WaveBackend::start()
|
||||
mThread = std::thread{std::mem_fn(&WaveBackend::mixerProc), this};
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
|
||||
e.what()};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to start mixing thread: %s", e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-10
@@ -220,7 +220,8 @@ void WinMMPlayback::open(const ALCchar *name)
|
||||
std::find(PlaybackDevices.cbegin(), PlaybackDevices.cend(), name) :
|
||||
PlaybackDevices.cbegin();
|
||||
if(iter == PlaybackDevices.cend())
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found",
|
||||
name};
|
||||
auto DeviceID = static_cast<UINT>(std::distance(PlaybackDevices.cbegin(), iter));
|
||||
|
||||
retry_open:
|
||||
@@ -254,7 +255,7 @@ retry_open:
|
||||
mDevice->FmtType = DevFmtShort;
|
||||
goto retry_open;
|
||||
}
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "waveOutOpen failed: %u", res};
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "waveOutOpen failed: %u", res};
|
||||
}
|
||||
|
||||
mDevice->DeviceName = PlaybackDevices[DeviceID];
|
||||
@@ -344,8 +345,8 @@ void WinMMPlayback::start()
|
||||
mThread = std::thread{std::mem_fn(&WinMMPlayback::mixerProc), this};
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start mixing thread: %s",
|
||||
e.what()};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to start mixing thread: %s", e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,7 +462,8 @@ void WinMMCapture::open(const ALCchar *name)
|
||||
std::find(CaptureDevices.cbegin(), CaptureDevices.cend(), name) :
|
||||
CaptureDevices.cbegin();
|
||||
if(iter == CaptureDevices.cend())
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name};
|
||||
throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found",
|
||||
name};
|
||||
auto DeviceID = static_cast<UINT>(std::distance(CaptureDevices.cbegin(), iter));
|
||||
|
||||
switch(mDevice->FmtChans)
|
||||
@@ -476,7 +478,7 @@ void WinMMCapture::open(const ALCchar *name)
|
||||
case DevFmtX61:
|
||||
case DevFmtX71:
|
||||
case DevFmtAmbi3D:
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s capture not supported",
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "%s capture not supported",
|
||||
DevFmtChannelsString(mDevice->FmtChans)};
|
||||
}
|
||||
|
||||
@@ -491,7 +493,7 @@ void WinMMCapture::open(const ALCchar *name)
|
||||
case DevFmtByte:
|
||||
case DevFmtUShort:
|
||||
case DevFmtUInt:
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s samples not supported",
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "%s samples not supported",
|
||||
DevFmtTypeString(mDevice->FmtType)};
|
||||
}
|
||||
|
||||
@@ -509,7 +511,7 @@ void WinMMCapture::open(const ALCchar *name)
|
||||
reinterpret_cast<DWORD_PTR>(&WinMMCapture::waveInProcC),
|
||||
reinterpret_cast<DWORD_PTR>(this), CALLBACK_FUNCTION)};
|
||||
if(res != MMSYSERR_NOERROR)
|
||||
throw al::backend_exception{ALC_INVALID_VALUE, "waveInOpen failed: %u", res};
|
||||
throw al::backend_exception{al::backend_error::DeviceError, "waveInOpen failed: %u", res};
|
||||
|
||||
// Ensure each buffer is 50ms each
|
||||
DWORD BufferSize{mFormat.nAvgBytesPerSec / 20u};
|
||||
@@ -551,8 +553,8 @@ void WinMMCapture::start()
|
||||
waveInStart(mInHdl);
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
throw al::backend_exception{ALC_INVALID_DEVICE, "Failed to start recording thread: %s",
|
||||
e.what()};
|
||||
throw al::backend_exception{al::backend_error::DeviceError,
|
||||
"Failed to start recording thread: %s", e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user