pipewire: update to master as of Nov 19th 2019
[AGL/meta-agl-devel.git] / meta-pipewire / recipes-multimedia / pipewire / pipewire / 0004-gst-pwaudioringbuffer-request-pause-play-on-the-appr.patch
1 From 1027efb2ced95a9548007ccc2f07805d48073846 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: Denied
18 See https://gitlab.freedesktop.org/pipewire/pipewire/merge_requests/140
19 ---
20  src/gst/gstpwaudioringbuffer.c | 27 +++++++++++++++++++++++----
21  1 file changed, 23 insertions(+), 4 deletions(-)
22
23 diff --git a/src/gst/gstpwaudioringbuffer.c b/src/gst/gstpwaudioringbuffer.c
24 index 989b2cd7..97350f38 100644
25 --- a/src/gst/gstpwaudioringbuffer.c
26 +++ b/src/gst/gstpwaudioringbuffer.c
27 @@ -202,11 +202,16 @@ on_stream_state_changed (void *data, enum pw_stream_state old,
28      enum pw_stream_state state, const char *error)
29  {
30    GstPwAudioRingBuffer *self = GST_PW_AUDIO_RING_BUFFER (data);
31 +  GstMessage *msg;
32  
33    GST_DEBUG_OBJECT (self->elem, "got stream state: %s",
34        pw_stream_state_as_string (state));
35  
36    switch (state) {
37 +    case PW_STREAM_STATE_ERROR:
38 +      GST_ELEMENT_ERROR (self->elem, RESOURCE, FAILED,
39 +          ("stream error: %s", error), (NULL));
40 +      break;
41      case PW_STREAM_STATE_UNCONNECTED:
42        GST_ELEMENT_ERROR (self->elem, RESOURCE, FAILED,
43            ("stream disconnected unexpectedly"), (NULL));
44 @@ -214,12 +219,26 @@ on_stream_state_changed (void *data, enum pw_stream_state old,
45      case PW_STREAM_STATE_CONNECTING:
46      case PW_STREAM_STATE_CONFIGURE:
47      case PW_STREAM_STATE_READY:
48 +      break;
49      case PW_STREAM_STATE_PAUSED:
50 -    case PW_STREAM_STATE_STREAMING:
51 +      if (old == PW_STREAM_STATE_STREAMING) {
52 +        if (GST_STATE (self->elem) != GST_STATE_PAUSED &&
53 +            GST_STATE_TARGET (self->elem) != GST_STATE_PAUSED) {
54 +          GST_DEBUG_OBJECT (self->elem, "requesting GST_STATE_PAUSED");
55 +          msg = gst_message_new_request_state (GST_OBJECT (self->elem),
56 +              GST_STATE_PAUSED);
57 +          gst_element_post_message (self->elem, msg);
58 +        }
59 +      }
60        break;
61 -    case PW_STREAM_STATE_ERROR:
62 -      GST_ELEMENT_ERROR (self->elem, RESOURCE, FAILED,
63 -          ("stream error: %s", error), (NULL));
64 +    case PW_STREAM_STATE_STREAMING:
65 +      if (GST_STATE (self->elem) != GST_STATE_PLAYING &&
66 +          GST_STATE_TARGET (self->elem) != GST_STATE_PLAYING) {
67 +        GST_DEBUG_OBJECT (self->elem, "requesting GST_STATE_PLAYING");
68 +        msg = gst_message_new_request_state (GST_OBJECT (self->elem),
69 +            GST_STATE_PLAYING);
70 +        gst_element_post_message (self->elem, msg);
71 +      }
72        break;
73    }
74    pw_thread_loop_signal (self->main_loop, FALSE);
75 -- 
76 2.24.0
77