{mixer,output}/pulse: move code to LogPulseError()
This commit is contained in:
parent
6a0a5f9693
commit
99e6409a67
@ -1351,6 +1351,7 @@ libmixer_plugins_a_SOURCES += \
|
||||
|
||||
noinst_LIBRARIES += libpulse.a
|
||||
libpulse_a_SOURCES = \
|
||||
src/lib/pulse/LogError.cxx src/lib/pulse/LogError.hxx \
|
||||
src/lib/pulse/Error.cxx src/lib/pulse/Error.hxx \
|
||||
src/lib/pulse/Domain.cxx src/lib/pulse/Domain.hxx
|
||||
libpulse_a_CPPFLAGS = $(AM_CPPFLAGS) $(PULSE_CFLAGS)
|
||||
|
33
src/lib/pulse/LogError.cxx
Normal file
33
src/lib/pulse/LogError.cxx
Normal file
@ -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));
|
||||
}
|
28
src/lib/pulse/LogError.hxx
Normal file
28
src/lib/pulse/LogError.hxx
Normal file
@ -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
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user