-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
modules: Add zephyr lc3 codec #44225
modules: Add zephyr lc3 codec #44225
Conversation
The following west manifest projects have been modified in this Pull Request:
Note: This message is automatically posted and updated by the Manifest GitHub Action. |
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.
A couple of minor comments
const uint8_t bad_frame_indicator = buf->len == 0 ? 1 : 0; | ||
uint8_t *in_buf = (bad_frame_indicator ? NULL : buf->data); |
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.
Hmm, apparently we discard the const struct bt_iso_recv_info *info
in BAP, so you won't ever get that information directly. Maybe we'll need to fix that.
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.
Yes that would be ideal - also if controllers would actually issue ISO data packets over HCI when they detect a failure to receive :-) (I have only seen one controller that does that.)
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.
The fact that they can, should be enough reason that they should :) For something like audio, that information is of significant worth.
samples/bluetooth/unicast_audio_client/boards/native_posix.conf
Outdated
Show resolved
Hide resolved
e065031
to
008b791
Compare
samples/bluetooth/unicast_audio_client/boards/nrf5340dk_nrf5340_cpuapp.conf
Outdated
Show resolved
Hide resolved
samples/bluetooth/unicast_audio_client/boards/nrf5340dk_nrf5340_cpuapp.conf
Outdated
Show resolved
Hide resolved
modules/liblc3codec/Kconfig
Outdated
config LIBLC3CODEC | ||
bool "liblc3codec Support" | ||
help | ||
This option enables the Android liblc3codec library for Bluetooth LE Audio |
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.
Should this by default enably e.g. CONFIG_FPU?
Should we add a warning if CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE
is too low, given the high stack usage of this module?
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.
CONFIG_FPU
is not strictly required if you have a fast CPU and can do it in SW. I'll add it - at least that forces people to think about if they want to disable it.
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE
- Good point - do you have an example on how to do that?
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.
Added select FPU in the LC3 module Kconfig.
Which stack to run the LC3 codec on is up to the application. I added a comment stating that a large stack is needed.
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.
If it is not a strict requirement then I suggest to use default y if FPU
or imply FPU
as those are less restrictive than depends on
or select
.
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.
Changed to select FPU
after all, but thanks for your inputs - I did not know the imply
keyword.
I figured that by imply
you allow it to be enabled on any system, but typically systems without a FPU run at 100MHz and below - hence most likely it will not work. On systems with FPU it would most likely work (if the CPU speed is high enough), but I'm sure there are systems out there that do not run 64MHz+, hence I would like not to enable it by default as that would also mean that we need to decide which c-lib people should use.
Would this compromise work for you?
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.
Did you consider depends on
?
That is usually recommended instead of select
, and I guess also more semantically correct.
Personally I think depends on
works better here than select
if we want to keep it as a requirement, but also that imply
is better than select
here, as it not a strict requirement.
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 did consider depends on
, but that hides the option until you actually set FPU in menuconfig so even though it might be preferred by some, I don't like it. For example FPU is not enabled by default in the nRF5340, hence you would spend ages browsing through the configuration system before you realize you need to enable FPU to show the LC3 option - which is not obvious. IMO depends on
is only meant to be used for adding additional configuration options to a config - like if you enable serial port support you get additional options related to serial port.
If there is a general Zephyr guideline that select
should not be used I'll change it of cause, but select
is nice and simple in this case - as a user it is clear to see that if I enable the feature I also get the features it depends on - hence to me select
works as depends on
should work in this case. I do not know if there are different tools for doing the configuration and some of those actually implements depends on
as select
+ a warning to the user that the depends on
features will also be enabled.
I used select
over imply
as I'm not sure anyone will want to spend time debugging why the system takes 10 times the expected execution time, and if they really want to run on a fixed point system they can make the required change to enforce it.
I can agree to change to imply
if you think the risk of people debugging slow systems makes up the benefit of being able to enable the feature on non-FPU systems without making the required modifications to kconfig.
If optimizations are made in the future that allows the codec to run acceptable on fixed point systems, I fully support changing it :-)
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.
If there is a general Zephyr guideline that select should not be used I'll change it of cause, but select is nice and simple in this case
We have https://docs.zephyrproject.org/latest/guides/build/kconfig/tips.html#alternatives-to-select
I am aware of the issue with the hiding configs when using Kconfig, and this is a divisive issue among Zephyr developers as depends on
is clearly preferred by everyone who doesn't use menuconfig (like myself), and vice versa for those who do.
I used select over imply as I'm not sure anyone will want to spend time debugging why the system takes 10 times the expected execution time, and if they really want to run on a fixed point system they can make the required change to enforce it.
If the system does not have FPU enabled, then a warning will appear during build, which should state that FPU=n
IIRC.
I am OK with select
or imply
here
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.
As I read the guide it favors Zephyr developers over Zephyr users - hence favoring code maintenance over ease of use.
If you are not using menuconfig to browse through possible config options, what do you use? (I know that when you get familiar with the zephyr code-base you know where to find the relevant kconfig files, but what would you use if you were a user of Zephyr and wanted to write an application and do initial configuration of the system - enable the features you need).
I guess I need to follow the Zephyr guide-line - will change to depends on
. Will do this when updating the west.yml after the module PR is merged as that will trigger a new review anyway.
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.
If you are not using menuconfig to browse through possible config options, what do you use?
I generally browser the Kconfig files and/or source code :) A quick search gives me a result of a total of more than 11000 Kconfig options; browsing that many option in a GUI to me seems nearly impossible, and generally searching for them as text works much faster for me.
If you use VSCode there are also extensions to help with Kconfigs: https://marketplace.visualstudio.com/items?itemName=trond-snekvik.kconfig-lang
I guess I need to follow the Zephyr guide-line - will change to depends on.
It is only a guideline and not a requirement of course, and as mentioned this is typically a personal preference depending on what tools you use :)
4fc4abc
to
5bd9e44
Compare
@carlescufi you might want to have a quick look at the LC3 module commit: |
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.
Integration commit looks fine to me.
Initial addition of the LC3 codec as a module. Usage of the module will be seperate commits. Even though this codec is a generic audio codec, it is tagged with Bluetooth: as it can only be used for LE-Audio. Using the codec for other purposes is a violation of the granted rights for the codec. Signed-off-by: Casper Bonde <casper_bonde@bose.com>
LC3 codec integration into BAP Unicast client and server sample applications. Will be enabled by default for a native_posix and nrf5430 cpuapp builds. The client will continuously transmit a LC3 encoded 400Hz sine wave and the client will receive and decode the data. Implementation verified using UART based HCI controller with ISO interface (userchan.c modified to open the UART directly as bluez do not have support for ISO data) as well as on-target execution on the nrf5340. Signed-off-by: Casper Bonde <casper_bonde@bose.com> Co-authored-by: Emil Gydesen <Thalley@users.noreply.github.com>
99c561f
5bd9e44
to
99c561f
Compare
@carlescufi I updated the reference in west.yml - could you please re-approve if you are happy with it? (834e446) |
Sample code demonstrating how the LC3 codec can be used for encoding and decoding audio data.
This is a simple integration into the existing BAP unicast application that uses a generated sine wave as audio data, encodes it and transfers it over a CIS. The receiver decodes the data and discards it after checking for errors.
Fixes #41228
This replaces #42443 using the new c-version of the LC3 codec