aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends/pulseaudio.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'alc/backends/pulseaudio.cpp')
-rw-r--r--alc/backends/pulseaudio.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp
index 57a6619e..1f6b8fae 100644
--- a/alc/backends/pulseaudio.cpp
+++ b/alc/backends/pulseaudio.cpp
@@ -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)};