After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 781721 - inter: Add overflow-mode property and alternative "block" mode
inter: Add overflow-mode property and alternative "block" mode
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal enhancement
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks: 791348 791353
 
 
Reported: 2017-04-25 14:00 UTC by Carlos Rafael Giani
Modified: 2018-11-03 14:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for new overflow-mode in inter elements (22.65 KB, patch)
2017-04-25 14:03 UTC, Carlos Rafael Giani
none Details | Review
Patch for new overflow-mode in inter elements , v2 (22.99 KB, patch)
2017-05-04 16:31 UTC, Carlos Rafael Giani
needs-work Details | Review

Description Carlos Rafael Giani 2017-04-25 14:00:51 UTC
Right now, the inter elements discard existing data if the channel is full. This is undesirable if one wants to use inter elements for creating a "producer" and a "consumer" pipeline. Example:

gst-launch-1.0 audiotestsrc ! interaudiosink sync=false  interaudiosrc ! alsasink

This will output a corrupted sine wave and use 100% CPU, which is because interaudiosink will output data as fast as the CPU allows - if the channel is full, it just flushes the oldest samples until there is enough room for new ones.

This current behavior is retained and remains the default; it is now called the "flush" mode. The overflow-mode property introduces an alternative behavior, the "block" mode. In this mode, if the channel is full, inter*sink elements block until the channel has enough free space. With intervideo and interaudio, this means that the sink elements block until the corresponding src elements have read out the last buffer (= the channel has a capacity of exactly one buffer). With interaudio, this means that the interaudiosink element blocks until the interaudiosrc element has retrieved period-time nanoseconds of audio data from the channel.

NOTE: This is a first version that does not include tests yet. Also, the intersub element changes have not been tested yet because so far I could not construct a test pipeline because the intersubsink sink caps are incompatible with existing subtitle parsers (perhaps a good topic for a separate intersub bugfix?).
Comment 1 Carlos Rafael Giani 2017-04-25 14:03:00 UTC
Created attachment 350399 [details] [review]
Patch for new overflow-mode in inter elements
Comment 2 Carlos Rafael Giani 2017-05-04 16:31:29 UTC
Created attachment 351065 [details] [review]
Patch for new overflow-mode in inter elements , v2

Surface mutex was held during preroll in the sinks. This updated version of the patch unlocks the mutex prior to entering preroll & locks it back after unless the preroll was ended unexpectedly.
Comment 3 Sebastian Dröge (slomo) 2017-10-31 17:06:01 UTC
Review of attachment 351065 [details] [review]:

::: gst/inter/gstinter.h
@@ +27,3 @@
+
+typedef enum {
+  GST_INTER_OVERFLOW_MODE_FLUSH,

Flush seems like a weird name. It's "non-blocking", it does not flush :)

::: gst/inter/gstinteraudiosink.c
@@ +357,3 @@
+        if (g_atomic_int_get (&interaudiosink->unlocked)) {
+          g_mutex_unlock (&interaudiosink->surface->mutex);
+          if ((ret = gst_base_sink_wait_preroll (sink)) != GST_FLOW_OK)

What is this case and why do we wait for preroll here? Needs a comment.

Usually if unlock(), you want to get out of render ASAP and return FLUSHING

@@ +363,3 @@
+
+        g_cond_wait (&interaudiosink->surface->cond,
+            &interaudiosink->surface->mutex);

You need to detect the unlock/flushing case here, in which case you want to go out immediately.
Comment 4 Carlos Rafael Giani 2017-12-07 14:09:57 UTC
> Flush seems like a weird name. It's "non-blocking", it does not flush :)

I called it flush because of the gst_adapter_flush() call in interaudiosink, but perhaps this is too specific. What about "overwrite-oldest"?

> What is this case and why do we wait for preroll here? Needs a comment.

This follows the GstBaseSink unlock() documentation, which states: "Subclasses should unblock any blocked function ASAP and call gst_base_sink_wait_preroll()"

> You need to detect the unlock/flushing case here, in which case you want to go out immediately.

This actually already happens. In the unlock/flushing case, the unlock() vfunc is called, which sets the unlocked flag and signals the condition variable.
Comment 5 GStreamer system administrator 2018-11-03 14:07:47 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/549.