From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH] sbc: detect when bitpool has changed
Date: Tue, 21 Dec 2010 18:58:44 +0200 [thread overview]
Message-ID: <1292950724-4918-1-git-send-email-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
---
sbc/sbc.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/sbc/sbc.c b/sbc/sbc.c
index a6391ae..b3a7a09 100644
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -965,7 +965,8 @@ ssize_t sbc_decode(sbc_t *sbc, const void *input, size_t input_len,
framelen = sbc_unpack_frame(input, &priv->frame, input_len);
- if (!priv->init) {
+ /* init if no previous frame was encode or bitpool has changed */
+ if (!priv->init || priv->frame.bitpool != sbc->bitpool) {
sbc_decoder_init(&priv->dec_state, &priv->frame);
priv->init = 1;
@@ -1035,7 +1036,8 @@ ssize_t sbc_encode(sbc_t *sbc, const void *input, size_t input_len,
if (written)
*written = 0;
- if (!priv->init) {
+ /* init if no previous frame was encode or bitpool has changed */
+ if (!priv->init || priv->frame.bitpool != sbc->bitpool) {
priv->frame.frequency = sbc->frequency;
priv->frame.mode = sbc->mode;
priv->frame.channels = sbc->mode == SBC_MODE_MONO ? 1 : 2;
@@ -1120,7 +1122,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;
--
1.7.1
next reply other threads:[~2010-12-21 16:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-21 16:58 Luiz Augusto von Dentz [this message]
2010-12-21 18:02 ` [PATCH] sbc: detect when bitpool has changed Brian Gix
2010-12-22 9:05 ` Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1292950724-4918-1-git-send-email-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox