Cannot decode mSBC with Realtek USB adapter
borine opened this issue · 1 comments
msbc decoding with Realtek USB devices is still broken. The decoder logic cannot work if the SCO socket message size ("mtu" in the code) is larger than the esco msbc frame size (60 bytes). For Realtek USB devices the message size is 72 bytes for msbc.
The problem is that the decoder loop decodes a maximum of 1 codec frame (60 bytes) per iteration, but reads exactly 72 bytes per iteration. Thus the data buffer quickly fills until there is no longer space to read 72 bytes, and a short read results. From that point on the audio stream is broken; we get stuttering audio and a constant flood of "Missing msbc packets" debug messages.
This patch enables successful msbc decoding in my tests:
diff --git a/src/sco.c b/src/sco.c
index 857a28e..229e148 100644
--- a/src/sco.c
+++ b/src/sco.c
@@ -481,7 +481,11 @@ static void *sco_msbc_dec_thread(struct ba_transport_thread *th) {
ffb_seek(&msbc.data, len);
int err;
- if ((err = msbc_decode(&msbc)) < 0) {
+ do {
+ err = msbc_decode(&msbc);
+ } while (err > 0);
+
+ if (err < 0) {
error("mSBC decoding error: %s", sbc_strerror(err));
continue;
}
git log -1 --oneline
4d1fac8 (HEAD -> master, origin/master, origin/HEAD) Show BUS name and BT device address in hcitop
Many thanks for the patch!