pulsesink: Update segdone periodically

This makes sure that we update segdone based on the read index received
during latency updates. As the comment notes, we make some compromises
to deal with the fact that segdone is a segment multiple, while the read
index offers finer granularity. The updates are also not very often
(100ms since that is how often automatic timing updates are provided).

All this is required for the baseaudiosink sample alignment code to work
at all.

https://bugzilla.gnome.org/show_bug.cgi?id=694257
This commit is contained in:
Arun Raghavan 2012-11-20 12:14:07 +05:30
parent 10802cae73
commit 35f3bea558

View file

@ -657,6 +657,7 @@ gst_pulsering_stream_latency_cb (pa_stream * s, void *userdata)
{
GstPulseSink *psink;
GstPulseRingBuffer *pbuf;
GstAudioRingBuffer *ringbuf;
const pa_timing_info *info;
pa_usec_t sink_usec;
@ -664,11 +665,26 @@ gst_pulsering_stream_latency_cb (pa_stream * s, void *userdata)
pbuf = GST_PULSERING_BUFFER_CAST (userdata);
psink = GST_PULSESINK_CAST (GST_OBJECT_PARENT (pbuf));
ringbuf = GST_AUDIO_RING_BUFFER (pbuf);
if (!info) {
GST_LOG_OBJECT (psink, "latency update (information unknown)");
return;
}
if (!info->read_index_corrupt) {
/* Update segdone based on the read index. segdone is of segment
* granularity, while the read index is at byte granularity. We take the
* ceiling while converting the latter to the former since it is more
* conservative to report that we've read more than we have than to report
* less. One concern here is that latency updates happen every 100ms, which
* means segdone is not updated very often, but increasing the update
* frequency would mean more communication overhead. */
g_atomic_int_set (&ringbuf->segdone,
(int) gst_util_uint64_scale_ceil (info->read_index, 1,
ringbuf->spec.segsize));
}
sink_usec = info->configured_sink_usec;
GST_LOG_OBJECT (psink,