bluetooth: Fix potential assertion failure if MTU changes
authorMikel Astiz <mikel.astiz@bmw-carit.de>
Thu, 24 Jan 2013 09:16:56 +0000 (10:16 +0100)
committerTanu Kaskinen <tanuk@iki.fi>
Thu, 24 Jan 2013 13:55:31 +0000 (15:55 +0200)
The assertion in hsp_process_render() assumes that, if a memory block is
already set by the time the function is reached, its size matches
write_block_size.

This can however fail if a transport has been released and acquired
back, in the unlikely case where the MTU has changed in the meantime,
assuming the memory block wasn't released.

src/modules/bluetooth/module-bluetooth-device.c

index becf716..9e4a8f9 100644 (file)
@@ -332,6 +332,11 @@ static void teardown_stream(struct userdata *u) {
         u->read_smoother = NULL;
     }
 
+    if (u->write_memchunk.memblock) {
+        pa_memblock_unref(u->write_memchunk.memblock);
+        pa_memchunk_reset(&u->write_memchunk);
+    }
+
     pa_log_debug("Audio stream torn down");
 }