From dd6678ce125949aa93df7a00797b9d6d03369e36 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Thu, 11 Jul 2019 19:02:34 +0300 Subject: mediaplayer: gstreamer: use pwaudiosink instead of alsasink 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 Change-Id: Ib40300ee6a74804c8491451267041d0554215d05 --- binding/afm-mediaplayer-binding.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'binding') 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"); -- cgit 1.2.3-korg