return 0;
}
-int sbc_parse(sbc_t *sbc, void *input, int input_len)
+ssize_t sbc_parse(sbc_t *sbc, const void *input, size_t input_len)
{
return sbc_decode(sbc, input, input_len, NULL, 0, NULL);
}
-int sbc_decode(sbc_t *sbc, void *input, int input_len, void *output,
- int output_len, int *written)
+ssize_t sbc_decode(sbc_t *sbc,
+ const void *input, size_t input_len,
+ void *output, size_t output_len,
+ size_t *written)
{
struct sbc_priv *priv;
char *ptr;
ptr = output;
- if (output_len < samples * priv->frame.channels * 2)
+ if (output_len < (size_t) (samples * priv->frame.channels * 2))
samples = output_len / (priv->frame.channels * 2);
for (i = 0; i < samples; i++) {
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;
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;
uint8_t subbands, channels, blocks, joint, bitpool;
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;
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;
#endif
#include <stdint.h>
+#include <sys/types.h>
/* sampling frequency */
#define SBC_FREQ_16000 0x00
int sbc_init(sbc_t *sbc, unsigned long flags);
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);
+
+ssize_t sbc_parse(sbc_t *sbc, const void *input, size_t input_len);
+
+/* Decodes ONE input block into ONE output block */
+ssize_t sbc_decode(sbc_t *sbc,
+ const void *input, size_t input_len,
+ void *output, size_t output_len,
+ size_t *written);
+
+/* 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);
unsigned char buf[BUF_SIZE], *stream;
struct stat st;
sbc_t sbc;
- int fd, ad, pos, streamlen, framelen, count, len;
+ int fd, ad, pos, streamlen, framelen, count;
+ size_t len;
int format = AFMT_S16_BE, frequency, channels;
ssize_t written;
if (count + len >= BUF_SIZE) {
fprintf(stderr,
"buffer size of %d is too small for decoded"
- " data (%d)\n", BUF_SIZE, len + count);
+ " data (%lu)\n", BUF_SIZE, (unsigned long) (len + count));
exit(1);
}
{
struct au_header au_hdr;
sbc_t sbc;
- int fd, size, encoded, srate, codesize, nframes;
+ int fd, size, srate, codesize, nframes;
+ size_t encoded;
ssize_t len;
if (sizeof(au_hdr) != 24) {
&encoded);
if (len != codesize || encoded <= 0) {
fprintf(stderr,
- "sbc_encode fail, len=%zd, encoded=%d\n",
- len, encoded);
+ "sbc_encode fail, len=%zd, encoded=%lu\n",
+ len, (unsigned long) encoded);
break;
}
size -= len;