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

[Question] Is there any reason why SND_PCM_STATE_PRIVATE1 enumeration value unhandled? #992

Open
runlevel5 opened this issue May 1, 2024 · 2 comments

Comments

@runlevel5
Copy link
Contributor

/__w/Q2RTX/Q2RTX/extern/openal-soft/alc/backends/alsa.cpp:396:11: warning: enumeration value 'SND_PCM_STATE_PRIVATE1' not handled in switch [-Wswitch]
  396 |     switch(state)
      |           ^

The compiler gives me that warning and so it's seems to me SND_PCM_STATE_PRIVATE1 is not handled. Is it by intention?

@kcat
Copy link
Owner

kcat commented May 2, 2024

As it's name suggests, it's a private state enumeration, that shouldn't be used by callers.

/** Private - used internally in the library - do not use*/
SND_PCM_STATE_PRIVATE1 = 1024

Unfortunately it being placed in the public headers means the compiler can see it as a potential enumeration for snd_pcm_state_t variables, which the compiler expectedly warns about not being handled as a potential value. I'd really consider this a bug in ALSA's headers, making a private thing public that causes errant warnings in valid properly written code. The only ways to avoid it are either to use it, in opposition to the comment, or disable -Wswitch warnings (or add a default case for the same effect), which can hide bugs from unhandled public enum states that may be added in the future (or other changes that could cause an existing state to not be handled as it should be).

@runlevel5
Copy link
Contributor Author

disable -Wswitch warnings

Not a good idea I agree.

either to use it, in opposition to the comment

Perhaps we should handle it and raise an error to let our devs know it is not meant to be used?

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

No branches or pull requests

2 participants