Commit graph

64 commits

Author SHA1 Message Date
Sebastian Dröge
8b468c3c36 audio: Generate audiobasesink/src and audiocdsrc GLib enums automatically
And ensure that GstAudioBaseSrcSlaveMethod's re-timestamp stays
re-timestamp and doesn't become retimestamp.
2017-04-09 11:49:50 +03:00
Thibault Saunier
099ac9faf2 docs: Convert gtkdoc comments to markdown
Modernizing the documentation, making it simpler to read an
modify and allowing us to possibly switch to hotdoc in the
future.
2017-03-10 18:19:17 -03:00
Marcin Kolny
89e711663f audioclock: use GstAudioClock* as first argument in GstAudioClock methods
All the GstAudioClock method declarations required object of GstClock type
as a first argument, but in fact, required GstAudioClock object (runtime
check in function body). Instead of checking type in run-time, we can
change functions declaration, to accept only GstAudioClock methods. Then,
runtime check is not necessary anymore, since always GstAudioClock object
is passed to a function.

https://bugzilla.gnome.org/show_bug.cgi?id=756628
2016-11-01 19:54:01 +02:00
Michael Olbrich
43155807cd audiobasesink: Post latency message on the bus after set_caps()
Any latency query before this will not get the correct latency so a new
latency query should be triggered once the audio sink know its own latency.

Without this the initial latency query from the pipeline arrives too early
sometimes and the resulting latency is too short.

https://bugzilla.gnome.org/show_bug.cgi?id=758911
2015-12-01 19:58:25 +02:00
Luis de Bethencourt
fe62e797d5 audiobasesink: use GST_STIME_ARGS for GstClockTimeDiff
No need to use G_GINT64_FORMAT for potentially negative values of
GstClockTimeDiff. Since 1.6 these can be handled with GST_STIME_ARGS.
Plus it creates more readable values in the logs.

https://bugzilla.gnome.org/show_bug.cgi?id=757480
2015-11-02 17:35:20 +00:00
eunhae choi
e98b96247f audiobasesink: fix issue about eos handling during flushing
If the flush-start is arrived during _eos_wait() in basesink,
the 'eos' flag is overwritten to TRUE after exiting the _eos_wait().
To resolve the overwritten issue,
the subclass doing the _eos_wait() call should return the right value.
If the eos flag is set to TRUE again, it will cause error(enter the eos flow)
of the following state changing from PAUSED to PLAYING in basesink.

https://bugzilla.gnome.org/show_bug.cgi?id=754980
2015-10-19 12:12:12 -03:00
Tim-Philipp Müller
7dac2e1eb1 audiobasesink: fix misleading error message debug detail
https://bugzilla.gnome.org/show_bug.cgi?id=754260
2015-08-29 10:44:28 +01:00
Carlos Rafael Giani
c5b75394a9 audiobasesink: added custom clock slaving method
This new clock slaving method allows for installing a callback that is
invoked during playback. Inside this callback, a custom slaving
mechanism can be used (for example, a control loop adjusting a PLL or an
asynchronous resampler). Upon request, it can skew the playout pointer
just like the "skew" method. This is useful if the clocks drifted apart
too much, and a quick reset is necessary.

Signed-off-by: Carlos Rafael Giani <dv@pseudoterminal.org>

https://bugzilla.gnome.org/show_bug.cgi?id=708362
2015-06-09 21:51:05 +10:00
Vincent Penquerc'h
5cb40d7320 audiobasesink: fix ring buffer leak on open failure 2015-04-09 13:00:58 +01:00
Arun Raghavan
557c2c9be1 audiobasesink: Reset audio clock if necessary
When the ringbuffer is deactivated and then acquired, if the audio clock
provided by the sink gets reset to zero, we need to add an offset to the
clock to make sure that subsequent samples are written out at the right
times. While we need to leave this to derived classes to take care of
when they provide their own clock (since that clock may or may not be
reset to zero), we can do this ourselves if we know the provided clock
is our own (which does reset to zero on a re-acquire).
2015-03-03 23:26:54 +05:30
Sebastian Dröge
8547594727 Improve and fix LATENCY query handling
This now follows the design docs everywhere, especially the maximum latency
handling.

https://bugzilla.gnome.org/show_bug.cgi?id=744106
2015-02-11 17:53:49 +02:00
Jan Schmidt
ca231ce321 audiobasesink: Re-work GAP buffer and trick-mode handling
In trickmode no-audio mode, or when receiving a GAP buffer,
discard the contents and render as a GAP event instead.

Make sure when rendering a gap event that the ring buffer will
restart on PAUSED->PLAYING by setting the eos_rendering flag.

This mostly reverts commit 8557ee and replaces it. The problem
with the previous approach is that it hangs in wait_preroll()
on a PLAYING-PAUSED transition because it doesn't commit state
properly.

https://bugzilla.gnome.org/show_bug.cgi?id=735666
2015-02-06 04:09:37 +11:00
Jan Schmidt
efe54e50e9 audiobasesink: Don't render a GAP silence buffer
Don't render out silence samples to a buffer, just
start the clock running, since any buffer with the
GAP flag will be discarded in render() now anyway.
2015-01-31 00:45:33 +11:00
Jan Schmidt
1df69786c3 audiobasesink: Make sure the ringbuffer is started before waiting
Don't call the basesink wait_event implementation until we're sure
the ringbuffer is running, because it might wait on a non-running
clock.
2015-01-31 00:45:33 +11:00
Jan Schmidt
8557eead82 audiobasesink: drop GAP buffers, or all buffers in trickmode no-audio mode
Make the base audio sink throw away buffers marked GAP, or all
incoming buffers when performing a trick play with
GST_SEGMENT_TRICKMODE_NO_AUDIO flag set, and make sure to start
the ringbuffer when that happens so the clock starts running.

Preserve the timing calculations when rendering, so state is all
updated the same, but just don't render samples.

https://bugzilla.gnome.org/show_bug.cgi?id=735666
2015-01-31 00:45:32 +11:00
Jan Schmidt
caff09300b audiobasesink: Make sure the ringbuffer really starts when we need it to
Some audio sink sub-classes (pulsesink) don't start their clock
when the ringbuffer starts, but always have to on EOS. When we
explicitly need to start the ringbuffer, make sure sub-classes will
do it by (ab)using the existing eos_rendering flag.
2015-01-28 16:30:42 +11:00
Thiago Santos
ef580889e0 audiobasesink: get the internal time before the clock reset
Otherwise calls to get the clock time might change its internal state
and the internal/external time for calibration get unbalanced leading to
a clock jump

https://bugzilla.gnome.org/show_bug.cgi?id=740834
2014-12-22 10:22:03 -03:00
Sebastian Dröge
ceb9de6e55 audiobase{sink,src}: Don't hold the object lock while calling create_ringbuffer() vfunc
The implementation of that vfunc might want to use the object lock for
something too. It's generally not a good idea to keep the object lock while
calling any function implemented elsewhere.

Also the ringbuffer can only be NULL at this point, remove a useless if block.

And in the sink actually hold the object lock while setting the ringbuffer on
the instance. Code accessing this is expected to use the object lock, so do it
here ourselves too.
2014-12-22 10:47:36 +01:00
Arun Raghavan
c47b005197 audio: Fix up a comment in GstAudioBaseSink
Rewrote the comment to not be PulseAudio-specific.
2014-09-29 19:46:32 +05:30
Garg
47e303269d audiobasesink: Fix deadlock caused by holding object lock while calling clock functions
Issue:
During a PAUSED->PLAYING transition when we are rendering an audio buffer in AudioBaseSink
we make adjustments to the sink's provided clock i.e. fix clock calibration using the external
pipeline clock, within "gst_audio_base_sink_sync_latency function inside gstaudiobasesink.c".
For the calibration adjustment we need to get the sink clock time using "gst_audio_clock_get_time".
But before calling "gst_audio_clock_get_time" we acquire the Object Lock on the Sink. If sink is
a pulsesink, "gst_audio_clock_get_time" internally calls "gst_pulsesink_get_time" which needs to
acquire Pulse Audio Main Loop Lock before querying Pulse Audio for its stream time using
"pa_stream_get_time". Please see "gst_pulsesink_get_time in pulsesink.c".

So the situation here is we have acquired the Object lock on Sink and need PA Main Loop Lock.
Now Pulse Audio Main Thread itself might be in the process of posting a stream status
message after Paused to Playing transition which in turn acquires the PA Main loop lock and
needs the Object Lock on Pulse Sink. This causes a deadlock with the earlier render thread.

Fix:
Do not acquire the object Lock on Sink before querying the time on PulseSink clock. This is
similar to the way we have used get_time at other places in the code. Acquire it after the
get_time call. This way PA Main loop will be able to post its stream status message by
acquiring the Sink Object lock and will eventually release its Main Loop lock needed for
gst_pulsesink_get_time to continue.

https://bugzilla.gnome.org/show_bug.cgi?id=736071
2014-09-12 14:21:19 +03:00
Tim-Philipp Müller
bcb8068e27 docs: remove outdated and pointless 'Last reviewed' lines from docs
They are very confusing for people, and more often than not
also just not very accurate. Seeing 'last reviewed: 2005' in
your docs is not very confidence-inspiring. Let's just remove
those comments.
2014-04-26 23:28:57 +01:00
Vincent Penquerc'h
7618699ffd audiobasesink: avoid possible sample count overflow
At 48 kHz, 2<<31 samples is reached before 13 hours so it
sounds plausible this would be hit.

Coverity 1139800, 1139801
2014-04-10 11:06:00 +01:00
Vincent Penquerc'h
169166d0a2 audiobasesink: clip start samples to match clipped start time
Clock slaving can clip start time to zero, giving us a shorted
duration than we originally got. To keep in sync, we must then
discard the samples falling before that zero timestamp.

This possibly fixes random distortion caused by constant PA
underflows which are never resynced.
2014-04-04 17:04:06 +01:00
Wim Taymans
6a88d6f8cd audiobasesink: make _get_time more threadsafe
We call the _get_time function from the provided clock and we don't lock
the sink object for performance reasons. Make sure we only read and
check variables once so that they don't change while we are executing
the code.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=720661
2014-01-21 11:25:18 +01:00
Jan Schmidt
c24a1254c9 audiodecoder: Choose a default initial caps before sending GAP
If there are no caps from the audio decoder when handling a GAP
event - as when one is received right at the start on a DVD without
initial audio - then choose any default caps for downstream and
then send the GAP, so the audio sink has a configured format in
which to start the ringbuffer.

Also, make the audio sink reject a GAP without caps with a clearer
error message.

Fixes bug https://bugzilla.gnome.org/show_bug.cgi?id=603921
2013-12-27 04:04:45 +11:00
Reynaldo H. Verdejo Pinochet
21190b9749 gstaudiobasesink: Always reset last_align
Should be done for all the reset_sync() cases. Not
only for the READY to PAUSED one.
2013-12-20 18:06:25 -03:00
Reynaldo H. Verdejo Pinochet
032779ff13 gstaudiobasesink: Reset last_align to 0, not -1
This is the expected behavior in READY -> PAUSED
2013-12-20 18:02:42 -03:00
Reynaldo H. Verdejo Pinochet
c1de7cdefb gstaudiobasesink: Always reset avg_skew on _reset
Only case in which it wasn't (READY to PAUSED) should
have had this value reseted too.
2013-12-20 17:58:43 -03:00
Reynaldo H. Verdejo Pinochet
adf800087c gstaudiobasesink: Retarget FIXME to 2.0
Properly fixing this one would break API
2013-12-20 17:48:22 -03:00
Reynaldo H. Verdejo Pinochet
d35db35258 gstaudiobasesink: Factor out reset sync routine 2013-12-20 17:47:38 -03:00
Reynaldo H. Verdejo Pinochet
b324d67586 gstaudiobasesink: Drop dead _sink_async_play() code 2013-12-20 13:58:34 -03:00
Reynaldo H. Verdejo Pinochet
2f04733a4b gstaudiobasesink: Break some too long lines 2013-12-20 13:58:33 -03:00
Reynaldo H. Verdejo Pinochet
187b106202 gstaudiobasesink: Cosmetics, grammar/spelling
- Drop repeated 'yet' from debug msg
- Drop repeated 'to' from param desc
- Some spelling
2013-12-20 13:58:33 -03:00
Reynaldo H. Verdejo Pinochet
86b0a0d6d0 gstaudiobasesink: Refactor alignment computation for clarity 2013-12-19 18:05:44 -03:00
Wim Taymans
df3718ea2b audiobasesink: handle the RESYNC flag
Also resync when a buffer with the RESYNC flag is seen.
2013-12-05 16:27:35 +01:00
Wim Taymans
c9ff3e4f98 audiobasesink: do big correction for large drift
If we are using skew slaving and we drift more than twice the allowed amount, do
a big correction to get back on track more quickly.
2013-09-25 16:03:07 +02:00
Sebastian Dröge
3f82e919dd libs: Use foo/foo.h as single-include header consistently everywhere
https://bugzilla.gnome.org/show_bug.cgi?id=688785
2012-12-12 17:13:10 +00:00
Tim-Philipp Müller
5f59b4f7ee Fix FSF address
https://bugzilla.gnome.org/show_bug.cgi?id=687520
2012-11-03 23:05:09 +00:00
Miguel Angel Cabrera Moya
244fdcc69a audiobasesink: use the same type as the internal type to return it
https://bugzilla.gnome.org/show_bug.cgi?id=687466
2012-11-02 19:52:38 +00:00
Sebastian Dröge
1813701ef2 audiobasesink: Add explanation to the GAP event handling code 2012-10-24 11:22:29 +02:00
Sebastian Dröge
b793d0bfae audiobasesink: Properly handle GAP events
These are now converted into silence buffers if they have
a duration or cause the ringbuffer and clock to be started
if they don't have a duration.

Fixes bug #685273.
2012-10-24 11:19:05 +02:00
Wim Taymans
a57198a0ba audio: improve property description
Improve the description of the latency-time and buffer-time properties in the
audio sink and source.
2012-09-14 16:08:50 +02:00
Wim Taymans
668ce33384 update for basesink change 2012-09-04 12:18:11 +02:00
Edward Hervey
def07410ef audiobasesink: Avoid resetting ringbuffer when not needed
If the ringbuffer was configured to the same caps as previously, we
don't need to reconfigure it.
2012-08-14 18:56:00 +02:00
Edward Hervey
2817bdadc9 libs: Remove "Since" markers and minor doc fixups 2012-07-13 12:11:06 +02:00
Edward Hervey
c9428c96b1 baseaudiosink: Resync when ringbuffer resets
When the ringbuffer gets restarted (like in setcaps), we *will* have
to resync against the new values.

Without this we end up blindly assuming the new samples align to the
old ones.
2012-07-12 09:51:35 +02:00
Wim Taymans
c003efcc63 audiobasesink: fix for basesink API change 2012-06-18 11:40:36 +02:00
Wim Taymans
dfb8e7cb2c don't pass random pointers to pull_range 2012-03-16 21:46:47 +01:00
Wim Taymans
25137962ad fix for caps API changes 2012-03-11 19:04:41 +01:00
Wim Taymans
7296ef7c63 audiobasesink: add some G_LIKELY 2012-03-09 17:15:38 +01:00