1 From cbb12450c2f258ef3ac8239889784e1a97dfeaa8 Mon Sep 17 00:00:00 2001
2 From: George Kiagiadakis <george.kiagiadakis@collabora.com>
3 Date: Wed, 8 Nov 2023 18:12:59 +0200
4 Subject: [PATCH 1/2] gst: avoid reporting error twice
6 First, make the error permanent by calling pw_stream_set_error()
7 and when this emits an error state again, report that to GStreamer.
9 Do the same in pipewiresink, which didn't even have the
10 pw_stream_set_error() call before, so the stream wasn't really going
11 into an error state at all.
13 Upstream-Status: Pipewire MR1763 merged
15 src/gst/gstpipewiresink.c | 9 +++++++--
16 src/gst/gstpipewiresrc.c | 10 +++++++---
17 2 files changed, 14 insertions(+), 5 deletions(-)
19 diff --git a/src/gst/gstpipewiresink.c b/src/gst/gstpipewiresink.c
20 index 36d158095..001ede9d5 100644
21 --- a/src/gst/gstpipewiresink.c
22 +++ b/src/gst/gstpipewiresink.c
23 @@ -532,8 +532,13 @@ on_state_changed (void *data, enum pw_stream_state old, enum pw_stream_state sta
24 pw_stream_trigger_process (pwsink->stream);
26 case PW_STREAM_STATE_ERROR:
27 - GST_ELEMENT_ERROR (pwsink, RESOURCE, FAILED,
28 - ("stream error: %s", error), (NULL));
29 + /* make the error permanent, if it is not already;
30 + pw_stream_set_error() will recursively call us again */
31 + if (pw_stream_get_state (pwsink->stream, NULL) != PW_STREAM_STATE_ERROR)
32 + pw_stream_set_error (pwsink->stream, -EPIPE, "%s", error);
34 + GST_ELEMENT_ERROR (pwsink, RESOURCE, FAILED,
35 + ("stream error: %s", error), (NULL));
38 pw_thread_loop_signal (pwsink->core->loop, FALSE);
39 diff --git a/src/gst/gstpipewiresrc.c b/src/gst/gstpipewiresrc.c
40 index 0514e4caa..e473338ba 100644
41 --- a/src/gst/gstpipewiresrc.c
42 +++ b/src/gst/gstpipewiresrc.c
43 @@ -681,9 +681,13 @@ on_state_changed (void *data,
44 case PW_STREAM_STATE_STREAMING:
46 case PW_STREAM_STATE_ERROR:
47 - pw_stream_set_error (pwsrc->stream, -EPIPE, "%s", error);
48 - GST_ELEMENT_ERROR (pwsrc, RESOURCE, FAILED,
49 - ("stream error: %s", error), (NULL));
50 + /* make the error permanent, if it is not already;
51 + pw_stream_set_error() will recursively call us again */
52 + if (pw_stream_get_state (pwsrc->stream, NULL) != PW_STREAM_STATE_ERROR)
53 + pw_stream_set_error (pwsrc->stream, -EPIPE, "%s", error);
55 + GST_ELEMENT_ERROR (pwsrc, RESOURCE, FAILED,
56 + ("stream error: %s", error), (NULL));
59 pw_thread_loop_signal (pwsrc->core->loop, FALSE);