summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-03-19 17:44:42 +0100
committerLennart Poettering <lennart@poettering.net>2009-03-19 17:44:42 +0100
commit291d21c4bab6970b70b08cc301c5287b4a11b20e (patch)
treeb37589bc97c850fe9277accd1d5dbdf9ee8f3cc8
parent794775bb51eac04546bc905f789bbe613fd23bfa (diff)
fix prototypes of sbc functions a bit
-rw-r--r--src/modules/bluetooth/module-bluetooth-device.c13
-rw-r--r--src/modules/bluetooth/sbc.c14
-rw-r--r--src/modules/bluetooth/sbc.h22
3 files changed, 32 insertions, 17 deletions
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 80c12567..2ae6e111 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -949,7 +949,7 @@ static int a2dp_process_render(struct userdata *u) {
void *d;
const void *p;
unsigned frame_count;
- int written;
+ size_t written;
uint64_t writing_at;
pa_assert(u);
@@ -975,14 +975,14 @@ static int a2dp_process_render(struct userdata *u) {
writing_at = u->write_index;
do {
- int encoded;
+ ssize_t encoded;
if (!u->write_memchunk.memblock)
pa_sink_render_full(u->sink, u->block_size, &u->write_memchunk);
p = (const uint8_t*) pa_memblock_acquire(u->write_memchunk.memblock) + u->write_memchunk.index;
encoded = sbc_encode(&a2dp->sbc,
- (void*) p, u->write_memchunk.length,
+ p, u->write_memchunk.length,
d, left,
&written);
@@ -997,10 +997,11 @@ static int a2dp_process_render(struct userdata *u) {
return -1;
}
- pa_assert(written >= 0);
-
pa_assert((size_t) encoded <= u->write_memchunk.length);
+ pa_assert((size_t) encoded == sbc_get_codesize(&a2dp->sbc));
+
pa_assert((size_t) written <= left);
+ pa_assert((size_t) written == sbc_get_frame_length(&a2dp->sbc));
/* pa_log_debug("SBC: encoded: %d; written: %d", encoded, written); */
@@ -1019,7 +1020,7 @@ static int a2dp_process_render(struct userdata *u) {
frame_count++;
- } while ((uint8_t*) d - (uint8_t*) a2dp->buffer + written < (ptrdiff_t) u->link_mtu);
+ } while (((uint8_t*) d - ((uint8_t*) a2dp->buffer + sbc_get_frame_length(&a2dp->sbc))) < (ptrdiff_t) u->link_mtu);
/* write it to the fifo */
memset(a2dp->buffer, 0, sizeof(*header) + sizeof(*payload));
diff --git a/src/modules/bluetooth/sbc.c b/src/modules/bluetooth/sbc.c
index a33ed571..6fa54796 100644
--- a/src/modules/bluetooth/sbc.c
+++ b/src/modules/bluetooth/sbc.c
@@ -1044,8 +1044,10 @@ int sbc_decode(sbc_t *sbc, void *input, int input_len, void *output,
return framelen;
}
-int sbc_encode(sbc_t *sbc, void *input, int input_len, void *output,
- int output_len, int *written)
+ssize_t sbc_encode(sbc_t *sbc,
+ const void *input, size_t input_len,
+ void *output, size_t output_len,
+ size_t *written)
{
struct sbc_priv *priv;
int framelen, samples;
@@ -1133,9 +1135,9 @@ void sbc_finish(sbc_t *sbc)
memset(sbc, 0, sizeof(sbc_t));
}
-int sbc_get_frame_length(sbc_t *sbc)
+size_t sbc_get_frame_length(sbc_t *sbc)
{
- int ret;
+ size_t ret;
uint8_t subbands, channels, blocks, joint;
struct sbc_priv *priv;
@@ -1164,7 +1166,7 @@ int sbc_get_frame_length(sbc_t *sbc)
return ret;
}
-int sbc_get_frame_duration(sbc_t *sbc)
+unsigned sbc_get_frame_duration(sbc_t *sbc)
{
uint8_t subbands, blocks;
uint16_t frequency;
@@ -1202,7 +1204,7 @@ int sbc_get_frame_duration(sbc_t *sbc)
return (1000000 * blocks * subbands) / frequency;
}
-uint16_t sbc_get_codesize(sbc_t *sbc)
+size_t sbc_get_codesize(sbc_t *sbc)
{
uint16_t subbands, channels, blocks;
struct sbc_priv *priv;
diff --git a/src/modules/bluetooth/sbc.h b/src/modules/bluetooth/sbc.h
index f9d506bc..25a12885 100644
--- a/src/modules/bluetooth/sbc.h
+++ b/src/modules/bluetooth/sbc.h
@@ -31,6 +31,7 @@ extern "C" {
#endif
#include <stdint.h>
+#include <sys/types.h>
/* sampling frequency */
#define SBC_FREQ_16000 0x00
@@ -84,11 +85,22 @@ int sbc_reinit(sbc_t *sbc, unsigned long flags);
int sbc_parse(sbc_t *sbc, void *input, int input_len);
int sbc_decode(sbc_t *sbc, void *input, int input_len, void *output,
int output_len, int *len);
-int sbc_encode(sbc_t *sbc, void *input, int input_len, void *output,
- int output_len, int *written);
-int sbc_get_frame_length(sbc_t *sbc);
-int sbc_get_frame_duration(sbc_t *sbc);
-uint16_t sbc_get_codesize(sbc_t *sbc);
+
+/* Encodes ONE input block into ONE output block */
+ssize_t sbc_encode(sbc_t *sbc,
+ const void *input, size_t input_len,
+ void *output, size_t output_len,
+ size_t *written);
+
+/* Returns the output block size in bytes */
+size_t sbc_get_frame_length(sbc_t *sbc);
+
+/* Returns the time one input/output block takes to play in msec*/
+unsigned sbc_get_frame_duration(sbc_t *sbc);
+
+/* Returns the input block size in bytes */
+size_t sbc_get_codesize(sbc_t *sbc);
+
const char *sbc_get_implementation_info(sbc_t *sbc);
void sbc_finish(sbc_t *sbc);