Rationale:
* Detecting whether current thread uses a throttling or blocking scheduler
is now immediate instead of relying on a sentinel name.
* Each scheduler can be optimized for its purpose.
* Blocking scheduler can now be reused saving a few CPU cycles entering
and leaving.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2526>
Consider the following sequence:
1. The pipeline is being started. This occurs under the main thread.
2. A source just pushed a buffer. This occured under a ts-Context thread, let's
call it ts-ctx-1.
3. The above buffer reaches `rtprecv`, which creates a src pad, which calls the
'pad-added' callback (under ts-ctx-1).
4. The 'pad-added' callback adds elements, link them and sync their state with
the pipeline (under ts-ctx-1).
A deadlock can occur if:
A. The pipeline on-going starting process picks an element that was just added
by `pad-added`, but not synced yet => the pipeline acquires the element's
mutex (under the main thread).
B. 'pad-added' reaches `sync_with_parent()` for the element => tries to acquire
the element's mutex (under ts-ctx-1).
C. The `prepare()` method for the element attempts to spawn a ts-Task on
ts-ctx-1, which is blocked. So the ts-Task spawned notification is not
triggered.
D. Because the `prepare()` method was executed on the main thread, which is not
a ts-Context thread, the ts-Task spawned notification is awaited
synchronously. So the element state transition is blocked, keeping the
element mutex, keeping ts-ctx-1 blocked.
I couldn't find an easy way to automatically detect these conditions. The
workaround here is to use a different ts-Context for the elements which are
added in 'pad-added', their ts-Tasks will be spawned on a ts-Context which can't
to be blocked by the starting process.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2518>
* Only set `num-buffers` on the main source (the one that logs statistics).
Previously all sources would push `num-buffers` so the last 5s were excluded
from stats because some elements would start stopping before the main source
which would cause outliers. All sources now keep pushing buffers until the
main has logged the global stats & request the pipeline to shut down.
* Log when all sinks have received the Segment event. This helps identify
deadlocks in some branches. When EOS is received a log warns if not all
sinks notified they received the Segment event.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2518>
[MR 2494] introduced `task::TransitionStatus::block_on_or_add_subtask_then()`
which allows executing a function after the transition succeeds or fails,
whatever the executor being used.
In that MR, I moved the resource assignments into that function in `prepare()`,
the reasoning being that if the Task transition failed, the resources would be
useless. Examples for such resources include: dataqueues, channel senders, etc.
This was actually a bad idea: if the transition happens asynchronously, the
state change can complete and buffers can start flowing before the transition
completes, leading to resources not being available, while they will be a
moment later and could have buffered the incoming items.
This commit reverts the resource assignments before the Task transition requests
for those handled by `prepare()`.
[MR 2494]: https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2494
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2517>
We need to specify the rustls dependency explicitly configured with the
required feature/provider which in this case is ring. Without this the
selection of TLS back end can fail for HTTPS as rustls crate mandates
that either of ring or aws-lc-rs be selected explicitly via feature
flags or code.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2500>
Commit b01829ac3 switched speechmatics use of async-tungstenite to
rustls. However, this resulted in an error like below.
```
Could not automatically determine the process-level CryptoProvider from Rustls crate features.
Call CryptoProvider::install_default() before this point to select a provider manually, or make sure exactly one of the 'aws-lc-rs' and 'ring' features is enabled.
See the documentation of the CryptoProvider type for more information.
```
rustls crate requires that a specific provider be selected explicitly
by installing the provider manually which would require a code change
or specifying as an explicit dependency with the ring feature enabled.
Fix this by opting for the latter approach.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2502>
The code was lifted from the accumulator in `awstranslate`, this element
can be used to accumulate words and punctuation into complete sentences
(or sentence fragments) for synthesis and / or translation by further
elements downstream.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2350>
The test has been seen failing on CI a couple of times. I ran it 5000 times
locally without failure. This commit attempts to prevent CI from failing by
waiting for the latency event then start counting 10 buffers before checking
the resulting latency.
Also fix confusing naming for the latency field in `InterSrc`.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2497>
This new example is built upon the existing `ts-standalone`:
* `ts-standalone` allows focusing on the overhead of threadshare specific
constructs. It uses a very light source element because buffer content is not
the concern in this case.
* `ts-standalone-rtprecv` aims at simulating a closer to real world use case:
it uses `ts-audiotestsrc` and `rtprecv`. `rtprecv` can push buffers either
from the upstream thread or from a blocking thread. Note that this example
intentionally drops buffers so `rtprecv` can exhibit both behaviours.
Reminders:
* Use `GST_DEBUG=ts-standalone*:4` to display statistics.
* Compile with `--release`.
* Compile with `--feature tunning` to get stats about the duration the
Throttling Scheduler at the sink spent parked.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2496>
Some state transitions relied on `block_on`, which caused a panic due to an
attempt to block while runing on a `Context` in the following situation:
* Upstream runs on a `Context`.
* Current threadshare element state is sync on parent in a `pad-added`
callback.
This commit:
* Uses `block_on_or_add_subtask` in all call sites where `block_on` was used.
* Renames `task::TransitionStatus::await_maybe_on_context` as
`block_on_or_add_subtask()`. Previous name didn't make it explicit it could
block. The new name matches the similar function in `executor`.
* Implements a new `block_on_or_add_subtask_then()` on `task::TransitionStatus`.
Compared to `block_on_or_add_subtask()`, it will also execute the provided
function after the transition occured or failed, whathever the executor being
used.
* Remove `task::TransitionStatus::block_on` as private: it shouldn't be used in
user code (it's still used in unit tests though).
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2494>
If an upstream elements uses dmabufs - and supports the videometa -
but negotiated sysmem caps, try to use the dmabuf texture builder
for direct GPU buffer imports.
This is notably the case if a udmabuf allocator is used, but also
if elements support dmabufs but do not yet support the DMA_DRM API.
An example for the later is Snapshot on phones. On one hand its
current implementation around camerabin makes using DMA_DRM caps hard
without breaking capturing with software encoders, while on the other
hand importing buffers with GL/VK not only avoids a buffer upload/copy,
but also `DMA_BUF_IOCTL_SYNC` calls, which are potentially expensive
on aarch64. Finally importing dmabufs potentially allows offloading to
display planes.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2490>
The depfile generation was only handling lib.rs files, missing main.rs
files used by binary crates. This caused incomplete dependency tracking
for binary targets.
Also added debug logging to help diagnose issues with Cargo.toml
detection and stripped whitespace from source paths to handle parsing
edge cases.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2471>
When switching between branches that have different plugins or dependencies,
stale .d files from the previous branch can cause cargo to be unnecessarily
invoked on every build, even when no actual changes have been made.
This fix checks the modification time of dependency files against the current
build start time and ignores any .d files that weren't generated during the
current cargo run. This prevents spurious rebuilds when switching between
branches with different plugin configurations.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2471>