]> code.delx.au - pulseaudio/commitdiff
simple: Handle holes in recording streams.
authorTanu Kaskinen <tanuk@iki.fi>
Wed, 7 Nov 2012 14:52:38 +0000 (16:52 +0200)
committerTanu Kaskinen <tanuk@iki.fi>
Mon, 4 Feb 2013 10:07:33 +0000 (12:07 +0200)
src/pulse/simple.c

index 3524296a7af84ceb323babe008c14af388d2446e..860cd185d63839a212098ec3ce15d4a2beedcfdf 100644 (file)
@@ -331,9 +331,14 @@ int pa_simple_read(pa_simple *p, void*data, size_t length, int *rerror) {
             r = pa_stream_peek(p->stream, &p->read_data, &p->read_length);
             CHECK_SUCCESS_GOTO(p, rerror, r == 0, unlock_and_fail);
 
-            if (!p->read_data) {
+            if (p->read_length <= 0) {
                 pa_threaded_mainloop_wait(p->mainloop);
                 CHECK_DEAD_GOTO(p, rerror, unlock_and_fail);
+            } else if (!p->read_data) {
+                /* There's a hole in the stream, skip it. We could generate
+                 * silence, but that wouldn't work for compressed streams. */
+                r = pa_stream_drop(p->stream);
+                CHECK_SUCCESS_GOTO(p, rerror, r == 0, unlock_and_fail);
             } else
                 p->read_index = 0;
         }