-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LE Audio: BAP shell LC3 decode #68920
LE Audio: BAP shell LC3 decode #68920
Conversation
39b9785
to
fa5a15a
Compare
738579a
to
5eda773
Compare
ac3006d
to
2413adc
Compare
1920196
to
61d868a
Compare
b1f4980
to
5e32f4c
Compare
subsys/bluetooth/audio/shell/bap.c
Outdated
shell_print(ctx_shell, | ||
"Initializing the LC3 decoder with %u us duration and %u Hz frequency", | ||
sh_stream->lc3_frame_duration_us, sh_stream->lc3_freq_hz); | ||
/* Create the encoder instance. This shall complete before stream_started() is called. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* Create the encoder instance. This shall complete before stream_started() is called. */ | |
/* Create the decoder instance. This shall complete before stream_started() is called. */ |
subsys/bluetooth/audio/shell/bap.c
Outdated
sh_stream->lc3_freq_hz, 0, /* No resampling */ | ||
&sh_stream->lc3_decoder_mem); | ||
if (sh_stream->lc3_decoder == NULL) { | ||
shell_error(ctx_shell, "Failed to setup LC3 encoder - wrong parameters?\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shell_error(ctx_shell, "Failed to setup LC3 encoder - wrong parameters?\n"); | |
shell_error(ctx_shell, "Failed to setup LC3 decoder - wrong parameters?\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops - Too much copy-paste :)
5e32f4c
to
47dab1c
Compare
|
||
if ((sh_stream->decoded_cnt % recv_stats_interval) == 0) { | ||
shell_print(ctx_shell, "[%zu]: Performing PLC", sh_stream->decoded_cnt); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when data == NULL, should we continue to execute lc3_decode() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NULL will perform PLC
sh_stream->lc3_frame_duration_us, sh_stream->lc3_freq_hz); | ||
/* Create the decoder instance. This shall complete before stream_started() is called. */ | ||
sh_stream->lc3_decoder = lc3_setup_decoder(sh_stream->lc3_frame_duration_us, | ||
sh_stream->lc3_freq_hz, 0, /* No resampling */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if the bap shell intended for non-USB device?
if not only for non-USB device, the sameple rate should not always 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR does not touch USB, but only does decoding. My followup PRs add proper resampling for USB
|
||
#if defined(CONFIG_BT_BAP_BROADCAST_SINK) | ||
struct shell_stream *sh_stream = shell_stream_from_bap_stream(stream); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about sh_stream == NULL ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shell_stream_from_bap_stream
cannot return NULL, as it always returns an address.
subsys/bluetooth/audio/shell/bap.c
Outdated
|
||
if (default_broadcast_sink.stream_cnt == 0) { | ||
/* All streams in the broadcast sink has been terminated */ | ||
default_broadcast_sink.syncable = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to set default_broadcast_sink.syncable = true ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that doesn't make any sense, especially since we are setting it to false
just below.
Must have been a bad merge conflict resolution or something :o
47dab1c
to
e8de570
Compare
subsys/bluetooth/audio/shell/bap.c
Outdated
break; | ||
} | ||
|
||
frame_cnt += ret; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may have a code error, the frame_cnt should not add itself, because the ret = frame_cnt + chan_cnt.
subsys/bluetooth/audio/shell/bap.c
Outdated
for (uint8_t i = 0U; i < frame_blocks_per_sdu; i++) { | ||
const int ret = decode_frame_block(buf, sh_stream, frame_cnt); | ||
|
||
if (ret < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"ret" never have a chance could less than 0.
e8de570
to
842e220
Compare
subsys/bluetooth/audio/shell/bap.c
Outdated
frame_cnt++; | ||
} | ||
|
||
return frame_cnt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should return how many channnel decode success in one frame block, rather than the total frame_cnt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, good catch
Add support for decoding incoming LC3 data. At this point we only instantiate a single LC3 decoder, so only one frequency and duration is supported. To accomodate for the increased RAM usage, the number of unicast streams support have been decreased. Further more, the LC3 handling in the shell has overall been improved, also for encoding. Signed-off-by: Emil Gydesen <[email protected]>
842e220
to
2d51bce
Compare
Fixes #53527