aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-12-29 22:25:14 +0100
committerMax Kellermann <max@duempel.org>2014-12-29 22:25:14 +0100
commitfe9db8b369cdb9e62396b6f92d48b03f4c5ad703 (patch)
tree4ca3fa1bf18575d9227e2bee4352cd4e63b7e14f
parentca035d0e8dec5e6f370885a8e21ac3c7998d8523 (diff)
downloadmpd-fe9db8b369cdb9e62396b6f92d48b03f4c5ad703.tar.gz
mpd-fe9db8b369cdb9e62396b6f92d48b03f4c5ad703.tar.xz
mpd-fe9db8b369cdb9e62396b6f92d48b03f4c5ad703.zip
{mixer,output}/pulse: use a common Domain instance
-rw-r--r--Makefile.am10
-rw-r--r--src/lib/pulse/Domain.cxx24
-rw-r--r--src/lib/pulse/Domain.hxx27
-rw-r--r--src/mixer/plugins/PulseMixerPlugin.cxx10
-rw-r--r--src/output/plugins/PulseOutputPlugin.cxx22
5 files changed, 73 insertions, 20 deletions
diff --git a/Makefile.am b/Makefile.am
index e1c19bb13..5fe7b70ad 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1231,7 +1231,6 @@ OUTPUT_LIBS = \
$(ROAR_LIBS) \
$(JACK_LIBS) \
$(OPENAL_LIBS) \
- $(PULSE_LIBS) \
$(SHOUT_LIBS)
OUTPUT_API_SRC = \
@@ -1256,7 +1255,7 @@ liboutput_plugins_a_SOURCES = \
MIXER_LIBS = \
libmixer_plugins.a \
- $(PULSE_LIBS)
+ $(PULSE_LIBS2)
MIXER_API_SRC = \
src/mixer/Listener.hxx \
@@ -1349,6 +1348,13 @@ liboutput_plugins_a_SOURCES += \
src/output/plugins/PulseOutputPlugin.hxx
libmixer_plugins_a_SOURCES += \
src/mixer/plugins/PulseMixerPlugin.cxx src/mixer/plugins/PulseMixerPlugin.hxx
+
+noinst_LIBRARIES += libpulse.a
+libpulse_a_SOURCES = \
+ src/lib/pulse/Domain.cxx src/lib/pulse/Domain.hxx
+libpulse_a_CPPFLAGS = $(AM_CPPFLAGS) $(PULSE_CFLAGS)
+PULSE_LIBS2 = libpulse.a $(PULSE_LIBS)
+OUTPUT_LIBS += $(PULSE_LIBS2)
endif
if HAVE_SHOUT
diff --git a/src/lib/pulse/Domain.cxx b/src/lib/pulse/Domain.cxx
new file mode 100644
index 000000000..1f5ba32b3
--- /dev/null
+++ b/src/lib/pulse/Domain.cxx
@@ -0,0 +1,24 @@
+/*
+ * 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 "Domain.hxx"
+#include "util/Domain.hxx"
+
+const Domain pulse_domain("pulse");
diff --git a/src/lib/pulse/Domain.hxx b/src/lib/pulse/Domain.hxx
new file mode 100644
index 000000000..f71240504
--- /dev/null
+++ b/src/lib/pulse/Domain.hxx
@@ -0,0 +1,27 @@
+/*
+ * 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_DOMAIN_HXX
+#define MPD_PULSE_DOMAIN_HXX
+
+class Domain;
+
+extern const Domain pulse_domain;
+
+#endif
diff --git a/src/mixer/plugins/PulseMixerPlugin.cxx b/src/mixer/plugins/PulseMixerPlugin.cxx
index 9e3eef9d8..d948c4a48 100644
--- a/src/mixer/plugins/PulseMixerPlugin.cxx
+++ b/src/mixer/plugins/PulseMixerPlugin.cxx
@@ -19,11 +19,11 @@
#include "config.h"
#include "PulseMixerPlugin.hxx"
+#include "lib/pulse/Domain.hxx"
#include "mixer/MixerInternal.hxx"
#include "mixer/Listener.hxx"
#include "output/plugins/PulseOutputPlugin.hxx"
#include "util/Error.hxx"
-#include "util/Domain.hxx"
#include "Log.hxx"
#include <pulse/context.h>
@@ -66,8 +66,6 @@ public:
bool SetVolume(unsigned volume, Error &error) override;
};
-static constexpr Domain pulse_mixer_domain("pulse_mixer");
-
void
PulseMixer::Offline()
{
@@ -120,7 +118,7 @@ PulseMixer::Update(pa_context *context, pa_stream *stream)
pa_stream_get_index(stream),
pulse_mixer_volume_cb, this);
if (o == nullptr) {
- FormatError(pulse_mixer_domain,
+ FormatError(pulse_domain,
"pa_context_get_sink_input_info() failed: %s",
pa_strerror(pa_context_errno(context)));
Offline();
@@ -142,7 +140,7 @@ pulse_mixer_on_connect(gcc_unused PulseMixer &pm,
(pa_subscription_mask_t)PA_SUBSCRIPTION_MASK_SINK_INPUT,
nullptr, nullptr);
if (o == nullptr) {
- FormatError(pulse_mixer_domain,
+ FormatError(pulse_domain,
"pa_context_subscribe() failed: %s",
pa_strerror(pa_context_errno(context)));
return;
@@ -212,7 +210,7 @@ PulseMixer::SetVolume(unsigned new_volume, Error &error)
if (!online) {
pulse_output_unlock(output);
- error.Set(pulse_mixer_domain, "disconnected");
+ error.Set(pulse_domain, "disconnected");
return false;
}
diff --git a/src/output/plugins/PulseOutputPlugin.cxx b/src/output/plugins/PulseOutputPlugin.cxx
index 5dc733383..ff077bed5 100644
--- a/src/output/plugins/PulseOutputPlugin.cxx
+++ b/src/output/plugins/PulseOutputPlugin.cxx
@@ -19,11 +19,11 @@
#include "config.h"
#include "PulseOutputPlugin.hxx"
+#include "lib/pulse/Domain.hxx"
#include "../OutputAPI.hxx"
#include "mixer/MixerList.hxx"
#include "mixer/plugins/PulseMixerPlugin.hxx"
#include "util/Error.hxx"
-#include "util/Domain.hxx"
#include "Log.hxx"
#include <pulse/thread-mainloop.h>
@@ -59,13 +59,11 @@ struct PulseOutput {
:base(pulse_output_plugin) {}
};
-static constexpr Domain pulse_output_domain("pulse_output");
-
static void
SetError(Error &error, pa_context *context, const char *msg)
{
const int e = pa_context_errno(context);
- error.Format(pulse_output_domain, e, "%s: %s", msg, pa_strerror(e));
+ error.Format(pulse_domain, e, "%s: %s", msg, pa_strerror(e));
}
void
@@ -120,7 +118,7 @@ pulse_output_set_volume(PulseOutput &po, const pa_cvolume *volume,
if (po.context == nullptr || po.stream == nullptr ||
pa_stream_get_state(po.stream) != PA_STREAM_READY) {
- error.Set(pulse_output_domain, "disconnected");
+ error.Set(pulse_domain, "disconnected");
return false;
}
@@ -301,7 +299,7 @@ pulse_output_setup_context(PulseOutput *po, Error &error)
po->context = pa_context_new(pa_threaded_mainloop_get_api(po->mainloop),
MPD_PULSE_NAME);
if (po->context == nullptr) {
- error.Set(pulse_output_domain, "pa_context_new() has failed");
+ error.Set(pulse_domain, "pa_context_new() has failed");
return false;
}
@@ -364,7 +362,7 @@ pulse_output_enable(AudioOutput *ao, Error &error)
po->mainloop = pa_threaded_mainloop_new();
if (po->mainloop == nullptr) {
- error.Set(pulse_output_domain,
+ error.Set(pulse_domain,
"pa_threaded_mainloop_new() has failed");
return false;
}
@@ -376,7 +374,7 @@ pulse_output_enable(AudioOutput *ao, Error &error)
pa_threaded_mainloop_free(po->mainloop);
po->mainloop = nullptr;
- error.Set(pulse_output_domain,
+ error.Set(pulse_domain,
"pa_threaded_mainloop_start() has failed");
return false;
}
@@ -626,7 +624,7 @@ pulse_output_close(AudioOutput *ao)
o = pa_stream_drain(po->stream,
pulse_output_stream_success_cb, po);
if (o == nullptr) {
- FormatWarning(pulse_output_domain,
+ FormatWarning(pulse_domain,
"pa_stream_drain() has failed: %s",
pa_strerror(pa_context_errno(po->context)));
} else
@@ -749,7 +747,7 @@ pulse_output_play(AudioOutput *ao, const void *chunk, size_t size,
while (po->writable == 0) {
if (pa_stream_is_suspended(po->stream)) {
pa_threaded_mainloop_unlock(po->mainloop);
- error.Set(pulse_output_domain, "suspended");
+ error.Set(pulse_domain, "suspended");
return 0;
}
@@ -757,7 +755,7 @@ pulse_output_play(AudioOutput *ao, const void *chunk, size_t size,
if (pa_stream_get_state(po->stream) != PA_STREAM_READY) {
pa_threaded_mainloop_unlock(po->mainloop);
- error.Set(pulse_output_domain, "disconnected");
+ error.Set(pulse_domain, "disconnected");
return 0;
}
}
@@ -803,7 +801,7 @@ pulse_output_cancel(AudioOutput *ao)
o = pa_stream_flush(po->stream, pulse_output_stream_success_cb, po);
if (o == nullptr) {
- FormatWarning(pulse_output_domain,
+ FormatWarning(pulse_domain,
"pa_stream_flush() has failed: %s",
pa_strerror(pa_context_errno(po->context)));
pa_threaded_mainloop_unlock(po->mainloop);