gstreamer/subprojects/gst-plugins-good/ext/adaptivedemux2
Thibault Saunier 049859c2cb adaptivedemux2: Do not submit_transfer when cancelled
There is a race condition where transfer has not been submitted yet while the
request is cancelled which leads to the transfer state going back to
`DOWNLOAD_REQUEST_STATE_OPEN` and the user of the request to get signalled about
its completion (and the task actually happening after it was cancelled) leading
to assertions and misbehaviours.

To ensure that this race can't happen, we start differentiating between the
UNSENT and CANCELLED states as in the normal case, when entering `submit_request`
the state is UNSENT and at that point we need to know that it is not because
the request has been cancelled.

In practice this case lead to an assertion in
`gst_adaptive_demux2_stream_begin_download_uri` because in a previous call to
`gst_adaptive_demux2_stream_stop_default` we cancelled the previous request and
setup a new one while it had not been submitted yet and then got a `on_download_complete`
callback called from that previous cancelled request and then we tried to do
`download_request_set_uri` on a request that was still `in_use`, leading to
something like:

```
 #0: 0x0000000186655ec8 g_assert (request->in_use == FALSE)assert.c:0
 #1: 0x00000001127236b8 libgstadaptivedemux2.dylib`download_request_set_uri(request=0x000060000017cc00, uri="https://XXX/chunk-stream1-00002.webm", range_start=0, range_end=-1) at downloadrequest.c:361
 #2: 0x000000011271cee8 libgstadaptivedemux2.dylib`gst_adaptive_demux2_stream_begin_download_uri(stream=0x00000001330f1800, uri="https://XXX/chunk-stream1-00002.webm", start=0, end=-1) at gstadaptivedemux-stream.c:1447
 #3: 0x0000000112719898 libgstadaptivedemux2.dylib`gst_adaptive_demux2_stream_load_a_fragment [inlined] gst_adaptive_demux2_stream_download_fragment(stream=0x00000001330f1800) at gstadaptivedemux-stream.c:0
 #4: 0x00000001127197f8 libgstadaptivedemux2.dylib`gst_adaptive_demux2_stream_load_a_fragment(stream=0x00000001330f1800) at gstadaptivedemux-stream.c:1969
 #5: 0x000000011271c2a4 libgstadaptivedemux2.dylib`gst_adaptive_demux2_stream_next_download(stream=0x00000001330f1800) at gstadaptivedemux-stream.c:2112
```

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5435>
2023-10-05 20:55:00 +00:00
..
dash mpdhelper: remove useless code 2023-09-28 18:31:07 +00:00
hls hlsdemux2: Ensure processed webvtt ends with empty new line 2023-07-04 10:57:01 +02:00
mss adaptivedemux2: Don't leak taglist 2023-02-03 16:52:24 +00:00
downloadhelper.c adaptivedemux2: Do not submit_transfer when cancelled 2023-10-05 20:55:00 +00:00
downloadhelper.h adaptivedemux2: Define RFC8673_LAST_BYTE_POS 2023-02-03 16:52:22 +00:00
downloadrequest.c adaptivedemux2: Do not submit_transfer when cancelled 2023-10-05 20:55:00 +00:00
downloadrequest.h adaptivedemux2: Do not submit_transfer when cancelled 2023-10-05 20:55:00 +00:00
gstadaptivedemux-period.c adaptivedemux2: Add gst_adaptive_demux_period_add_stream() 2023-02-03 16:52:23 +00:00
gstadaptivedemux-private.h adaptivedemux2: Remove API lock 2023-07-28 12:27:09 +00:00
gstadaptivedemux-stream.c adaptivedemux2: Handle early key-unit seek 2023-06-22 06:56:33 +00:00
gstadaptivedemux-stream.h adaptivedemux2: Fix download error handling more 2023-02-03 16:52:23 +00:00
gstadaptivedemux-track.c adaptivedemux2: Fix early seeking 2023-06-22 06:56:33 +00:00
gstadaptivedemux-types.h adaptivedemux2: Refactor stream methods into the stream 2022-11-05 04:00:31 +11:00
gstadaptivedemux.c gstadaptivedemux: fix memory leak 2023-08-07 14:18:21 +08:00
gstadaptivedemux.h adaptivedemux2: Split track id from event stream-id 2023-02-10 10:56:52 +00:00
gstadaptivedemuxelement.c adaptivedemux2: fix plugin/element init 2022-05-30 13:13:48 +00:00
gstadaptivedemuxelements.h adaptivedemux2: fix plugin/element init 2022-05-30 13:13:48 +00:00
gstadaptivedemuxutils.c adaptivedemux2: drop use of GSlice 2023-01-24 15:25:06 +00:00
gstadaptivedemuxutils.h New HLS, DASH and MSS adaptive demuxer elements 2022-04-18 14:11:23 +00:00
gstisoff.c New HLS, DASH and MSS adaptive demuxer elements 2022-04-18 14:11:23 +00:00
gstisoff.h New HLS, DASH and MSS adaptive demuxer elements 2022-04-18 14:11:23 +00:00
meson.build adaptivedemux2: Add GStreamer to the deps list 2022-11-23 09:29:14 +00:00
plugin.c adaptivedemux2: fix plugin/element init 2022-05-30 13:13:48 +00:00