From: Arun Raghavan Date: Tue, 20 Nov 2012 06:44:07 +0000 (+0530) Subject: pulsesink: Update segdone periodically X-Git-Tag: 1.1.1~318 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=35f3bea55888315ea477b16cfec19666962f2c70;p=platform%2Fupstream%2Fgst-plugins-good.git 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 --- diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c index 0827a06..1029e97 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,