interaudiosink: fix leak when not connected
authorDavid Schleef <ds@schleef.org>
Tue, 2 Apr 2013 03:03:59 +0000 (20:03 -0700)
committerDavid Schleef <ds@schleef.org>
Tue, 9 Apr 2013 22:36:17 +0000 (15:36 -0700)
gst/inter/gstinteraudiosink.c

index 108c7a8..1c6e56d 100644 (file)
@@ -235,9 +235,10 @@ gst_inter_audio_sink_render (GstBaseSink * sink, GstBuffer * buffer)
   n = gst_adapter_available (interaudiosink->surface->audio_adapter) / 4;
 #define SIZE 1600
   if (n > (SIZE * 3)) {
-    GST_WARNING ("flushing 800 samples");
-    gst_adapter_flush (interaudiosink->surface->audio_adapter, (SIZE / 2) * 4);
-    n -= (SIZE / 2);
+    int n_chunks = (n / (SIZE / 2)) - 4;
+    GST_WARNING ("flushing %d samples", n_chunks * 800);
+    gst_adapter_flush (interaudiosink->surface->audio_adapter,
+        n_chunks * (SIZE / 2) * 4);
   }
   gst_adapter_push (interaudiosink->surface->audio_adapter,
       gst_buffer_ref (buffer));