linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: "Frédéric Dalleau" <frederic.dalleau@linux.intel.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 2/5] Add support for mSBC frame header
Date: Fri, 28 Sep 2012 16:45:11 +0200	[thread overview]
Message-ID: <1348843511.13371.29.camel@aeonflux> (raw)
In-Reply-To: <1348757068-31048-3-git-send-email-frederic.dalleau@linux.intel.com>

Hi Fred,

> mSBC modifies header so that it contains: OxAD 0x00 0x00.
> The first bytes allows to distinguish mSBC packets from standard SBC
> packets used in A2DP. The two zero bytes are reserved for future definition.
> ---
>  sbc/sbc.c |  104 +++++++++++++++++++++++++++++++++++++------------------------
>  1 file changed, 63 insertions(+), 41 deletions(-)
> 
> diff --git a/sbc/sbc.c b/sbc/sbc.c
> index 7e4faa0..131755b 100644
> --- a/sbc/sbc.c
> +++ b/sbc/sbc.c
> @@ -407,55 +407,71 @@ static int sbc_unpack_frame(sbc_t *sbc, const uint8_t *data,
>  	if (len < 4)
>  		return -1;
>  
> -	if (data[0] != SBC_SYNCWORD)
> -		return -2;
> -
> -	frame->frequency = (data[1] >> 6) & 0x03;
> +	if (sbc->flags & SBC_MSBC) {
> +		if (data[0] != MSBC_SYNCWORD)
> +			return -2;
> +		if (data[1] != 0)
> +			return -5;
> +		if (data[2] != 0)
> +			return -6;

I am getting the felling that just splitting this into separate
unpack_sbc_frame and unpack_msbc_frame would make this a lot cleaner
instead of keeping to check if mSBC flag or not is set.

We might even include a function callback in sbc_t where we on sbc_init
just select one or the other. No need to keep repeating that check for
every single frame. As far as I can tell, you never can switch from SBC
to mSBC or vice-versa anyway.

With that you also would not need to change the function prototype to
include sbc_t at all.

Regards

Marcel



  reply	other threads:[~2012-09-28 14:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-27 14:44 [PATCH 0/5] mSBC tests Frédéric Dalleau
2012-09-27 14:44 ` [PATCH 1/5] Add msbc encoding and decoding flag Frédéric Dalleau
2012-09-28 14:53   ` Marcel Holtmann
2012-09-27 14:44 ` [PATCH 2/5] Add support for mSBC frame header Frédéric Dalleau
2012-09-28 14:45   ` Marcel Holtmann [this message]
2012-09-27 14:44 ` [PATCH 3/5] update sbcdec for msbc Frédéric Dalleau
2012-09-27 14:44 ` [PATCH 4/5] update sbcenc " Frédéric Dalleau
2012-09-27 14:44 ` [PATCH 5/5] update sbcinfo " Frédéric Dalleau
2012-09-27 20:34 ` [PATCH 0/5] mSBC tests Siarhei Siamashka
2012-09-28  8:21   ` Dalleau, Frederic
2012-09-28 15:05   ` Marcel Holtmann
2012-10-30  2:18     ` Siarhei Siamashka

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=1348843511.13371.29.camel@aeonflux \
    --to=marcel@holtmann.org \
    --cc=frederic.dalleau@linux.intel.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;
as well as URLs for NNTP newsgroup(s).