summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2019-07-11 19:02:34 +0300
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2019-07-12 12:47:59 +0300
commitdd6678ce125949aa93df7a00797b9d6d03369e36 (patch)
treeb2af053e2fdf7b9f17a4d7e135424ca076c4677a
parentba1880a6cf8c750a5b73a3d3003a54622e1f480c (diff)
mediaplayer: gstreamer: use pwaudiosink instead of alsasinkhalibut_8.0.0halibut_7.99.3halibut/8.0.0halibut/7.99.38.0.07.99.3
This native pipewire sink has better performance and allows 1) properly selecting the role of the app 2) proper handling of the situation where another app with higher priority has taken over the audio stream Bug-AGL: SPEC-2634 Signed-off-by: George Kiagiadakis <george.kiagiadakis@collabora.com> Change-Id: Ib40300ee6a74804c8491451267041d0554215d05
-rw-r--r--binding/afm-mediaplayer-binding.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/binding/afm-mediaplayer-binding.c b/binding/afm-mediaplayer-binding.c
index 86f1f3b..5eaa982 100644
--- a/binding/afm-mediaplayer-binding.c
+++ b/binding/afm-mediaplayer-binding.c
@@ -56,7 +56,7 @@ static const char * const LOOP_STATES[LOOP_NUM_TYPES] = {
};
typedef struct _CustomData {
- GstElement *playbin, *fake_sink, *alsa_sink;
+ GstElement *playbin, *fake_sink, *audio_sink;
gboolean playing;
int loop_state;
gboolean one_time;
@@ -201,8 +201,8 @@ static int set_media_uri(struct playlist_item *item, int state)
data.duration = GST_CLOCK_TIME_NONE;
if (state) {
- g_object_set(data.playbin, "audio-sink", data.alsa_sink, NULL);
- AFB_DEBUG("GSTREAMER playbin.audio-sink = alsa-sink");
+ g_object_set(data.playbin, "audio-sink", data.audio_sink, NULL);
+ AFB_DEBUG("GSTREAMER playbin.audio-sink = pipewire-sink");
if (!data.playing)
mediaplayer_set_role_state(data.api, GST_STATE_PLAYING);
@@ -435,8 +435,8 @@ static void gstreamer_controls(afb_req_t request)
return;
}
} else {
- g_object_set(data.playbin, "audio-sink", data.alsa_sink, NULL);
- AFB_DEBUG("GSTREAMER playbin.audio-sink = alsa-sink");
+ g_object_set(data.playbin, "audio-sink", data.audio_sink, NULL);
+ AFB_DEBUG("GSTREAMER playbin.audio-sink = pipewire-sink");
mediaplayer_set_role_state(api, GST_STATE_PLAYING);
AFB_DEBUG("GSTREAMER playbin.state = GST_STATE_PLAYING");
@@ -874,12 +874,13 @@ static void gstreamer_init(afb_api_t api)
exit(1);
}
- data.alsa_sink = gst_element_factory_make("alsasink", NULL);
- if (!data.alsa_sink)
+ data.audio_sink = gst_element_factory_make("pwaudiosink", NULL);
+ if (!data.audio_sink)
{
- AFB_ERROR("GST Pipeline: Failed to create 'alsasink' element!");
+ AFB_ERROR("GST Pipeline: Failed to create 'pwaudiosink' element!");
exit(1);
}
+ gst_util_set_object_arg(data.audio_sink, "stream-properties", "p,media.role=Multimedia");
g_object_set(data.playbin, "audio-sink", data.fake_sink, NULL);
AFB_DEBUG("GSTREAMER playbin.audio-sink = fake-sink");