diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-03-23 16:44:11 +0100 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-04-17 01:45:19 +0200 |
commit | c43f8bdcc1d527e2d77481a66217771038be3acd (patch) | |
tree | c3f684c6e594b86a68071ea00194d6c1a8724a02 /sbc | |
parent | 999d9b9ac1f8e7d25f620661b99ae6068560c3f1 (diff) |
fix up sbc.h prototypes to use const/size_t wherever applicable
Diffstat (limited to 'sbc')
-rw-r--r-- | sbc/sbc.c | 22 | ||||
-rw-r--r-- | sbc/sbc.h | 33 | ||||
-rw-r--r-- | sbc/sbcdec.c | 5 | ||||
-rw-r--r-- | sbc/sbcenc.c | 7 |
4 files changed, 45 insertions, 22 deletions
@@ -973,13 +973,15 @@ int sbc_init(sbc_t *sbc, unsigned long flags) 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; @@ -1020,7 +1022,7 @@ int sbc_decode(sbc_t *sbc, void *input, int input_len, void *output, 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++) { @@ -1044,8 +1046,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,7 +1137,7 @@ 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; uint8_t subbands, channels, blocks, joint, bitpool; @@ -1159,7 +1163,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; @@ -1197,7 +1201,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; @@ -31,6 +31,7 @@ extern "C" { #endif #include <stdint.h> +#include <sys/types.h> /* sampling frequency */ #define SBC_FREQ_16000 0x00 @@ -81,14 +82,30 @@ typedef struct sbc_struct sbc_t; 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); diff --git a/sbc/sbcdec.c b/sbc/sbcdec.c index 497379000..9e87d63a2 100644 --- a/sbc/sbcdec.c +++ b/sbc/sbcdec.c @@ -48,7 +48,8 @@ static void decode(char *filename, char *output, int tofile) 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; @@ -185,7 +186,7 @@ static void decode(char *filename, char *output, int tofile) 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); } diff --git a/sbc/sbcenc.c b/sbc/sbcenc.c index 8dad062f2..0e3b6fb7d 100644 --- a/sbc/sbcenc.c +++ b/sbc/sbcenc.c @@ -48,7 +48,8 @@ static void encode(char *filename, int subbands, int bitpool, int joint, { 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) { @@ -171,8 +172,8 @@ static void encode(char *filename, int subbands, int bitpool, int joint, &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; |