]> code.delx.au - pulseaudio/commitdiff
bluetooth: Don't abort on SBC decoding error
authorJames Bunton <jamesbunton@delx.net.au>
Sun, 26 Jan 2014 14:14:38 +0000 (01:14 +1100)
committerTanu Kaskinen <tanuk@iki.fi>
Mon, 3 Mar 2014 16:06:21 +0000 (18:06 +0200)
The Nokia E7 running Symbian Belle Refresh seems to generate invalid SBC
packets every few minutes. This causes pulseaudio to disconnect the
stream and log "SBC decoding error (-3)".

If a single packet is bad, pulseaudio should keep playing the stream.

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

index 83e603fcbe834f2d842fd4f5a4a98400ecd1673c..90b1bcd2b0a7ee99d024878668c0ae158fe4845e 100644 (file)
@@ -937,7 +937,7 @@ static int a2dp_process_push(struct userdata *u) {
                 pa_log_error("SBC decoding error (%li)", (long) decoded);
                 pa_memblock_release(memchunk.memblock);
                 pa_memblock_unref(memchunk.memblock);
-                return -1;
+                return 0;
             }
 
 /*             pa_log_debug("SBC: decoded: %lu; written: %lu", (unsigned long) decoded, (unsigned long) written); */
@@ -1039,10 +1039,12 @@ static void thread_func(void *userdata) {
                 if (n_read < 0)
                     goto io_fail;
 
-                /* We just read something, so we are supposed to write something, too */
-                pending_read_bytes += n_read;
-                do_write += pending_read_bytes / u->write_block_size;
-                pending_read_bytes = pending_read_bytes % u->write_block_size;
+                if (n_read > 0) {
+                    /* We just read something, so we are supposed to write something, too */
+                    pending_read_bytes += n_read;
+                    do_write += pending_read_bytes / u->write_block_size;
+                    pending_read_bytes = pending_read_bytes % u->write_block_size;
+                }
             }
         }
 
index 287e763979ec2321b23e735c527c322ca78d57b5..61723f86586448fa2ff33245203fa713623f379c 100644 (file)
@@ -458,7 +458,7 @@ static int a2dp_process_push(struct userdata *u) {
                 pa_log_error("SBC decoding error (%li)", (long) decoded);
                 pa_memblock_release(memchunk.memblock);
                 pa_memblock_unref(memchunk.memblock);
-                return -1;
+                return 0;
             }
 
             /* Reset frame length, it can be changed due to bitpool change */
@@ -1095,10 +1095,12 @@ static void thread_func(void *userdata) {
                 if (n_read < 0)
                     goto io_fail;
 
-                /* We just read something, so we are supposed to write something, too */
-                pending_read_bytes += n_read;
-                do_write += pending_read_bytes / u->write_block_size;
-                pending_read_bytes = pending_read_bytes % u->write_block_size;
+                if (n_read > 0) {
+                    /* We just read something, so we are supposed to write something, too */
+                    pending_read_bytes += n_read;
+                    do_write += pending_read_bytes / u->write_block_size;
+                    pending_read_bytes = pending_read_bytes % u->write_block_size;
+                }
             }
         }