Skip to content
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

Add vela alsa lib interface #2970

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

yangyalei
Copy link

@yangyalei yangyalei commented Jan 23, 2025

Summary

Add vela alsa lib interface

Impact

Introducing ALSA compatible audio subsystem on NuttX.

Testing

Use alsa lib interface play music in allwinnertech&BES platform

@nuttxpr
Copy link

nuttxpr commented Jan 23, 2025

[Experimental Bot, please feedback here]

No, this PR does not fully meet the NuttX requirements. While it provides a summary and mentions testing, it lacks crucial details. Here's a breakdown of what's missing:

  • Summary: While it states "Add vela alsa lib interface," it doesn't explain why this change is necessary. Is it a new feature? Does it fix a bug? What part of the code is affected? How does the "vela alsa lib interface" work and what changes does it introduce? Any related NuttX issues should also be linked.
  • Impact: Simply stating "nop" is insufficient. Each impact item needs to be addressed explicitly with "NO" or "YES," and if "YES," a description is required. Even if there's no impact, stating "NO" for each item clarifies that these aspects were considered.
  • Testing: The testing description is vague. It mentions playing music on specific platforms, but doesn't provide details about the build host or the specific boards/configurations used. Critically, it's missing the "before" and "after" testing logs, which are essential for demonstrating the change's effect. What constitutes "works as intended"? What specific tests were run?

To meet the requirements, the PR needs to be revised to include the missing information. For example, the impact section should look like this (even if there's no impact):

* Is new feature added? YES (Adds the vela alsa lib interface)
* Impact on user (will user need to adapt to change)? NO
* Impact on build (will build process change)? NO
* Impact on hardware (will arch(s) / board(s) / driver(s) change)? YES (Affects Allwinnertech and BES platforms - please specify which boards and how)
* Impact on documentation (is update required / provided)? YES (Documentation should be added explaining the vela alsa lib interface and how to use it)
* Impact on security (any sort of implications)? NO
* Impact on compatibility (backward/forward/interoperability)? NO
* Anything else to consider? NO

The testing section needs actual logs and specific build/target details.

@yangyalei
Copy link
Author

This PR is related to apache/nuttx#15657

FAR struct bitsconv_data *bc;
FAR struct bitsconv_data *bc_s16;
FAR struct chmap_data *cm;
FAR SpeexResamplerState *resampler;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comes from ALSA and needs to stay that way @yangyalei ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comes from ALSA and needs to stay that way @yangyalei ?

This is just a simple way to support format convert and resampling... This is not the standard implementation of ALSA; it's just a basic implementation.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our format check complains here because of mixed case.. but I guess this name is enforced by some standard API and we should not change that to maintain compatibility? :-)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our format check complains here because of mixed case.. but I guess this name is enforced by some standard API and we should not change that to maintain compatibility? :-)

I used libspeexdsp (BSD license, tested performance is quite good) for resampling, but the interface definitions of libspeexdsp follow camel case naming convention. I have discussed this with @xiaoxiang781216, it's OK.

@cederom
Copy link

cederom commented Jan 23, 2025

Thank you @yangyalei amazing work!! :-)


config AUDIOUTILS_SPEEXDSP
bool "Audio libspeexdsp Library"
default n
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depends on ALLOW_BSD_COMPONENTS

Copy link
Member

@raiden00pl raiden00pl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the license of this code? is it somehow based on alsa-lib ? Is it GPL?

If this code is GPL then it can't be merged. GPL licensed code cannot be hosted in ASF projects.

@xiaoxiang781216
Copy link
Contributor

xiaoxiang781216 commented Jan 23, 2025

what is the license of this code? is it somehow based on alsa-lib ? Is it GPL?

If this code is GPL then it can't be merged. GPL licensed code cannot be hosted in ASF projects.

it's rewrite from scratch, but follow alsa-lib public API, just like nuttx v4l2 driver framework:
https://github.com/apache/nuttx/blob/master/include/sys/videoio.h
The implementation is totally different from https://git.alsa-project.org/?p=alsa-lib.git;a=tree.

@jerpelea
Copy link
Contributor

what is the license of this code? is it somehow based on alsa-lib ? Is it GPL?
If this code is GPL then it can't be merged. GPL licensed code cannot be hosted in ASF projects.

it's rewrite from scratch, but follow alsa-lib public API, just like nuttx v4l2 driver framework: https://github.com/apache/nuttx/blob/master/include/sys/videoio.h The implementation is totally different from https://git.alsa-project.org/?p=alsa-lib.git;a=tree.

I will run a scan after merge

Comment on lines +95 to +96
const int16_t *src;
int32_t *dst;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FAR

Comment on lines +108 to +109
src = (const int16_t *)in_data;
dst = (int32_t *)bc->bitsconv_buf;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FAR

Comment on lines +121 to +122
int32_t *src;
int16_t *dst;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FAR

Comment on lines +134 to +135
src = (int32_t *)in_data;
dst = (int16_t *)bc->bitsconv_buf;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FAR

Comment on lines +93 to +94
in = (const int16_t *)in_data;
out = (int16_t *)cm->chmap_buf;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FAR

Comment on lines +146 to +147
in = (const int32_t *)in_data;
out = (int32_t *)cm->chmap_buf;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FAR

* Public Functions
****************************************************************************/

const char *snd_pcm_name(snd_pcm_t *pcm)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FAR and in other places

return NULL;
}

const char *_snd_pcm_format_descriptions[] =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in order to maintain compatibility?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt that compatibility is a sufficient reason not to name this implementation as "derivative GPL work".
Even internal static functions are called the same like in alsa-lib.

@raiden00pl
Copy link
Member

raiden00pl commented Jan 23, 2025

I'm definitely not licences expert so I don't know if licensing this code to Apache is OK or not.

But for sure caution is required here. GPL is like virus.
Where does "interface inspiration" ends and "derivative work" begin? I see a lot of identical fragments here as in https://github.com/alsa-project/alsa-lib/tree/master/src not only in headers, so I would wounder if we aren't dealing here with "derivative GPL work".

@raiden00pl
Copy link
Member

raiden00pl commented Jan 23, 2025

it's rewrite from scratch, but follow alsa-lib public API, just like nuttx v4l2 driver framework:

If this is rewriten based on alsa-lib then this is a derivative work. If this is a derivative work of GPL, then this code is GPL. If this code is GPL then it can't be relicensed to Apache.

That's how I understand copyleft licences. I would be happy if there is someone more competent than me and says otherwise.

@cederom
Copy link

cederom commented Jan 24, 2025

maybe we should ask ALSA project directly to have no doubts?

if the interface is compatible but its a rewrite from scratch then should be no problem? how otherwise create alternatives?

@raiden00pl
Copy link
Member

The code structure is very similar to alsa-lib, some code fragments are the same, many private functions has the same names. This is not just a compatible interface, but highly inspired on alsa-lib work. Asking the alsa-lib team won't change anything here if it's a derivative work of GPL. I doubt they relicence it to permisive license, I doubt if its even possible.

If you want to avoid such problems you have to write EVERYTHING from scratch, the only thing you can take from GPL project are PUBLIC header interfaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants