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

Set conditional default backend #1158

Merged
merged 4 commits into from
Feb 2, 2023

Conversation

fxsalazar
Copy link
Contributor

No description provided.

@eladyn
Copy link
Member

eladyn commented Jan 7, 2023

Thank you! This is something I wanted to do for quite some time now.

While this solution is already much better than what has been there before, maybe we could go for an even "smarter" default backend selection logic. I'm thinking of something like this:

const fn default_backend() -> Backend {
  #[cfg(all(feature = "portaudio_backend", target_os="macos")]
  return Backend::Portaudio;
  #[cfg(feature = "alsa_backend")]
  return Bacend::Alsa;
  #[cfg(feature = "portaudio_backend")]
  return Backend::Portaudio;

  todo!("other backends");
  
  #[cfg(not(any(feature = "pulseaudio_backend", feature = "portaudio_backend", ...)))]
  compile_error!("Please enable at least one backend!");
}

This would prevent things like this:

The application panicked (crashed).
Message:  Unknown backend: alsa.
Location: src/setup.rs:169

Although this code is only a rough sketch and quite verbose / ugly.

If you don't want to look into this further, that would be fine as well, and we can just merge this version! :)

@fxsalazar
Copy link
Contributor Author

Yes, sure, I'll take a look to this approach.

@fxsalazar
Copy link
Contributor Author

fxsalazar commented Jan 22, 2023

I decided to go with the BACKEND_VALUES which is already aggregating the features values. 🤔 does it make sense?

Copy link
Member

@eladyn eladyn left a comment

Choose a reason for hiding this comment

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

Oh, right. That seems like a good idea! Apart from a small comment, LGTM!

src/config.rs Outdated Show resolved Hide resolved
@fxsalazar fxsalazar requested a review from eladyn January 22, 2023 22:59
Copy link
Member

@eladyn eladyn left a comment

Choose a reason for hiding this comment

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

Thank you!

@eladyn eladyn requested a review from a team January 22, 2023 23:06
@slondr
Copy link
Member

slondr commented Feb 2, 2023

cool!

@slondr slondr merged commit 0c4f6f9 into Spotifyd:master Feb 2, 2023
@fxsalazar fxsalazar deleted the conditional_backend_default branch February 2, 2023 00:53
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

Successfully merging this pull request may close these issues.

3 participants