aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/plugins
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
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 'src/output/plugins')
-rw-r--r--src/output/plugins/PulseOutputPlugin.cxx64
-rw-r--r--src/output/plugins/PulseOutputPlugin.hxx10
-rw-r--r--src/output/plugins/RoarOutputPlugin.cxx8
-rw-r--r--src/output/plugins/RoarOutputPlugin.hxx4
-rw-r--r--src/output/plugins/WinmmOutputPlugin.cxx4
-rw-r--r--src/output/plugins/WinmmOutputPlugin.hxx2
6 files changed, 44 insertions, 48 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;
diff --git a/src/output/plugins/PulseOutputPlugin.hxx b/src/output/plugins/PulseOutputPlugin.hxx
index 4d8bf4b59..9219780a5 100644
--- a/src/output/plugins/PulseOutputPlugin.hxx
+++ b/src/output/plugins/PulseOutputPlugin.hxx
@@ -28,19 +28,19 @@ class Error;
extern const struct AudioOutputPlugin pulse_output_plugin;
void
-pulse_output_lock(PulseOutput *po);
+pulse_output_lock(PulseOutput &po);
void
-pulse_output_unlock(PulseOutput *po);
+pulse_output_unlock(PulseOutput &po);
void
-pulse_output_set_mixer(PulseOutput *po, PulseMixer *pm);
+pulse_output_set_mixer(PulseOutput &po, PulseMixer &pm);
void
-pulse_output_clear_mixer(PulseOutput *po, PulseMixer *pm);
+pulse_output_clear_mixer(PulseOutput &po, PulseMixer &pm);
bool
-pulse_output_set_volume(PulseOutput *po,
+pulse_output_set_volume(PulseOutput &po,
const pa_cvolume *volume, Error &error);
#endif
diff --git a/src/output/plugins/RoarOutputPlugin.cxx b/src/output/plugins/RoarOutputPlugin.cxx
index dca9fa346..ac4dd8a4e 100644
--- a/src/output/plugins/RoarOutputPlugin.cxx
+++ b/src/output/plugins/RoarOutputPlugin.cxx
@@ -93,9 +93,9 @@ RoarOutput::GetVolume() const
}
int
-roar_output_get_volume(RoarOutput *roar)
+roar_output_get_volume(RoarOutput &roar)
{
- return roar->GetVolume();
+ return roar.GetVolume();
}
bool
@@ -115,9 +115,9 @@ RoarOutput::SetVolume(unsigned volume)
}
bool
-roar_output_set_volume(RoarOutput *roar, unsigned volume)
+roar_output_set_volume(RoarOutput &roar, unsigned volume)
{
- return roar->SetVolume(volume);
+ return roar.SetVolume(volume);
}
inline void
diff --git a/src/output/plugins/RoarOutputPlugin.hxx b/src/output/plugins/RoarOutputPlugin.hxx
index 8b7c37512..5f5a9246e 100644
--- a/src/output/plugins/RoarOutputPlugin.hxx
+++ b/src/output/plugins/RoarOutputPlugin.hxx
@@ -25,9 +25,9 @@ class RoarOutput;
extern const struct AudioOutputPlugin roar_output_plugin;
int
-roar_output_get_volume(RoarOutput *roar);
+roar_output_get_volume(RoarOutput &roar);
bool
-roar_output_set_volume(RoarOutput *roar, unsigned volume);
+roar_output_set_volume(RoarOutput &roar, unsigned volume);
#endif
diff --git a/src/output/plugins/WinmmOutputPlugin.cxx b/src/output/plugins/WinmmOutputPlugin.cxx
index d61f2055a..cae39df5f 100644
--- a/src/output/plugins/WinmmOutputPlugin.cxx
+++ b/src/output/plugins/WinmmOutputPlugin.cxx
@@ -59,9 +59,9 @@ struct WinmmOutput {
static constexpr Domain winmm_output_domain("winmm_output");
HWAVEOUT
-winmm_output_get_handle(WinmmOutput *output)
+winmm_output_get_handle(WinmmOutput &output)
{
- return output->handle;
+ return output.handle;
}
static bool
diff --git a/src/output/plugins/WinmmOutputPlugin.hxx b/src/output/plugins/WinmmOutputPlugin.hxx
index 450e58b4e..50fae4f2f 100644
--- a/src/output/plugins/WinmmOutputPlugin.hxx
+++ b/src/output/plugins/WinmmOutputPlugin.hxx
@@ -35,7 +35,7 @@ extern const struct AudioOutputPlugin winmm_output_plugin;
gcc_pure
HWAVEOUT
-winmm_output_get_handle(WinmmOutput *);
+winmm_output_get_handle(WinmmOutput &output);
#endif