mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 20:51:13 +00:00
audio: correctly handle short read/writes
This commit is contained in:
parent
2c5f455423
commit
e4492c24ea
2 changed files with 7 additions and 5 deletions
|
@ -229,11 +229,11 @@ audioringbuffer_thread_func (GstRingBuffer * buf)
|
|||
|
||||
/* buffer must be started */
|
||||
if (gst_ring_buffer_prepare_read (buf, &readseg, &readptr, &len)) {
|
||||
gint written = 0;
|
||||
gint written;
|
||||
|
||||
left = len;
|
||||
do {
|
||||
written = writefunc (sink, readptr + written, left);
|
||||
written = writefunc (sink, readptr, left);
|
||||
GST_LOG_OBJECT (sink, "transfered %d bytes of %d from segment %d",
|
||||
written, left, readseg);
|
||||
if (written < 0 || written > left) {
|
||||
|
@ -245,6 +245,7 @@ audioringbuffer_thread_func (GstRingBuffer * buf)
|
|||
break;
|
||||
}
|
||||
left -= written;
|
||||
readptr += written;
|
||||
} while (left > 0);
|
||||
|
||||
/* clear written samples */
|
||||
|
|
|
@ -215,20 +215,21 @@ audioringbuffer_thread_func (GstRingBuffer * buf)
|
|||
gint readseg;
|
||||
|
||||
if (gst_ring_buffer_prepare_read (buf, &readseg, &readptr, &len)) {
|
||||
gint read = 0;
|
||||
gint read;
|
||||
|
||||
left = len;
|
||||
do {
|
||||
read = readfunc (src, readptr + read, left);
|
||||
read = readfunc (src, readptr, left);
|
||||
GST_LOG_OBJECT (src, "transfered %d bytes of %d to segment %d", read,
|
||||
left, readseg);
|
||||
if (read < 0 || read > left) {
|
||||
GST_WARNING_OBJECT (src,
|
||||
"error reading data (reason: %s), skipping segment",
|
||||
"error reading data %d (reason: %s), skipping segment", read,
|
||||
g_strerror (errno));
|
||||
break;
|
||||
}
|
||||
left -= read;
|
||||
readptr += read;
|
||||
} while (left > 0);
|
||||
|
||||
/* we read one segment */
|
||||
|
|
Loading…
Reference in a new issue