aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/pulse_output_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-08-31 21:00:55 +0200
committerMax Kellermann <max@duempel.org>2011-08-31 21:01:22 +0200
commite76c752987e0b943e0ee01d6e062e86befd9e8c5 (patch)
tree775a609194d7364086c835681630b486ae78af3d /src/output/pulse_output_plugin.c
parent042c1abc6e1b0023a9f2964573102a332e598237 (diff)
downloadmpd-e76c752987e0b943e0ee01d6e062e86befd9e8c5.tar.gz
mpd-e76c752987e0b943e0ee01d6e062e86befd9e8c5.tar.xz
mpd-e76c752987e0b943e0ee01d6e062e86befd9e8c5.zip
output/pulse: add function _delete_stream()
Merge common code.
Diffstat (limited to '')
-rw-r--r--src/output/pulse_output_plugin.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/output/pulse_output_plugin.c b/src/output/pulse_output_plugin.c
index c09b6a6af..8fcf26992 100644
--- a/src/output/pulse_output_plugin.c
+++ b/src/output/pulse_output_plugin.c
@@ -225,6 +225,20 @@ pulse_output_connect(struct pulse_output *po, GError **error_r)
}
/**
+ * Frees and clears the stream.
+ */
+static void
+pulse_output_delete_stream(struct pulse_output *po)
+{
+ assert(po != NULL);
+ assert(po->stream != NULL);
+
+ pa_stream_disconnect(po->stream);
+ pa_stream_unref(po->stream);
+ po->stream = NULL;
+}
+
+/**
* Frees and clears the context.
*/
static void
@@ -539,8 +553,7 @@ pulse_output_open(void *data, struct audio_format *audio_format,
error = pa_stream_connect_playback(po->stream, po->sink,
NULL, 0, NULL, NULL);
if (error < 0) {
- pa_stream_unref(po->stream);
- po->stream = NULL;
+ pulse_output_delete_stream(po);
g_set_error(error_r, pulse_output_quark(), 0,
"pa_stream_connect_playback() has failed: %s",
@@ -578,9 +591,7 @@ pulse_output_close(void *data)
pulse_wait_for_operation(po->mainloop, o);
}
- pa_stream_disconnect(po->stream);
- pa_stream_unref(po->stream);
- po->stream = NULL;
+ pulse_output_delete_stream(po);
if (po->context != NULL &&
pa_context_get_state(po->context) != PA_CONTEXT_READY)