summaryrefslogtreecommitdiff
path: root/src/pulse/stream.h
diff options
context:
space:
mode:
authorTanu Kaskinen <tanuk@iki.fi>2012-11-07 16:52:37 +0200
committerDavid Henningsson <david.henningsson@canonical.com>2012-11-08 15:38:32 +0100
commitdfd44036b54d65314664622ff93dfd18eee03c7b (patch)
treebdb875ea796d5f21588603175cd3950a5cf1ae4f /src/pulse/stream.h
parent38c650dca96aff9240ddeb5528206ba43bb58187 (diff)
pulse: Fix hole handling in pa_stream_peek().
Previously, if there was a hole in a recording stream, pa_stream_peek() would crash. Holes could be handled silently inside pa_stream_peek() by generating silence (wouldn't work for compressed streams, though) or by skipping any holes. However, I think it's better to let the caller decide how the holes should be handled, so in case of holes, pa_stream_peek() will return NULL data pointer and the length of the hole in the nbytes argument. This change is technically an interface break, because previously the documentation didn't mention the possibility of holes that need special handling. However, since holes caused crashing anyway in the past, it's not a regression if applications keep misbehaving due to not handing holes properly. Some words about when holes can appear in recording streams: I think it would be reasonable behavior if overruns due to the application reading data too slowly would cause holes. Currently that's not the case - overruns will just cause audio to be skipped. But the point is that this might change some day. I'm not sure how holes can occur with the current code, but as the linked bug shows, they can happen. It's most likely due to recording from a monitor source where the thing being monitored has holes in its playback stream. BugLink: http://bugs.launchpad.net/bugs/1058200
Diffstat (limited to 'src/pulse/stream.h')
-rw-r--r--src/pulse/stream.h20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/pulse/stream.h b/src/pulse/stream.h
index b4464fadd..a6785ec19 100644
--- a/src/pulse/stream.h
+++ b/src/pulse/stream.h
@@ -534,11 +534,21 @@ int pa_stream_write(
pa_seek_mode_t seek /**< Seek mode, must be PA_SEEK_RELATIVE for upload streams */);
/** Read the next fragment from the buffer (for recording streams).
- * \a data will point to the actual data and \a nbytes will contain the size
- * of the data in bytes (which can be less or more than a complete
- * fragment). Use pa_stream_drop() to actually remove the data from
- * the buffer. If no data is available this will return a NULL
- * pointer. */
+ * If there is data at the current read index, \a data will point to
+ * the actual data and \a nbytes will contain the size of the data in
+ * bytes (which can be less or more than a complete fragment).
+ *
+ * If there is no data at the current read index, it means that either
+ * the buffer is empty or it contains a hole (that is, the write index
+ * is ahead of the read index but there's no data where the read index
+ * points at). If the buffer is empty, \a data will be NULL and
+ * \a nbytes will be 0. If there is a hole, \a data will be NULL and
+ * \a nbytes will contain the length of the hole.
+ *
+ * Use pa_stream_drop() to actually remove the data from the buffer
+ * and move the read index forward. pa_stream_drop() should not be
+ * called if the buffer is empty, but it should be called if there is
+ * a hole. */
int pa_stream_peek(
pa_stream *p /**< The stream to use */,
const void **data /**< Pointer to pointer that will point to data */,