pa_sample_spec sample_spec;
gint64 offset;
+ gint64 write_offset;
gboolean corked;
gboolean in_commit;
GST_LOG_OBJECT (psink,
"latency_update, %" G_GUINT64_FORMAT ", %d:%" G_GINT64_FORMAT ", %d:%"
- G_GUINT64_FORMAT ", %" G_GUINT64_FORMAT ", %" G_GUINT64_FORMAT "\n",
+ G_GUINT64_FORMAT ", %" G_GUINT64_FORMAT ", %" G_GUINT64_FORMAT,
GST_TIMEVAL_TO_TIME (info->timestamp), info->write_index_corrupt,
info->write_index, info->read_index_corrupt, info->read_index,
info->sink_usec, info->configured_sink_usec);
else
pbuf->offset = -gst_util_uint64_scale_int (-time_offset,
pbuf->sample_spec.rate, GST_SECOND);
+ pbuf->write_offset = 0;
GST_LOG_OBJECT (psink, "sample offset %" G_GINT64_FORMAT, pbuf->offset);
for (;;) {
gboolean reverse;
gint *toprocess;
gint inr, outr, bps;
- gint64 offset;
+ gint64 offset, diff;
guint bufsize;
pbuf = GST_PULSERING_BUFFER_CAST (buf);
/* offset is in bytes */
offset *= bps;
+ diff = offset - pbuf->write_offset;
+ pbuf->write_offset = offset;
+
while (*toprocess > 0) {
size_t avail;
guint towrite;
if (G_LIKELY (inr == outr && !reverse)) {
/* no rate conversion, simply write out the samples */
- if (pa_stream_write (pbuf->stream, data, towrite, NULL, offset,
- PA_SEEK_ABSOLUTE) < 0)
+ if (pa_stream_write (pbuf->stream, data, towrite, NULL, diff,
+ PA_SEEK_RELATIVE) < 0)
goto write_failed;
data += towrite;
+ diff = 0;
+ pbuf->write_offset += towrite;
in_samples -= avail;
out_samples -= avail;
} else {
/* needed for conditional execution */
pulsesink->pa_version = pa_get_library_version ();
+ GST_DEBUG_OBJECT (pulsesink, "using pulseaudio version %s",
+ pulsesink->pa_version);
+
g_assert ((pulsesink->mainloop = pa_threaded_mainloop_new ()));
g_assert (pa_threaded_mainloop_start (pulsesink->mainloop) == 0);