Re: [PATCH] Re: A2DP quality (bluetooth-alsa)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 27, 2012 at 4:29 AM, qduaty <qduaty@xxxxxxxxx> wrote:
>> 2012/3/26 Siarhei Siamashka <siarhei.siamashka@xxxxxxxxx>:
>>> Floating point code does not need any rounding coefficient.
>
> I'm very likely to agreed that I was wrong with initializing t1
> elements to 1, but seemingly it helps with quality, especially in
> conjunction with accumError. So either I discovered something new, or
> I repeatedly "hear" my changes in C code instead of actual difference.

I think Double Blind listening Test is necessary, otherwise everything
is very subjective:
    http://www.hydrogenaudio.org/forums/index.php?showtopic=16295

> Maybe I should look at sbcdec output.

You could also look at fixing sbc decoder, it still does have some
real audio quality problems :)

> Regarding the bitpool:
>
>>> Do you have a hcidump log before and after patching bluez for the part
>>> where A2DP settings are negotiated?
>
> Actually I just forced bluez to use higher bitpool for SBC than
> negotiated. This is the hcidump after the change, but it does not
> differ from what has been before.
>
>> ACL data: handle 1 flags 0x02 dlen 20
>    L2CAP(d): cid 0x0040 len 16 [psm 25]
>      AVDTP(s): Capabilities rsp: transaction 4 nsp 0x00
>        Media Transport
>        Media Codec - SBC
>          16kHz 32kHz 44.1kHz 48kHz
>          Mono DualChannel Stereo JointStereo
>          4 8 12 16 Blocks
>          4 8 Subbands
>          SNR Loudness
>          Bitpool Range 2-53
>        Content Protection
>          02 00
> < ACL data: handle 1 flags 0x02 dlen 18
>    L2CAP(d): cid 0x0060 len 14 [psm 25]
>      AVDTP(s): Set config cmd: transaction 5 nsp 0x00
>        ACP SEID 1 - INT SEID 1
>        Media Transport
>        Media Codec - SBC
>          44.1kHz
>          Stereo
>          16 Blocks
>          8 Subbands
>          Loudness
>          Bitpool Range 46-46
>
> The headset reports bltpool range of 2-53 and bluez reports 46-46, but
> according to Blueman, it streams at 99 KB/s

This is getting really confusing. If I run blueman, it reports ~40
KB/s for bitpool 53, ~48 KB/s for bitpool 64 and ~36 KB/s for bitpool
46 (if I add 'bitpool "46"' line to my .asoundrc).

> Also, I removed calls to
> default_bitpool(), which is now reported as unused function, and
> increased MAX_BITPOOL everywhere. It does not change anything.

I have attached two test patches.

The first patch adds debug prints to syslog from sbc encoder, just to
clearly confirm the real bitpool used by the encoder. If the encoder
is encoding data with some certain bitpool settings and you hear
something from your headset, then there is no way for the bitpool to
be magically different from that.

The second patch removes default_bitpool() limitation, and this boosts
bitpool from 53 to 64 for me. Confirmed by sbc encoder debug prints
from my first patch, hcidump log and blueman streaming rate
statistics.

> When bitpool is not set in ./asoundrc, Bluez responds with the same
> values it received from the device. There is a difference between
> Bluez and WinMo, which first sends its own capabilities and then asks
> the device (see my previous hcidump). I don't know what BH-503
> answers, but it's possible that it adapts to higher limits of the
> phone and reports higher bitpools than 53, or the phone overrides
> negotiated settings and streams at any bitpool it likes. I tested it
> with bitpools up to 250 and it always worked. Contrary to that, Bluez
> copies the (fake or backward-compatible) value of 53 that was received
> from the device and limits itself instead of reporting its real
> capabilities.

-- 
Best regards,
Siarhei Siamashka
From 94a7494f063b3e22c8e2c3556a021c5315598e86 Mon Sep 17 00:00:00 2001
From: Siarhei Siamashka <siarhei.siamashka@xxxxxxxxx>
Date: Tue, 27 Mar 2012 10:03:00 +0300
Subject: [PATCH 1/2] HACK: report bitpool to syslog from sbc encoder

---
 sbc/sbc.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/sbc/sbc.c b/sbc/sbc.c
index c5015ab..0273035 100644
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -42,6 +42,7 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <limits.h>
+#include <syslog.h>
 
 #include "sbc_math.h"
 #include "sbc_tables.h"
@@ -1060,9 +1061,11 @@ ssize_t sbc_encode(sbc_t *sbc, const void *input, size_t input_len,
 
 		sbc_encoder_init(&priv->enc_state, &priv->frame);
 		priv->init = 1;
+		syslog(LOG_USER | LOG_INFO, "sbc_encode: bitpool set to %d\n", sbc->bitpool);
 	} else if (priv->frame.bitpool != sbc->bitpool) {
 		priv->frame.length = sbc_get_frame_length(sbc);
 		priv->frame.bitpool = sbc->bitpool;
+		syslog(LOG_USER | LOG_INFO, "sbc_encode: bitpool changed to %d\n", sbc->bitpool);
 	}
 
 	/* input must be large enough to encode a complete frame */
-- 
1.7.3.4

From bbd5102a185d8c80b3668864618f34359c2d2139 Mon Sep 17 00:00:00 2001
From: Siarhei Siamashka <siarhei.siamashka@xxxxxxxxx>
Date: Tue, 27 Mar 2012 10:10:27 +0300
Subject: [PATCH 2/2] HACK: remove default_bitpool limitation

---
 audio/a2dp.c          |    3 +--
 audio/pcm_bluetooth.c |    4 +---
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/audio/a2dp.c b/audio/a2dp.c
index 623a0bc..8153819 100644
--- a/audio/a2dp.c
+++ b/audio/a2dp.c
@@ -1839,8 +1839,7 @@ static gboolean select_sbc_params(struct sbc_codec_cap *cap,
 		cap->allocation_method = SBC_ALLOCATION_SNR;
 
 	min_bitpool = MAX(MIN_BITPOOL, supported->min_bitpool);
-	max_bitpool = MIN(default_bitpool(cap->frequency, cap->channel_mode),
-							supported->max_bitpool);
+	max_bitpool = MAX(min_bitpool, supported->max_bitpool);
 
 	cap->min_bitpool = min_bitpool;
 	cap->max_bitpool = max_bitpool;
diff --git a/audio/pcm_bluetooth.c b/audio/pcm_bluetooth.c
index 85566a3..9130e35 100644
--- a/audio/pcm_bluetooth.c
+++ b/audio/pcm_bluetooth.c
@@ -609,9 +609,7 @@ static int bluetooth_a2dp_init(struct bluetooth_data *data,
 		min_bitpool = max_bitpool = cfg->bitpool;
 	else {
 		min_bitpool = MAX(MIN_BITPOOL, cap->min_bitpool);
-		max_bitpool = MIN(default_bitpool(cap->frequency,
-					cap->channel_mode),
-					cap->max_bitpool);
+		max_bitpool = MAX(min_bitpool, cap->max_bitpool);
 	}
 
 	cap->min_bitpool = min_bitpool;
-- 
1.7.3.4


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux