mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-26 13:44:23 +08:00
Fixed correct handling of frame sizes in the encoder
This commit is contained in:
parent
365f92ed45
commit
2cada66773
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user