summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Raghavan <arun.raghavan@collabora.co.uk>2012-11-20 12:14:07 +0530
committerArun Raghavan <arun.raghavan@collabora.co.uk>2013-02-23 09:26:19 +0530
commit35f3bea55888315ea477b16cfec19666962f2c70 (patch)
tree27c1dd7aa147f626d27277393e2dde57bb75166f
parent10802cae7339ff1a3e35723159a122088c202933 (diff)
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
-rw-r--r--ext/pulse/pulsesink.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c
index 0827a06fe..1029e974f 100644
--- a/ext/pulse/pulsesink.c
+++ b/ext/pulse/pulsesink.c
@@ -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,