diff options
Diffstat (limited to 'sbc')
-rw-r--r-- | sbc/sbc.c | 6 | ||||
-rw-r--r-- | sbc/sbc.h | 2 | ||||
-rw-r--r-- | sbc/sbcenc.c | 4 |
3 files changed, 7 insertions, 5 deletions
@@ -69,7 +69,7 @@ struct sbc_frame { uint8_t subband_mode; uint8_t subbands; uint8_t bitpool; - uint8_t codesize; + uint16_t codesize; uint8_t length; /* bit number x set means joint stereo has been used in subband x */ @@ -1329,9 +1329,9 @@ int sbc_get_frame_duration(sbc_t *sbc) return (1000000 * blocks * subbands) / frequency; } -int sbc_get_codesize(sbc_t *sbc) +uint16_t sbc_get_codesize(sbc_t *sbc) { - uint8_t subbands, channels, blocks; + uint16_t subbands, channels, blocks; struct sbc_priv *priv; priv = sbc->priv; @@ -87,7 +87,7 @@ 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); -int sbc_get_codesize(sbc_t *sbc); +uint16_t sbc_get_codesize(sbc_t *sbc); void sbc_finish(sbc_t *sbc); #ifdef __cplusplus diff --git a/sbc/sbcenc.c b/sbc/sbcenc.c index 2a8066ec..9cbfb871 100644 --- a/sbc/sbcenc.c +++ b/sbc/sbcenc.c @@ -47,7 +47,7 @@ static ssize_t __read(int fd, void *buf, size_t count) while (count > 0) { len = read(fd, buf + pos, count); if (len <= 0) - return len; + return pos > len ? pos : len; count -= len; pos += len; @@ -188,6 +188,8 @@ static void encode(char *filename, int subbands, int bitpool, int joint, len = sbc_encode(&sbc, input, size, output, sizeof(output), &encoded); + if (len <= 0) + break; if (len < size) memmove(input, input + len, size - len); |