class new (rate, alignment_threshold, discont_wait)
  copy ()
  free ()
  get_alignment_threshold ()
  get_discont_wait ()
  get_rate ()
  get_samples_since_discont ()
  get_timestamp_at_discont ()
  mark_discont ()
  process (discont, timestamp, n_samples)
  set_alignment_threshold (alignment_threshold)
  set_discont_wait (discont_wait)
  set_rate (rate)


class GstAudio.AudioStreamAlign

GstAudio.AudioStreamAlign provides a helper object that helps tracking audio stream alignment and discontinuities, and detects discontinuities if possible.

See for a description of its parameters and GstAudio.AudioStreamAlign.process() for the details of the processing.

New in version 1.14.

classmethod new(rate, alignment_threshold, discont_wait)[source]
  • rate (int) – a sample rate
  • alignment_threshold (int) – a alignment threshold in nanoseconds
  • discont_wait (int) – discont wait in nanoseconds

a new GstAudio.AudioStreamAlign. free with

Return type:


Allocate a new GstAudio.AudioStreamAlign with the given configuration. All processing happens according to sample rate rate, until gst_audio_discont_wait_set_rate() is called with a new rate. A negative rate can be used for reverse playback.

alignment_threshold gives the tolerance in nanoseconds after which a timestamp difference is considered a discontinuity. Once detected, discont_wait nanoseconds have to pass without going below the threshold again until the output buffer is marked as a discontinuity. These can later be re-configured with GstAudio.AudioStreamAlign.set_alignment_threshold() and GstAudio.AudioStreamAlign.set_discont_wait().

New in version 1.14.

Returns:a new GstAudio.AudioStreamAlign. free with
Return type:GstAudio.AudioStreamAlign

Copy a GstAudio.AudioStreamAlign structure.

New in version 1.14.


Free a GstAudio.AudioStreamAlign structure previously allocated with or GstAudio.AudioStreamAlign.copy().

New in version 1.14.

Return type:int
Return type:int
Return type:int
Returns:The number of samples processed since the last discontinuity.
Return type:int

Returns the number of samples that were processed since the last discontinuity was detected.

New in version 1.14.

Returns:The last timestamp at when a discontinuity was detected
Return type:int

Timestamp that was passed when a discontinuity was detected, i.e. the first timestamp after the discontinuity.

New in version 1.14.


Marks the next buffer as discontinuous and resets timestamp tracking.

New in version 1.14.

process(discont, timestamp, n_samples)[source]
  • discont (bool) – if this data is considered to be discontinuous
  • timestamp (int) – a #GstClockTime of the start of the data
  • n_samples (int) – number of samples to process

True if a discontinuity was detected, False otherwise.

out_timestamp:output timestamp of the data
out_duration:output duration of the data
 output sample position of the start of the data

Return type:

(bool, out_timestamp: int, out_duration: int, out_sample_position: int)

Processes data with timestamp and n_samples, and returns the output timestamp, duration and sample position together with a boolean to signal whether a discontinuity was detected or not. All non-discontinuous data will have perfect timestamps and durations.

A discontinuity is detected once the difference between the actual timestamp and the timestamp calculated from the sample count since the last discontinuity differs by more than the alignment threshold for a duration longer than discont wait.

Note: In reverse playback, every buffer is considered discontinuous in the context of buffer flags because the last sample of the previous buffer is discontinuous with the first sample of the current one. However for this function they are only considered discontinuous in reverse playback if the first sample of the previous buffer is discontinuous with the last sample of the current one.

New in version 1.14.

Parameters:alignment_threshold (int) –
Parameters:discont_wait (int) –
Parameters:rate (int) –