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 787560 - audio: Add helper object for audio discontinuity detection
audio: Add helper object for audio discontinuity detection
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
unspecified
Other All
: Normal enhancement
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks: 787297 788284 788285 788286 788287
 
 
Reported: 2017-09-11 19:50 UTC by Sebastian Dröge (slomo)
Modified: 2017-09-28 11:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
audio: Add helper object for audio discontinuity detection (22.38 KB, patch)
2017-09-11 19:50 UTC, Sebastian Dröge (slomo)
none Details | Review
audio: Add helper object for audio discontinuity detection (21.19 KB, patch)
2017-09-12 12:27 UTC, Sebastian Dröge (slomo)
none Details | Review
audio: Add reverse playback support to GstAudioDiscontDetect (12.36 KB, patch)
2017-09-12 13:04 UTC, Sebastian Dröge (slomo)
none Details | Review
audio: Add helper object for audio discontinuity detection (21.27 KB, patch)
2017-09-12 13:15 UTC, Sebastian Dröge (slomo)
none Details | Review
audio: Add helper object for audio discontinuity detection (24.61 KB, patch)
2017-09-12 13:31 UTC, Sebastian Dröge (slomo)
none Details | Review
audio: Add reverse playback support to GstAudioDiscontDetect (12.31 KB, patch)
2017-09-12 13:32 UTC, Sebastian Dröge (slomo)
none Details | Review
audiobuffersplit: Use new GstAudioDiscontDetect API (8.81 KB, patch)
2017-09-12 13:43 UTC, Sebastian Dröge (slomo)
none Details | Review
audiobuffersplit: Drain pending samples if the caps are changing (2.27 KB, patch)
2017-09-12 13:43 UTC, Sebastian Dröge (slomo)
none Details | Review
audio: Add helper object for audio discontinuity detection and sample alignment (24.25 KB, patch)
2017-09-13 13:09 UTC, Sebastian Dröge (slomo)
committed Details | Review
audio: Add reverse playback support to GstAudioStreamAlign (12.16 KB, patch)
2017-09-13 13:09 UTC, Sebastian Dröge (slomo)
committed Details | Review
audio: Add stream align API for getting timestamp at discont and number of samples since discont (9.25 KB, patch)
2017-09-13 13:24 UTC, Sebastian Dröge (slomo)
committed Details | Review
audiobuffersplit: Use new GstAudioStreamAlign API (10.35 KB, patch)
2017-09-13 13:29 UTC, Sebastian Dröge (slomo)
committed Details | Review
audiobuffersplit: Drain pending samples if the caps are changing (2.24 KB, patch)
2017-09-13 13:29 UTC, Sebastian Dröge (slomo)
committed Details | Review

Description Sebastian Dröge (slomo) 2017-09-11 19:50:22 UTC
See commit message
Comment 1 Sebastian Dröge (slomo) 2017-09-11 19:50:28 UTC
Created attachment 359554 [details] [review]
audio: Add helper object for audio discontinuity detection

This is the same code that is in decklinkaudiosrc, audioringbuffer,
audiomixer and various other places. Have it once instead of copying it
everywhere.
Comment 2 Sebastian Dröge (slomo) 2017-09-12 12:27:07 UTC
Created attachment 359620 [details] [review]
audio: Add helper object for audio discontinuity detection

This is the same code that is in decklinkaudiosrc, audioringbuffer,
audiomixer and various other places. Have it once instead of copying it
everywhere.
Comment 3 Sebastian Dröge (slomo) 2017-09-12 13:04:16 UTC
Created attachment 359623 [details] [review]
audio: Add reverse playback support to GstAudioDiscontDetect
Comment 4 Sebastian Dröge (slomo) 2017-09-12 13:06:17 UTC
Now only has to be used in:
- audiobasesink
- audiobuffersplit
- audiomixer base class
- decklinkaudiosrc/sink
- splitmuxsink

... and audiorate to improve on the current somewhat suboptimal behaviour.
Comment 5 Sebastian Dröge (slomo) 2017-09-12 13:15:43 UTC
Created attachment 359624 [details] [review]
audio: Add helper object for audio discontinuity detection

This is the same code that is in decklinkaudiosrc, audioringbuffer,
audiomixer and various other places. Have it once instead of copying it
everywhere.
Comment 6 Sebastian Dröge (slomo) 2017-09-12 13:31:52 UTC
Created attachment 359628 [details] [review]
audio: Add helper object for audio discontinuity detection

This is the same code that is in decklinkaudiosrc, audioringbuffer,
audiomixer and various other places. Have it once instead of copying it
everywhere.
Comment 7 Sebastian Dröge (slomo) 2017-09-12 13:32:04 UTC
Created attachment 359629 [details] [review]
audio: Add reverse playback support to GstAudioDiscontDetect
Comment 8 Sebastian Dröge (slomo) 2017-09-12 13:43:50 UTC
Created attachment 359631 [details] [review]
audiobuffersplit: Use new GstAudioDiscontDetect API
Comment 9 Sebastian Dröge (slomo) 2017-09-12 13:43:56 UTC
Created attachment 359632 [details] [review]
audiobuffersplit: Drain pending samples if the caps are changing
Comment 10 Tim-Philipp Müller 2017-09-12 14:58:37 UTC
API looks fine, but I don't quite like the name yet (surprise!).

It does more than detect disconts.

How about GstAudioContinuityTracker or GstAudioPositionTracker or somesuch?
Comment 11 Sebastian Dröge (slomo) 2017-09-13 13:09:42 UTC
Created attachment 359718 [details] [review]
audio: Add helper object for audio discontinuity detection and sample alignment

This is the same code that is in decklinkaudiosrc, audioringbuffer,
audiomixer and various other places. Have it once instead of copying it
everywhere.
Comment 12 Sebastian Dröge (slomo) 2017-09-13 13:09:48 UTC
Created attachment 359719 [details] [review]
audio: Add reverse playback support to GstAudioStreamAlign
Comment 13 Sebastian Dröge (slomo) 2017-09-13 13:24:10 UTC
Created attachment 359721 [details] [review]
audio: Add stream align API for getting timestamp at discont and number of samples since discont
Comment 14 Sebastian Dröge (slomo) 2017-09-13 13:29:46 UTC
Created attachment 359723 [details] [review]
audiobuffersplit: Use new GstAudioStreamAlign API
Comment 15 Sebastian Dröge (slomo) 2017-09-13 13:29:52 UTC
Created attachment 359724 [details] [review]
audiobuffersplit: Drain pending samples if the caps are changing
Comment 16 Tim-Philipp Müller 2017-09-13 13:32:05 UTC
Worksforme :)

If you're not going to make all elements use it, please open enhancement bugs for elements that need to be ported still.
Comment 17 Sebastian Dröge (slomo) 2017-09-26 08:20:29 UTC
Ok, any other comments before I merge this? :)
Comment 18 Nicolas Dufresne (ndufresne) 2017-09-27 15:14:04 UTC
Review of attachment 359718 [details] [review]:

Looks good in general, I have couple of questions, nothing major really.

::: gst-libs/gst/audio/gstaudiostreamalign.c
@@ +26,3 @@
+#include "gstaudiostreamalign.h"
+
+G_DEFINE_BOXED_TYPE (GstAudioStreamAlign, gst_audio_stream_align,

I was wondering between GstAudioStreamAlignment vs GstAudioStreamAlign, we have GstVidoAlginment, but GstAllocationParams.align. So I guess it makes it's pretty equal, just mentionning, nothing to change.

@@ +29,3 @@
+    (GBoxedCopyFunc) gst_audio_stream_align_copy,
+    (GBoxedFreeFunc) gst_audio_stream_align_free);
+

Maybe a SECTION block to help document ?

@@ +72,3 @@
+  align = g_new0 (GstAudioStreamAlign, 1);
+  align->rate = rate;
+  align->alignment_threshold = 40 * GST_MSECOND;

Why isn't this parameters like the rate? They are configurable in the sink, then the base class fixate the defaults no ? I also remember a recent thread indicating a possible bug that after fix allow reducing greatly the thresholds, so maybe we shoulnd't scatter the defaults ?
Comment 19 Nicolas Dufresne (ndufresne) 2017-09-27 15:16:15 UTC
Review of attachment 359719 [details] [review]:

Looks good.
Comment 20 Nicolas Dufresne (ndufresne) 2017-09-27 15:18:15 UTC
Review of attachment 359721 [details] [review]:

Optional comment for this one.

::: gst-libs/gst/audio/gstaudiostreamalign.h
@@ -31,2 @@
 GST_EXPORT
-GType                   gst_audio_stream_align_get_type                (void);

the reformatting is nice, by quite unrelated. It's nitpicking, bug maybe we could have slip it up ?
Comment 21 Nicolas Dufresne (ndufresne) 2017-09-27 15:21:55 UTC
Review of attachment 359723 [details] [review]:

::: gst/audiobuffersplit/gstaudiobuffersplit.c
@@ +154,3 @@
+  self->stream_align = gst_audio_stream_align_new (48000);
+  gst_audio_stream_align_set_alignment_threshold (self->stream_align,
+      DEFAULT_ALIGNMENT_THRESHOLD);

This is a good argument toward moving the alignment threshold as a paramter to _new().

@@ +156,3 @@
+      DEFAULT_ALIGNMENT_THRESHOLD);
+  gst_audio_stream_align_set_discont_wait (self->stream_align,
+      DEFAULT_DISCONT_WAIT);

And maybe this one too then ?

@@ +389,3 @@
+      || GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_RESYNC),
+      GST_BUFFER_PTS (buffer), gst_buffer_get_size (buffer) / bpf, NULL, NULL,
+      NULL);

I would create couple of local variable to make this more readable.

::: gst/audiobuffersplit/gstaudiobuffersplit.h
@@ +53,3 @@
   GstAdapter *adapter;
 
+  GstAudioStreamAlign *stream_align;

The new API is not thread safe, and this is access through property. Maybe document the locking ? OBJECT_LOCK ?
Comment 22 Nicolas Dufresne (ndufresne) 2017-09-27 15:23:14 UTC
Review of attachment 359724 [details] [review]:

::: gst/audiobuffersplit/gstaudiobuffersplit.c
@@ +498,3 @@
+        }
+        self->info = info;
+        gst_audio_stream_align_set_rate (self->stream_align, self->info.rate);

Locking ?
Comment 23 Sebastian Dröge (slomo) 2017-09-28 11:07:01 UTC
Attachment 359718 [details] pushed as ec1e20f - audio: Add helper object for audio discontinuity detection and sample alignment
Attachment 359719 [details] pushed as d2fd740 - audio: Add reverse playback support to GstAudioStreamAlign
Attachment 359721 [details] pushed as bf68e74 - audio: Add stream align API for getting timestamp at discont and number of samples since discont
Comment 24 Sebastian Dröge (slomo) 2017-09-28 11:09:42 UTC
(In reply to Nicolas Dufresne (stormer) from comment #18)

> @@ +26,3 @@
> +#include "gstaudiostreamalign.h"
> +
> +G_DEFINE_BOXED_TYPE (GstAudioStreamAlign, gst_audio_stream_align,
> 
> I was wondering between GstAudioStreamAlignment vs GstAudioStreamAlign, we
> have GstVidoAlginment, but GstAllocationParams.align. So I guess it makes
> it's pretty equal, just mentionning, nothing to change.

Align would be a verb, this thing is doing something (-> verb) while GstVideoAlignment is just data (-> noun). GstAllocationParams.align is an "order", please align that much (-> verb). IMHO this all makes sense as is :)

> @@ +29,3 @@
> +    (GBoxedCopyFunc) gst_audio_stream_align_copy,
> +    (GBoxedFreeFunc) gst_audio_stream_align_free);
> +
> 
> Maybe a SECTION block to help document ?

Done

> @@ +72,3 @@
> +  align = g_new0 (GstAudioStreamAlign, 1);
> +  align->rate = rate;
> +  align->alignment_threshold = 40 * GST_MSECOND;
> 
> Why isn't this parameters like the rate? They are configurable in the sink,
> then the base class fixate the defaults no ? I also remember a recent thread
> indicating a possible bug that after fix allow reducing greatly the
> thresholds, so maybe we shoulnd't scatter the defaults ?

Added to the constructor now, good idea :)


(In reply to Nicolas Dufresne (stormer) from comment #20)
> Review of attachment 359721 [details] [review] [review]:
> 
> Optional comment for this one.
> 
> ::: gst-libs/gst/audio/gstaudiostreamalign.h
> @@ -31,2 @@
>  GST_EXPORT
> -GType                   gst_audio_stream_align_get_type               
> (void);
> 
> the reformatting is nice, by quite unrelated. It's nitpicking, bug maybe we
> could have slip it up ?

The reformatting is only needed because of this new commit :) It requires horizontal indentation to be increased.
Comment 25 Sebastian Dröge (slomo) 2017-09-28 11:14:00 UTC
Attachment 359723 [details] pushed as dd490e1 - audiobuffersplit: Use new GstAudioStreamAlign API
Attachment 359724 [details] pushed as d01724a - audiobuffersplit: Drain pending samples if the caps are changing