-
Notifications
You must be signed in to change notification settings - Fork 187
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 support for ALSA softvol plugin #158
Conversation
Needed to support the ALSA softvol plugin.
Needed to add support for the ALSA softvol plugin as a mixer.
22e54f9
to
f926ea7
Compare
This seem to break cross compilation. It fails with:
I think you should be able to solve this by making sure pkg-config is properly configured in the docker files. Environment variables like |
@Fulkerson I am cross-compiling for a custom ARMv5 target and it works:
I do not use docker... |
Thanks for the PR ! I'm quite busy this week, so I probably won't be reviewing it until this weekend.
See RustAudio/cpal#152 and http://doc.crates.io/build-script.html#overriding-build-scripts @joerg-krause I can take care of adding that if you don't want to mess around with the Dockerfile |
This PR seems to support any ALSA mixer not just softvol. The mixer should just be named |
@plietar I've added support for the ALSA softvol plugin to shairport-sync some time ago: mikebrady/shairport-sync#293. There was already ALSA hardware mixer support implemented, but the ALSA functions to use for handling the dB volume range are different between software and hardware mixer. I will check, if I have a board with a hardware mixer interface to test with. |
Hmm, I'm not very familiar with alsa but my understanding is it should not matter what mixer is configured by the user in the |
Is there a reason for not caching the mixer and selem instances, so you don't have to create a new Mixer instance for each volume get/set? It would be also nice to be able to specify a separate alsa mixer device. This is need for things like room correction where librespot outputs to alsa loopback which then sends samples to the real output device, but volume control must work with the real output. |
The reason is my limited knowledge about Rust. If I move the mixer and selem instances to
This can be done using the |
@joerg-krause |
Instead of passing additional options to the mixers which not all mixers need wouldn't it make sense to add a config file? Either one specifically for your mixer or even one for the whole application where you could add a section for each "component". I'm working on an external mixer, which might need different options. |
Config file for what exactly? Shairport has this handled properly for alsa: you can specify separate mixer device, which defaults to the output device if not set. I'm suggesting to do the same for librespot alsa backend. |
|
||
let volume: i64 = selem.get_playback_volume(alsa::mixer::SelemChannelId::FrontLeft).unwrap(); | ||
|
||
volume as u16 * 256 |
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 factor 256 is only valid for ALSA mixers having a resolution of 256: 0xFFFF / resolution(256) = 256. If the resolution of the mixer is for example 128, the factor needs to be: 0xFFFF / resolution(128) = 512.
Closed in favor of #160. |
Add support for the ALSA softvol plugin as a mixer. The ALSA softvol plugin allows librespot to control the master volume.
Therefore, switch to the alsa crate from diwic, as this crate already implements the mixer interface, and port the alsa backend to this crate.
The ALSA softvol plugin needs to audio device name. Therefoe, enhance the mixer interface by passing the device name to the mixer instance. The device name is ignored by the softmixer.
Finally, get the initial volume setting from the mixer. This way, the spotify player uses the last volume instead of setting it always to 100%.