summaryrefslogtreecommitdiffstats
path: root/binding/radio_output_gstreamer.c
diff options
context:
space:
mode:
Diffstat (limited to 'binding/radio_output_gstreamer.c')
-rw-r--r--binding/radio_output_gstreamer.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/binding/radio_output_gstreamer.c b/binding/radio_output_gstreamer.c
index f492bb5..5359deb 100644
--- a/binding/radio_output_gstreamer.c
+++ b/binding/radio_output_gstreamer.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 Konsulko Group
+ * Copyright (C) 2018, 2019 Konsulko Group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,10 @@
#include "radio_output.h"
#include "rtl_fm.h"
+// Flag to enable using GST_STATE_READY instead of GST_STATE_PAUSED to trigger
+// Wireplumber policy mechanism. Hopefully temporary.
+#define WIREPLUMBER_WORKAROUND
+
// Output buffer
static unsigned int extra;
static int16_t extra_buf[1];
@@ -61,7 +65,7 @@ int radio_output_open()
queue = gst_element_factory_make("queue", "queue");
convert = gst_element_factory_make("audioconvert", "convert");
resample = gst_element_factory_make("audioresample", "resample");
- sink = gst_element_factory_make("alsasink", "sink");
+ sink = gst_element_factory_make("pwaudiosink", "sink");
if(!(pipeline && appsrc && queue && convert && resample && sink)) {
fprintf(stderr, "pipeline element construction failed!\n");
}
@@ -73,6 +77,7 @@ int radio_output_open()
"layout", G_TYPE_STRING, "interleaved",
"channel-mask", G_TYPE_UINT64, 3,
NULL), NULL);
+ gst_util_set_object_arg(sink, "stream-properties", "p,media.role=Multimedia");
if((p = getenv("RADIO_OUTPUT"))) {
fprintf(stderr, "Using output device %s\n", p);
@@ -95,7 +100,11 @@ int radio_output_open()
NULL);
// Start pipeline in paused state
+#ifdef WIREPLUMBER_WORKAROUND
+ gst_element_set_state(pipeline, GST_STATE_READY);
+#else
gst_element_set_state(pipeline, GST_STATE_PAUSED);
+#endif
// Set up output buffer
extra = 0;
@@ -128,7 +137,11 @@ void radio_output_stop(void)
if(pipeline && running) {
// Stop pipeline
running = false;
+#ifdef WIREPLUMBER_WORKAROUND
+ gst_element_set_state(pipeline, GST_STATE_READY);
+#else
gst_element_set_state(pipeline, GST_STATE_PAUSED);
+#endif
// Flush pipeline
// This seems required to avoid stutters on starts after a stop