Commit graph

171 commits

Author SHA1 Message Date
Vincent Penquerc'h
0d47c615ad baseaudiosink: make unsigned properties unsigned, not signed 2011-11-10 15:55:31 +00:00
Tim-Philipp Müller
d7fc45f42e docs: fix up some Since: markers 2011-11-07 23:05:44 +00:00
Felipe Contreras
3df415d4c7 baseaudiosink: make discont-wait configurable
Now we can configure how much time to wait before deciding that a
discont has happened.

Also, adds getter and setter to allow derived implementations to set
this value upon construction.

Suggestions and several improvements by Havard Graff.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2011-11-07 11:58:46 +01:00
Felipe Contreras
0a111bf26e baseaudiosink: delay the resyncing of timestamp vs ringbuffertime
A common problem for audio-playback is that the timestamps might not
be completely linear. This is specially common when doing streaming over
a network, where you can have jittery and/or bursty packettransmission,
which again will often be reflected on the buffertimestamps.

Now, the current implementation have a threshold that says how far the
buffertimestamp is allowed o drift from the ideal aligned time in the
ringbuffer. This was an instant reaction, and ment that if one buffer
arrived with a timestamp that would breach the drift-tolerance, a resync
would take place, and the result would be an audible gap for the
listener.

The annoying thing would be that in the case of a "timestamp-outlier",
you would first resync one way, say +100ms, and then, if the next
timestamp was "back on track", you would end up resyncing the other way
(-100ms) So in fact, when you had only one buffer with slightly off
timestamping, you would end up with *two* audible gaps. This is the
problem this patch addresses.

The way to "fix" this problem with the previous implementation, would
have been to increase the "drift-tolerance" to a value that was greater
than the largest timestamp-outlier one would normally expect.  The big
problem with this approach, however, is that it will allow normal
operations with a huge offset timestamp vs running-time, which is
detrimental to lip-sync. If the drift-tolerance is set to 200ms, it
basically means that lip-sync can easily end up being off by that much.

This patch will basically start a timer when the first breach of
drift-tolerance is detected. If any following timestamp for the next n
nanoseconds gets "back on track" within the threshold, it has basically
eliminated the effect of an outlier, and the timer is stopped.  If,
however, all timestamps within this time-limit are breaching the
threshold, we are probably facing a more permanent offset in the
timestamps, and a resync is allowed to happen.

So basically this patch offers something as rare as both higher
accuracy, it terms of allowing smaller drift-tolerances, as well as much
smoother, less glitchy playback!

Commit message and improvments by Havard Graff.

Fixes bug #640859.
2011-11-07 11:33:32 +01:00
Felipe Contreras
3f1395afae baseaudiosink: rename some variables 2011-11-07 11:18:34 +01:00
Felipe Contreras
fbde258be6 baseaudiosink: use gst_util_uint64_scale_int when appropriate
It's probably safer this way.
2011-11-07 11:11:08 +01:00
Felipe Contreras
369cf3f14a baseaudiosink: split drift-tolerance into alignment-threshold
So that drift-tolerance is used for clock slaving resync, and
alignment-threshold is for timestamp drift.
2011-11-07 11:10:05 +01:00
Felipe Contreras
58b9818853 baseaudiosink: trivial comment fixes
Some found by Havard Graff.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2011-11-07 10:57:56 +01:00
Tim-Philipp Müller
4e59e63ff7 baseaudiosink: fix unused variable compiler warning if debugging in core is disabled
https://bugzilla.gnome.org/show_bug.cgi?id=660150
2011-10-19 00:32:13 +01:00
Stefan Sauer
264d91a502 baseaudiosink: fix latency calculation for live elements
Max_latency was computed on already adjusted min_latency. Introduce a new
variable for clarity. Spotted by Blaise Gassend.
Fixes #644284
2011-07-28 14:31:47 +02:00
Mark Nauwelaerts
68231a645a baseaudiosink: fix max latency calculation
... to allow infinite max, as also claimed by comment.
2011-07-28 12:05:06 +02:00
Mark Nauwelaerts
5d0f279fea baseaudiosink: drop samples that are too late
... rather than having all of them rendered at 0 or subsequently aligned,
likely inevitably leading to repeated resyncing.
2011-07-28 11:47:52 +02:00
Thijs Vermeir
dad50ad1fe baseaudiosink: recalibrate clock on setcaps
Because the spec for the ringbuffer can change when changing
the caps, we must recalibrate the clock.

https://bugzilla.gnome.org/show_bug.cgi?id=610443
2011-05-23 17:02:03 +02:00
Arun Raghavan
824e643ec9 baseaudiosink: Fix trivial indentation problems 2011-05-14 18:53:12 +05:30
Arun Raghavan
643e5f586c baseaudiosink: Allow subclasses to provide payloaders
This allows subclasses to provide a "payload" function to prepare
buffers for consumption. The immediate use for this is for sinks that
can handle compressed formats - parsers are directly connected to the
sink, and for formats such as AC3, DTS, and MPEG, IEC 61937 patyloading
might be used.

API: GstBaseAudioSinkClass:payload()

https://bugzilla.gnome.org/show_bug.cgi?id=642730
2011-05-14 18:23:18 +05:30
Havard Graff
588ac0ae6f baseaudiosink: don't allow aligning behind the read-segment
Given a large enough drift-tolerance, one could end up in a situation
where one would keep aligning the written buffers behind the current
read-segment position. The result for the reader would be complete
silence, possible preceded by very choppy audio.

By checking the available headroom, one can determine if there is
room to do alignment, or if one should resort to a resync instead to get
the pointers back on track.

Also refactor the alignment-logic out of the render function for cleaner
code.
2011-04-04 09:31:26 +02:00
Mark Nauwelaerts
e73f293ee5 baseaudiosink: arrange for running clock when rendering eos
Commit ba2e500bd9 ensured to provide
a running clock when EOS had finished rendering.  However,
other measures are needed (and were in place before) to ensure a
running clock when EOS still needs rendering (i.e. waiting).

So, specifically, re-introduce eos_rendering removed in aforementioned commit,
this time as a public variable so subclasses can be aware of the situation.

Fixes (part of) #645961.

API: GstBaseAudioSink:eos_rendering
2011-03-31 13:18:53 +02:00
Mark Nauwelaerts
ba2e500bd9 baseaudiosink: start ringbuffer upon going to PLAYING and already EOS
... otherwise we may end up without running clock in PLAYING.

Fixes #636886.
2011-03-04 14:10:30 +01:00
Felipe Contreras
21d1e2ded0 baseaudiosink: trivial cleanups
It seems these stuff was neglected from commmit d8942e2.

Signed-off-by: Felipe Contreras <felipe.contreras@nokia.com>
2011-01-30 15:40:53 +02:00
Tim-Philipp Müller
9c9afee1cf baseaudiosink: default to enable-last-buffer=FALSE for audio sinks
There isn't really any good reason to get the last buffer from an
audio sink, so don't make the sink keep it around unnecessarily.
2011-01-02 17:21:54 +00:00
Havard Graff
60ff7c0eb4 baseaudiosink: protect against ringbuffer disappearing while in a query
Observed a case where the sink went to null-state during the query,
hence the ringbuffer-pointer was NULL, causing a crash.

Moving the ringbuffer-check code until after the query, and hold the
lock during the check and while using the spec-values. It should not matter
to the query wether the ringbuffer is present or not, and it actually
gets a time bit more time to get the ringbuffer set up in this case!

Fixes #635231
2010-12-29 12:29:40 +01:00
Tim-Philipp Müller
751c34bffc audio: make public get_type() functions thread-safe 2010-10-08 11:34:58 +01:00
Tim-Philipp Müller
6b7af81e30 audio: fix enum value name in enums that are public API
So run-time bindings can introspect the names correctly (we abuse this
field as description field only in elements, not for public API
(where the description belongs into the gtk-doc chunk).

https://bugzilla.gnome.org/show_bug.cgi?id=629746
2010-10-08 11:34:58 +01:00
Wim Taymans
84dba3698d baseaudiosink: add Since markers
Fixes #630443
2010-09-24 13:09:28 +02:00
Havard Graff
3067a83df2 baseaudiosink: Added getter and setter for drift tolerance. 2010-09-24 13:06:35 +02:00
Wim Taymans
c89082b2dd baseaudiosink: subtract the render_delay from our latency
The latency reported by the base class includes the render_delay, which we don't
want to include when we start slaving our clocks.

See #630441
2010-09-24 12:54:47 +02:00
Wim Taymans
24226284b8 baseaudio: avoid taking extra ref on sink/src
Don't take an extra ref on the sink and source because that creates a reference
cycle. Instead, use the invalidate method of the clock when the sink and source
are freed. This way, we don't call into the time function anymore after the
objects are disposed.
2010-09-07 18:12:38 +02:00
Sebastian Dröge
b296c96169 baseaudiosink/baseaudiosrc: Post CLOCK-LOST/CLOCK-PROVIDE when going to/from READY
Otherwise the clocks are redistributed every time the pipeline
goes to PAUSED, which is quite expensive.
2010-08-04 15:19:42 +02:00
Sebastian Dröge
ed271ff809 baseaudiosink: Post clock-provide and clock-lost messages when going from/to PLAYING 2010-07-16 17:40:45 +02:00
Sebastian Dröge
f1ac770f1b baseaudiosink: Use new gst_audio_clock_new_full() 2010-07-16 17:40:45 +02:00
Sebastian Dröge
a5c35621c3 Revert "baseaudiosink: Allocate and free the clock in NULL->READY and reverse"
This reverts commit cea2644ed8.

Many audio sink assume that they can create a clock in
the instance init function and it will be there forever
and not be cleared by the state change functions.
2010-06-03 13:44:40 +02:00
Sebastian Dröge
cea2644ed8 baseaudiosink: Allocate and free the clock in NULL->READY and reverse 2010-06-03 10:23:22 +02:00
Mark Nauwelaerts
dcc4b25686 baseaudiosink: arrange for a running ringbuffer/clock for _wait_eos
Fixes #612223.
2010-03-16 15:30:12 +01:00
Tim-Philipp Müller
848a7f2868 baseaudiosink: increase default drift tolerance to fix glitches with WMA
Increase default drift tolerance to 40ms to avoid glitches with decoders
or formats where there's a lot of timestamp jitter for some reason or
another (in this case: asf/wma), at least until we implement timestamp
smoothing.
2009-12-20 23:19:41 +00:00
Wim Taymans
75c5aed1ba audiosink: add adjustement when slaving
Our calibration against the pipeline clock is done with the adjusted
ringbuffer time, so take the adjustement into account. Fixes some audio dropouts
when reusing audio sinks after switching clocks and slaving methods in a
pipeline.
2009-11-25 10:26:16 -06:00
Wim Taymans
0e6b9e596d baseaudiosink: fix initial calibration
When we are calibrating the internal clock against the external clock take into
account the time offset applied to our internal clock because we will subtract
that in the render_function again.
2009-11-18 17:11:03 +01:00
Wim Taymans
d8942e2850 baseaudiosink: make drift tolerance configurable
Add drift-tolerance property (defaulting to 20ms) to handle resync after clock
drift or timestamp drift instead of relying on the latency-time value for clock
drift and 500ms for timestamp drift.
Remove warning about discont timestamp and simply resync. The warning is in some
cases not correct and is triggered more frequently now that we lower the
tolerance value.
2009-11-04 16:16:31 +01:00
Tim-Philipp Müller
6f4c1ac583 Remove GST_DEBUG_FUNCPTR where they're pointless
There's not much point in using GST_DEBUG_FUNCPTR with GObject
virtual functions such as get_property, set_propery, finalize and
dispose, since they'll never be used by anyone anyway. Saves a
few bytes and possibly a sixteenth of a polar bear.
2009-10-28 00:59:35 +00:00
Wim Taymans
35cddfb1e3 baseaudiosink: add ugly backward compat hack
Check for pulsesink < 0.10.17 because it includes code that is now included in
baseaudiosink. Disable that code in baseaudiosink to be compatible with the
older version.
2009-09-10 12:40:01 +02:00
Wim Taymans
06be2b8632 baseaudiosink: take clock time in setcaps
Take the time of the clock so that the last_time field is set. This is important
for sinks that restart their internal ringbuffer after a caps change and need to
know the last know position.
2009-09-09 18:26:03 +02:00
Wim Taymans
fe47c6c4d5 baseaudiosink: correct for clock reset
When going to NULL, we reset the ringbuffer so that it starts beck from 0. We
also make sure that the clock is updated with the elapsed time so that it
alsways increments even when the ringbuffer goes back to 0. When this happened
we need to adjust the sample position for the reset ringbuffer.

Fixes #594136
2009-09-09 16:19:32 +02:00
Wim Taymans
57a13f28de audiosink: free the ringbuffer when going to NULL
Unparent and free the ringbuffer when going to NULL, like we do with the
audiosrc element. We can do this now because we correctly manage the time
jumping back to 0.
2009-06-17 13:18:18 +02:00
Wim Taymans
69b7fb3845 baseaudiosink: reset accum when dropping samples
When we are resampling and we drop samples because we paused, reset the accum
counter because it's now invalid.
2009-06-11 12:38:35 +02:00
Wim Taymans
38e59ec75d baseaudiosink: no need to cause discont when clipping
Remove the discont-when-clipping hack now that basesink provides us with
correctly clipped samples when stepping.
2009-06-09 12:09:15 +02:00
Wim Taymans
cb4952fc2e audiosink: don't align when we clip
Don't align samples when they were clipped. Not entirely correct but better than
nothing for now.
2009-06-08 17:26:59 +02:00
Andy Wingo
c7ca6abe53 add can-activate-pull property to baseaudiosink
* gst-libs/gst/audio/gstbaseaudiosink.c: Add can-activate-pull property
  to baseaudiosink.
2009-05-26 13:17:44 +02:00
Wim Taymans
81170c4989 audiosink: improve debug message 2009-05-21 10:48:49 +02:00
Wim Taymans
c68a361e31 audiosink: return the return value of wait_preroll
Return the value that _wait_preroll() returned instead of always WRONG_STATE.
2009-05-19 17:17:37 +02:00
Andy Wingo
9f74ce745f Revert "add can-activate-pull property to baseaudiosink"
This reverts commit c4074a2ee4.
2009-04-29 11:18:42 +02:00
Andy Wingo
219a31fa3c Revert "[baseaudiosink] add docs for can-activate-pull"
This reverts commit 416ce16f26.
2009-04-29 11:18:33 +02:00