summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-08-21 21:32:09 +0000
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-08-21 21:32:09 +0000
commitb1618922db92f9bc65b0841f66eb71742bc1b553 (patch)
tree401dbbda10d88248b2dfd3c9961363f7f6b121d4
parent38c5be0cc3029bf78445be15470d18343a5b4dae (diff)
Add swap member to sbc struct and fix pcm plugin to not swap the buffer.
-rw-r--r--audio/pcm_bluetooth.c13
-rw-r--r--sbc/sbc.c18
-rw-r--r--sbc/sbc.h1
-rw-r--r--sbc/sbcdec.c1
-rw-r--r--sbc/sbcenc.c1
5 files changed, 19 insertions, 15 deletions
diff --git a/audio/pcm_bluetooth.c b/audio/pcm_bluetooth.c
index 80afd562..495f1521 100644
--- a/audio/pcm_bluetooth.c
+++ b/audio/pcm_bluetooth.c
@@ -109,16 +109,6 @@ struct bluetooth_data {
struct bluetooth_a2dp a2dp; /* A2DP data */
};
-static void memcpy_changeendian(void *dst, const void *src, int size)
-{
- int i;
- const uint16_t *ptrsrc = src;
- uint16_t *ptrdst = dst;
-
- for (i = 0; i < size / 2; i++)
- *ptrdst++ = htons(*ptrsrc++);
-}
-
static int bluetooth_start(snd_pcm_ioplug_t *io)
{
DBG("bluetooth_start %p", io);
@@ -622,8 +612,7 @@ static snd_pcm_sframes_t bluetooth_a2dp_write(snd_pcm_ioplug_t *io,
/* Ready for more data */
buff = (uint8_t *) areas->addr +
(areas->first + areas->step * offset) / 8;
- memcpy_changeendian(data->buffer + data->count, buff,
- frame_size * frames_to_read);
+ memcpy(data->buffer + data->count, buff, frame_size * frames_to_read);
/* Remember we have some frames in the pipe now */
data->count += frames_to_read * frame_size;
diff --git a/sbc/sbc.c b/sbc/sbc.c
index d485a5fd..d27c1e9a 100644
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -1289,6 +1289,7 @@ int sbc_init(sbc_t *sbc, unsigned long flags)
sbc->subbands = 8;
sbc->blocks = 16;
sbc->bitpool = 32;
+ sbc->swap = 0;
return 0;
}
@@ -1341,8 +1342,14 @@ int sbc_decode(sbc_t *sbc, void *data, int count)
for (ch = 0; ch < priv->frame.channels; ch++) {
int16_t s;
s = priv->frame.pcm_sample[ch][i];
- *ptr++ = (s & 0xff00) >> 8;
- *ptr++ = (s & 0x00ff);
+
+ if (sbc->swap) {
+ *ptr++ = (s & 0xff00) >> 8;
+ *ptr++ = (s & 0x00ff);
+ } else {
+ *ptr++ = (s & 0x00ff);
+ *ptr++ = (s & 0xff00) >> 8;
+ }
}
}
@@ -1387,7 +1394,12 @@ int sbc_encode(sbc_t *sbc, void *data, int count)
for (i = 0; i < priv->frame.subbands * priv->frame.blocks; i++) {
for (ch = 0; ch < sbc->channels; ch++) {
- int16_t s = (ptr[0] & 0xff) << 8 | (ptr[1] & 0xff);
+ int16_t s;
+
+ if (sbc->swap)
+ s = (ptr[0] & 0xff) << 8 | (ptr[1] & 0xff);
+ else
+ s = (ptr[0] & 0xff) | (ptr[1] & 0xff) << 8;
ptr += 2;
priv->frame.pcm_sample[ch][i] = s;
}
diff --git a/sbc/sbc.h b/sbc/sbc.h
index 70881c12..11d9740d 100644
--- a/sbc/sbc.h
+++ b/sbc/sbc.h
@@ -40,6 +40,7 @@ struct sbc_struct {
int blocks;
int subbands;
int bitpool;
+ int swap;
void *data;
int size;
diff --git a/sbc/sbcdec.c b/sbc/sbcdec.c
index b5305550..d84a631b 100644
--- a/sbc/sbcdec.c
+++ b/sbc/sbcdec.c
@@ -90,6 +90,7 @@ static void decode(char *filename, char *audiodevice, int tofile)
}
sbc_init(&sbc, 0L);
+ sbc.swap = 1;
framelen = sbc_decode(&sbc, stream, streamlen);
printf("%d Hz, %d channels\n", sbc.rate, sbc.channels);
diff --git a/sbc/sbcenc.c b/sbc/sbcenc.c
index 8919fb92..2334f8d3 100644
--- a/sbc/sbcenc.c
+++ b/sbc/sbcenc.c
@@ -144,6 +144,7 @@ static void encode(char *filename, int subbands, int joint)
sbc.channels = BE_INT(au_hdr->channels);
sbc.subbands = subbands;
sbc.joint = joint;
+ sbc.swap = 1;
count = BE_INT(au_hdr->data_size);
size = len - BE_INT(au_hdr->hdr_size);
memmove(buf, buf + BE_INT(au_hdr->hdr_size), size);