diff options
author | Max Kellermann <max@duempel.org> | 2014-12-29 22:42:52 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-12-29 22:42:52 +0100 |
commit | 99e6409a67de5f4af181ac11b2b9fd9b4515e3fa (patch) | |
tree | 6778503679c780c82fe3afc56a345588ef32e829 /src | |
parent | 6a0a5f9693a69d2b8453d77155d2b238decf964d (diff) | |
download | mpd-99e6409a67de5f4af181ac11b2b9fd9b4515e3fa.tar.gz mpd-99e6409a67de5f4af181ac11b2b9fd9b4515e3fa.tar.xz mpd-99e6409a67de5f4af181ac11b2b9fd9b4515e3fa.zip |
{mixer,output}/pulse: move code to LogPulseError()
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/pulse/LogError.cxx | 33 | ||||
-rw-r--r-- | src/lib/pulse/LogError.hxx | 28 | ||||
-rw-r--r-- | src/mixer/plugins/PulseMixerPlugin.cxx | 12 | ||||
-rw-r--r-- | src/output/plugins/PulseOutputPlugin.cxx | 10 |
4 files changed, 70 insertions, 13 deletions
diff --git a/src/lib/pulse/LogError.cxx b/src/lib/pulse/LogError.cxx new file mode 100644 index 000000000..7f84b41e5 --- /dev/null +++ b/src/lib/pulse/LogError.cxx @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" +#include "LogError.hxx" +#include "Domain.hxx" +#include "Log.hxx" + +#include <pulse/context.h> +#include <pulse/error.h> + +void +LogPulseError(pa_context *context, const char *prefix) +{ + const int e = pa_context_errno(context); + FormatError(pulse_domain, "%s: %s", prefix, pa_strerror(e)); +} diff --git a/src/lib/pulse/LogError.hxx b/src/lib/pulse/LogError.hxx new file mode 100644 index 000000000..c50fdf15c --- /dev/null +++ b/src/lib/pulse/LogError.hxx @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_PULSE_LOG_ERROR_HXX +#define MPD_PULSE_LOG_ERROR_HXX + +struct pa_context; + +void +LogPulseError(pa_context *context, const char *prefix); + +#endif diff --git a/src/mixer/plugins/PulseMixerPlugin.cxx b/src/mixer/plugins/PulseMixerPlugin.cxx index d948c4a48..1c47f5a5a 100644 --- a/src/mixer/plugins/PulseMixerPlugin.cxx +++ b/src/mixer/plugins/PulseMixerPlugin.cxx @@ -20,6 +20,7 @@ #include "config.h" #include "PulseMixerPlugin.hxx" #include "lib/pulse/Domain.hxx" +#include "lib/pulse/LogError.hxx" #include "mixer/MixerInternal.hxx" #include "mixer/Listener.hxx" #include "output/plugins/PulseOutputPlugin.hxx" @@ -30,7 +31,6 @@ #include <pulse/introspect.h> #include <pulse/stream.h> #include <pulse/subscribe.h> -#include <pulse/error.h> #include <assert.h> @@ -118,9 +118,8 @@ PulseMixer::Update(pa_context *context, pa_stream *stream) pa_stream_get_index(stream), pulse_mixer_volume_cb, this); if (o == nullptr) { - FormatError(pulse_domain, - "pa_context_get_sink_input_info() failed: %s", - pa_strerror(pa_context_errno(context))); + LogPulseError(context, + "pa_context_get_sink_input_info() failed"); Offline(); return; } @@ -140,9 +139,8 @@ pulse_mixer_on_connect(gcc_unused PulseMixer &pm, (pa_subscription_mask_t)PA_SUBSCRIPTION_MASK_SINK_INPUT, nullptr, nullptr); if (o == nullptr) { - FormatError(pulse_domain, - "pa_context_subscribe() failed: %s", - pa_strerror(pa_context_errno(context))); + LogPulseError(context, + "pa_context_subscribe() failed"); return; } diff --git a/src/output/plugins/PulseOutputPlugin.cxx b/src/output/plugins/PulseOutputPlugin.cxx index 916366bf7..3e50eac52 100644 --- a/src/output/plugins/PulseOutputPlugin.cxx +++ b/src/output/plugins/PulseOutputPlugin.cxx @@ -21,6 +21,7 @@ #include "PulseOutputPlugin.hxx" #include "lib/pulse/Domain.hxx" #include "lib/pulse/Error.hxx" +#include "lib/pulse/LogError.hxx" #include "../OutputAPI.hxx" #include "mixer/MixerList.hxx" #include "mixer/plugins/PulseMixerPlugin.hxx" @@ -618,9 +619,8 @@ pulse_output_close(AudioOutput *ao) o = pa_stream_drain(po->stream, pulse_output_stream_success_cb, po); if (o == nullptr) { - FormatWarning(pulse_domain, - "pa_stream_drain() has failed: %s", - pa_strerror(pa_context_errno(po->context))); + LogPulseError(po->context, + "pa_stream_drain() has failed"); } else pulse_wait_for_operation(po->mainloop, o); } @@ -797,9 +797,7 @@ pulse_output_cancel(AudioOutput *ao) o = pa_stream_flush(po->stream, pulse_output_stream_success_cb, po); if (o == nullptr) { - FormatWarning(pulse_domain, - "pa_stream_flush() has failed: %s", - pa_strerror(pa_context_errno(po->context))); + LogPulseError(po->context, "pa_stream_flush() has failed"); pa_threaded_mainloop_unlock(po->mainloop); return; } |