pulsesink: Fix playback if PA doesn't give us a large enough shared memory buffer

This commit is contained in:
Sebastian Dröge 2010-06-09 15:42:37 +02:00
parent f22c7d0f7c
commit b78a27beb2

View file

@ -1345,15 +1345,16 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
} }
} }
avail = out_samples; if (pbuf->m_writable < towrite)
towrite = pbuf->m_writable;
avail = towrite / bps;
GST_LOG_OBJECT (psink, "writing %u samples at offset %" G_GUINT64_FORMAT, GST_LOG_OBJECT (psink, "writing %u samples at offset %" G_GUINT64_FORMAT,
(guint) avail, offset); (guint) avail, offset);
if (G_LIKELY (inr == outr && !reverse)) { if (G_LIKELY (inr == outr && !reverse)) {
/* no rate conversion, simply write out the samples */ /* no rate conversion, simply write out the samples */
/* copy the data into internal buffer */ /* copy the data into internal buffer */
assert (pbuf->m_writable >= towrite);
memcpy ((guint8 *) pbuf->m_data + pbuf->m_towrite, data, towrite); memcpy ((guint8 *) pbuf->m_data + pbuf->m_towrite, data, towrite);
pbuf->m_towrite += towrite; pbuf->m_towrite += towrite;