a2dp: fix a2dp encoding under sampling rate of 88200, 96000

Signed-off-by: Huang-Huang Bao <eh5@sokka.cn>
This commit is contained in:
Huang-Huang Bao 2020-12-19 20:25:49 +08:00
parent 16f5058af9
commit 9653d748a3
No known key found for this signature in database
GPG key ID: 33C3271387A13D1B

View file

@ -65,6 +65,7 @@ struct impl {
int codesize; int codesize;
int frame_length; int frame_length;
int frame_count; int frame_count;
int frame_count_factor;
}; };
enum { enum {
@ -297,7 +298,7 @@ static int codec_increase_bitpool(void *data)
static int codec_get_num_blocks(void *data) static int codec_get_num_blocks(void *data)
{ {
struct impl *this = data; struct impl *this = data;
return this->frame_count; return this->frame_count * this->frame_count_factor;
} }
static int codec_get_block_size(void *data) static int codec_get_block_size(void *data)
@ -358,10 +359,13 @@ static void *codec_init(const struct a2dp_codec *codec, uint32_t flags,
case LDACBT_SAMPLING_FREQ_044100: case LDACBT_SAMPLING_FREQ_044100:
case LDACBT_SAMPLING_FREQ_048000: case LDACBT_SAMPLING_FREQ_048000:
this->codesize *= 128; this->codesize *= 128;
this->frame_count_factor = 1;
break; break;
case LDACBT_SAMPLING_FREQ_088200: case LDACBT_SAMPLING_FREQ_088200:
case LDACBT_SAMPLING_FREQ_096000: case LDACBT_SAMPLING_FREQ_096000:
this->codesize *= 256; /* ldac ecoder has a constant encoding lsu: LDACBT_ENC_LSU=128 */
this->codesize *= 128;
this->frame_count_factor = 2;
break; break;
default: default:
res = -EINVAL; res = -EINVAL;