Commit graph

10 commits

Author SHA1 Message Date
François Laignel
116cf9bd3c threadshare/*src: rework pause/flush_start/flush_stop
This commit fixes several issues with the `Ts*Src` elements.

The pause functions used cancel_task which breaks the Task loop at await
points. For some elements, this implies making sure no item is being lost.
Moreover, cancelling the Task also cancels downstream processing, which
makes it difficult to ensure elements can handle all cases.

This commit reimplements Task::pause which allows completing the running
loop iteration before pausing the loop.

See https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/277#note_439529

In the Paused state, incoming items were rejected by TsAppSrc and DataQueue.

See https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/277#note_438455

- FlushStart must engage items rejection and cancel the Task.
- FlushStop must purge the internal stream & accept items again.

If the task was cancelled, `push_prelude` could set `need_initial_events`
to `true` when the events weren't actually pushed yet.

TsAppSrc used to renew its internal channel which could cause Buffer loss
when transitionning Playing -> Paused -> Playing.

See https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/issues/98
2020-03-21 18:46:03 +00:00
Sebastian Dröge
56895f35bc threadshare/runtime: Add a dummy context when blocking the current thread
This allows downstreams to function as if a normal context thread is
operating upstream apart from not being able to spawn new tasks.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/issues/96
2020-03-16 15:19:39 +02:00
Sebastian Dröge
12dcca3f17 threadshare/runtime: Drain pending sub tasks in a loop
A pending sub task might add new pending sub tasks that have to be
handled first.
2020-03-16 15:02:30 +02:00
François Laignel
4c584fd162 threadshare: Pad{Src,Sink}::unprepare: release all functions 2020-03-15 13:17:26 +02:00
Sebastian Dröge
e729324cce threadshare: Refactor infrastructure
The biggest changes are
- Many functions are not asynchronous anymore as it would be difficult
  to run them correctly with our mix of synchronous C code and Rust
  code.
- The pad context and its corresponding custom event are gone and
  instead thread local storage and task local storage are used. This
  makes it easier to correctly pass it through the different layers
  of Rust and C code and back.
- Sink events have a different function for serialized and oob events,
  src events are handled correctly by default now by simply forwarding
  them.
- Task::prepare() has a separate variant that takes a preparation
  function as this is a very common task.
- The task loop function can signal via its return value if it wants to
  be called again or not.
2020-03-15 13:17:26 +02:00
François Laignel
d1cc8eaec8 ts: don't panic when operating on a Context without a valid PadContext
Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/issues/94
2020-01-22 06:16:17 +00:00
François Laignel
a15d60105b ts: fix FlushStart / FlushStop events handling 2020-01-16 00:44:45 +01:00
François Laignel
3eed2f69d9 ts: have block_on panic if running on a Context thread 2020-01-16 00:18:16 +01:00
François Laignel
0221524a10 Update to tokio release 0.2.5 + throttling 2019-12-21 08:56:43 +01:00
François Laignel
e8f5191ee7 ts: Pad wrapper for async processing
See https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/merge_requests/170#note_276334
and https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/merge_requests/204
2019-12-21 08:56:43 +01:00