bluez5: Init BAP LC3 coder/decoder depending on direction

For LE Audio, sink and source have their own media transport endpoint.
Media sink or source only needs the coder or decoder respectively.
This commit is contained in:
Frédéric Danis 2022-08-12 15:35:22 +02:00 committed by Wim Taymans
parent 28b4fbecfb
commit d4b639419a
3 changed files with 28 additions and 12 deletions

View file

@ -586,17 +586,21 @@ static void *codec_init(const struct media_codec *codec, uint32_t flags,
}
this->codesize = this->samples * this->channels * sizeof(int32_t);
for (ich = 0; ich < this->channels; ich++) {
this->enc[ich] = lc3_setup_encoder(this->frame_dus, this->samplerate, 0, calloc(1, lc3_encoder_size(this->frame_dus, this->samplerate)));
if (this->enc[ich] == NULL) {
res = -EINVAL;
goto error;
if (flags & MEDIA_CODEC_FLAG_SINK) {
for (ich = 0; ich < this->channels; ich++) {
this->enc[ich] = lc3_setup_encoder(this->frame_dus, this->samplerate, 0, calloc(1, lc3_encoder_size(this->frame_dus, this->samplerate)));
if (this->enc[ich] == NULL) {
res = -EINVAL;
goto error;
}
}
this->dec[ich] = lc3_setup_decoder(this->frame_dus, this->samplerate, 0, calloc(1, lc3_decoder_size(this->frame_dus, this->samplerate)));
if (this->dec[ich] == NULL) {
res = -EINVAL;
goto error;
} else {
for (ich = 0; ich < this->channels; ich++) {
this->dec[ich] = lc3_setup_decoder(this->frame_dus, this->samplerate, 0, calloc(1, lc3_decoder_size(this->frame_dus, this->samplerate)));
if (this->dec[ich] == NULL) {
res = -EINVAL;
goto error;
}
}
}