aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/plugins/PulseOutputPlugin.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-02-06 21:10:12 +0100
committerMax Kellermann <max@duempel.org>2014-02-06 21:10:12 +0100
commit0a0659d737e8788fc1ba02e8c113e55204782716 (patch)
tree8855ba68e8648bbb81ea94899406e4b2988ae489 /src/output/plugins/PulseOutputPlugin.cxx
parentb6df4680df08db7827af56d5adf2a04264f2dcb9 (diff)
downloadmpd-0a0659d737e8788fc1ba02e8c113e55204782716.tar.gz
mpd-0a0659d737e8788fc1ba02e8c113e55204782716.tar.xz
mpd-0a0659d737e8788fc1ba02e8c113e55204782716.zip
mixer/Plugin: pass AudioOutput reference to init()
Passing a void pointer is unsafe.
Diffstat (limited to '')
-rw-r--r--src/output/plugins/PulseOutputPlugin.cxx64
1 files changed, 30 insertions, 34 deletions
diff --git a/src/output/plugins/PulseOutputPlugin.cxx b/src/output/plugins/PulseOutputPlugin.cxx
index 1f255718f..4e24984c4 100644
--- a/src/output/plugins/PulseOutputPlugin.cxx
+++ b/src/output/plugins/PulseOutputPlugin.cxx
@@ -70,70 +70,66 @@ SetError(Error &error, pa_context *context, const char *msg)
}
void
-pulse_output_lock(PulseOutput *po)
+pulse_output_lock(PulseOutput &po)
{
- pa_threaded_mainloop_lock(po->mainloop);
+ pa_threaded_mainloop_lock(po.mainloop);
}
void
-pulse_output_unlock(PulseOutput *po)
+pulse_output_unlock(PulseOutput &po)
{
- pa_threaded_mainloop_unlock(po->mainloop);
+ pa_threaded_mainloop_unlock(po.mainloop);
}
void
-pulse_output_set_mixer(PulseOutput *po, PulseMixer *pm)
+pulse_output_set_mixer(PulseOutput &po, PulseMixer &pm)
{
- assert(po != nullptr);
- assert(po->mixer == nullptr);
- assert(pm != nullptr);
+ assert(po.mixer == nullptr);
- po->mixer = pm;
+ po.mixer = &pm;
- if (po->mainloop == nullptr)
+ if (po.mainloop == nullptr)
return;
- pa_threaded_mainloop_lock(po->mainloop);
+ pa_threaded_mainloop_lock(po.mainloop);
- if (po->context != nullptr &&
- pa_context_get_state(po->context) == PA_CONTEXT_READY) {
- pulse_mixer_on_connect(pm, po->context);
+ if (po.context != nullptr &&
+ pa_context_get_state(po.context) == PA_CONTEXT_READY) {
+ pulse_mixer_on_connect(pm, po.context);
- if (po->stream != nullptr &&
- pa_stream_get_state(po->stream) == PA_STREAM_READY)
- pulse_mixer_on_change(pm, po->context, po->stream);
+ if (po.stream != nullptr &&
+ pa_stream_get_state(po.stream) == PA_STREAM_READY)
+ pulse_mixer_on_change(pm, po.context, po.stream);
}
- pa_threaded_mainloop_unlock(po->mainloop);
+ pa_threaded_mainloop_unlock(po.mainloop);
}
void
-pulse_output_clear_mixer(PulseOutput *po, gcc_unused PulseMixer *pm)
+pulse_output_clear_mixer(PulseOutput &po, gcc_unused PulseMixer &pm)
{
- assert(po != nullptr);
- assert(pm != nullptr);
- assert(po->mixer == pm);
+ assert(po.mixer == &pm);
- po->mixer = nullptr;
+ po.mixer = nullptr;
}
bool
-pulse_output_set_volume(PulseOutput *po, const pa_cvolume *volume,
+pulse_output_set_volume(PulseOutput &po, const pa_cvolume *volume,
Error &error)
{
pa_operation *o;
- if (po->context == nullptr || po->stream == nullptr ||
- pa_stream_get_state(po->stream) != PA_STREAM_READY) {
+ if (po.context == nullptr || po.stream == nullptr ||
+ pa_stream_get_state(po.stream) != PA_STREAM_READY) {
error.Set(pulse_output_domain, "disconnected");
return false;
}
- o = pa_context_set_sink_input_volume(po->context,
- pa_stream_get_index(po->stream),
+ o = pa_context_set_sink_input_volume(po.context,
+ pa_stream_get_index(po.stream),
volume, nullptr, nullptr);
if (o == nullptr) {
- SetError(error, po->context,
+ SetError(error, po.context,
"failed to set PulseAudio volume");
return false;
}
@@ -190,7 +186,7 @@ pulse_output_context_state_cb(struct pa_context *context, void *userdata)
switch (pa_context_get_state(context)) {
case PA_CONTEXT_READY:
if (po->mixer != nullptr)
- pulse_mixer_on_connect(po->mixer, context);
+ pulse_mixer_on_connect(*po->mixer, context);
pa_threaded_mainloop_signal(po->mainloop, 0);
break;
@@ -198,7 +194,7 @@ pulse_output_context_state_cb(struct pa_context *context, void *userdata)
case PA_CONTEXT_TERMINATED:
case PA_CONTEXT_FAILED:
if (po->mixer != nullptr)
- pulse_mixer_on_disconnect(po->mixer);
+ pulse_mixer_on_disconnect(*po->mixer);
/* the caller thread might be waiting for these
states */
@@ -231,7 +227,7 @@ pulse_output_subscribe_cb(pa_context *context,
idx == pa_stream_get_index(po->stream) &&
(type == PA_SUBSCRIPTION_EVENT_NEW ||
type == PA_SUBSCRIPTION_EVENT_CHANGE))
- pulse_mixer_on_change(po->mixer, context, po->stream);
+ pulse_mixer_on_change(*po->mixer, context, po->stream);
}
/**
@@ -487,7 +483,7 @@ pulse_output_stream_state_cb(pa_stream *stream, void *userdata)
switch (pa_stream_get_state(stream)) {
case PA_STREAM_READY:
if (po->mixer != nullptr)
- pulse_mixer_on_change(po->mixer, po->context, stream);
+ pulse_mixer_on_change(*po->mixer, po->context, stream);
pa_threaded_mainloop_signal(po->mainloop, 0);
break;
@@ -495,7 +491,7 @@ pulse_output_stream_state_cb(pa_stream *stream, void *userdata)
case PA_STREAM_FAILED:
case PA_STREAM_TERMINATED:
if (po->mixer != nullptr)
- pulse_mixer_on_disconnect(po->mixer);
+ pulse_mixer_on_disconnect(*po->mixer);
pa_threaded_mainloop_signal(po->mainloop, 0);
break;