summaryrefslogtreecommitdiffstats
path: root/src/modules/bluetooth
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz-von@nokia.com>2010-12-23 13:13:28 +0200
committerLuiz Augusto von Dentz <luiz.dentz-von@nokia.com>2010-12-23 13:16:43 +0200
commite4979ab5cff84ef64c88bba3a1b6b4c5e02f7777 (patch)
tree41a71dde48f5b64213550248b391666248f741b1 /src/modules/bluetooth
parent96338eec28ce9af97965a177eeecd6daebd208f5 (diff)
bluetooth: detect when bitpool has changed on sbc codec
A2DP spec allow bitpool changes midstream which is why sbc configuration has a range of values for bitpool that the encoder can use and decoder must support. Bitpool changes do not affect the state of encoder/decoder so they don't need to be reinitialize when this happens, so the impact is fairly small, what it does change is the frame length so encoders may change the bitpool to use the link more efficiently.
Diffstat (limited to 'src/modules/bluetooth')
-rw-r--r--src/modules/bluetooth/sbc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/modules/bluetooth/sbc.c b/src/modules/bluetooth/sbc.c
index 779be4bd..5157c70f 100644
--- a/src/modules/bluetooth/sbc.c
+++ b/src/modules/bluetooth/sbc.c
@@ -1005,7 +1005,8 @@ ssize_t sbc_decode(sbc_t *sbc, const void *input, size_t input_len,
priv->frame.codesize = sbc_get_codesize(sbc);
priv->frame.length = framelen;
- }
+ } else if (priv->frame.bitpool != sbc->bitpool)
+ sbc->bitpool = priv->frame.bitpool;
if (!output)
return framelen;
@@ -1076,6 +1077,9 @@ 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;
+ } else if (priv->frame.bitpool != sbc->bitpool) {
+ priv->frame.length = sbc_get_frame_length(sbc);
+ priv->frame.bitpool = sbc->bitpool;
}
/* input must be large enough to encode a complete frame */
@@ -1140,7 +1144,7 @@ size_t sbc_get_frame_length(sbc_t *sbc)
struct sbc_priv *priv;
priv = sbc->priv;
- if (priv->init)
+ if (priv->init && priv->frame.bitpool == sbc->bitpool)
return priv->frame.length;
subbands = sbc->subbands ? 8 : 4;