pipewire config: enable bluez modules in pipewire and wireplumber
[AGL/meta-agl-devel.git] / meta-pipewire / recipes-multimedia / pipewire / pipewire / 0012-gst-pwaudioringbuffer-request-pause-play-on-the-appr.patch
1 From 1eb1e3a839f97ad4aa43c289f702c587a068a333 Mon Sep 17 00:00:00 2001
2 From: George Kiagiadakis <george.kiagiadakis@collabora.com>
3 Date: Thu, 11 Jul 2019 16:21:17 +0300
4 Subject: [PATCH] gst/pwaudioringbuffer: request pause/play on the appropriate
5  stream state changes
6
7 This allows the client to properly go to PAUSED when the session manager
8 unlinks the stream and go again to PLAYING when the sm re-links it.
9 This allows the session manager to implement policies without letting
10 the client pipeline freeze (in the absence of a running audio clock)
11 when it is unlinked. Note that in case the client doesn't handle the
12 request, there is still no issue. Like in pulseaudio, the clock just
13 freezes, so the pipeline stops progressing.
14
15 This is similar to the pulseaudio cork/uncork mechanism.
16
17 Upstream-Status: Submitted [https://github.com/PipeWire/pipewire/pull/140]
18 ---
19  src/gst/gstpwaudioringbuffer.c | 27 +++++++++++++++++++++++----
20  1 file changed, 23 insertions(+), 4 deletions(-)
21
22 diff --git a/src/gst/gstpwaudioringbuffer.c b/src/gst/gstpwaudioringbuffer.c
23 index 181304e8..04259927 100644
24 --- a/src/gst/gstpwaudioringbuffer.c
25 +++ b/src/gst/gstpwaudioringbuffer.c
26 @@ -202,11 +202,16 @@ on_stream_state_changed (void *data, enum pw_stream_state old,
27      enum pw_stream_state state, const char *error)
28  {
29    GstPwAudioRingBuffer *self = GST_PW_AUDIO_RING_BUFFER (data);
30 +  GstMessage *msg;
31  
32    GST_DEBUG_OBJECT (self->elem, "got stream state: %s",
33        pw_stream_state_as_string (state));
34  
35    switch (state) {
36 +    case PW_STREAM_STATE_ERROR:
37 +      GST_ELEMENT_ERROR (self->elem, RESOURCE, FAILED,
38 +          ("stream error: %s", error), (NULL));
39 +      break;
40      case PW_STREAM_STATE_UNCONNECTED:
41        GST_ELEMENT_ERROR (self->elem, RESOURCE, FAILED,
42            ("stream disconnected unexpectedly"), (NULL));
43 @@ -214,12 +219,26 @@ on_stream_state_changed (void *data, enum pw_stream_state old,
44      case PW_STREAM_STATE_CONNECTING:
45      case PW_STREAM_STATE_CONFIGURE:
46      case PW_STREAM_STATE_READY:
47 +      break;
48      case PW_STREAM_STATE_PAUSED:
49 -    case PW_STREAM_STATE_STREAMING:
50 +      if (old == PW_STREAM_STATE_STREAMING) {
51 +        if (GST_STATE (self->elem) != GST_STATE_PAUSED &&
52 +            GST_STATE_TARGET (self->elem) != GST_STATE_PAUSED) {
53 +          GST_DEBUG_OBJECT (self->elem, "requesting GST_STATE_PAUSED");
54 +          msg = gst_message_new_request_state (GST_OBJECT (self->elem),
55 +              GST_STATE_PAUSED);
56 +          gst_element_post_message (self->elem, msg);
57 +        }
58 +      }
59        break;
60 -    case PW_STREAM_STATE_ERROR:
61 -      GST_ELEMENT_ERROR (self->elem, RESOURCE, FAILED,
62 -          ("stream error: %s", error), (NULL));
63 +    case PW_STREAM_STATE_STREAMING:
64 +      if (GST_STATE (self->elem) != GST_STATE_PLAYING &&
65 +          GST_STATE_TARGET (self->elem) != GST_STATE_PLAYING) {
66 +        GST_DEBUG_OBJECT (self->elem, "requesting GST_STATE_PLAYING");
67 +        msg = gst_message_new_request_state (GST_OBJECT (self->elem),
68 +            GST_STATE_PLAYING);
69 +        gst_element_post_message (self->elem, msg);
70 +      }
71        break;
72    }
73    pw_thread_loop_signal (self->main_loop, FALSE);
74 -- 
75 2.20.1
76