Summary
Add AudioSession with functions like get_vol() and set_vol(vol: u8) to set the volume of an application or other running audio sessions.
Target crate(s)
volumecontrol-core, volumecontrol (wrapper), volumecontrol-linux, volumecontrol-windows, volumecontrol-macos
Platform scope
All platforms
Motivation & use case
It is very usefull to not only change the output volume of the devices but to change the output volume of each audio session.
Proposed API or behavior
There should be a AudioSession trait similar to AudioDevice with which a user can control the current audio sessions.
How it could look like:
Change volume of every current session to 50%:
use volumecontrol::{AudioSession, SessionInfo, AudioError};
let session_infos: Result<Vec<SessionInfo>, AudioError> = AudioSession::list();
for session_info in sessions.unwrap().into_inter() {
let session: AudioSession = AudioSession::from_id(&session_info.id).unwrap();
session.set_vol(50).unwrap();
println!("Volume of '{}' is now set to {}%.", session.name(), session.get_vol().unwrap());
}
Example output:
Volume of 'Discord.exe' is now set to 50%.
Volume of 'chrome.exe' is now set to 50%.
Volume of 'Spotify.exe' is now set to 50%.
On linux the session name could look different (without .exe at the end).
Acceptance criteria
Implementation hints
These is everything I could find to this topic:
- WASAPI:
IAudioSessionManager2, IAudioSessionEnumerator and IAudioSessionControl2 interfaces.
- PulseAudio:
Sink Input 's are App Audio Streams (the audio sessions). pa_context_get_sink_input_info_list, pa_context_get_sink_input_info, pa_context_set_sink_input_volume, pa_context_set_sink_input_mute and (PA_SUBSCRIPTION_MASK_SINK_INPUT) could be needed functions
Breaking change?
Yes — new trait method (requires major version bump)
Alternatives considered
No response
Summary
Add
AudioSessionwith functions likeget_vol()andset_vol(vol: u8)to set the volume of an application or other running audio sessions.Target crate(s)
volumecontrol-core, volumecontrol (wrapper), volumecontrol-linux, volumecontrol-windows, volumecontrol-macos
Platform scope
All platforms
Motivation & use case
It is very usefull to not only change the output volume of the devices but to change the output volume of each audio session.
Proposed API or behavior
There should be a
AudioSessiontrait similar toAudioDevicewith which a user can control the current audio sessions.How it could look like:
Change volume of every current session to 50%:
Example output:
On linux the session name could look different (without
.exeat the end).Acceptance criteria
SessionInfoadded.AudioSessionwith all required methods added.Implementation hints
These is everything I could find to this topic:
IAudioSessionManager2,IAudioSessionEnumeratorandIAudioSessionControl2interfaces.Sink Input's are App Audio Streams (the audio sessions).pa_context_get_sink_input_info_list,pa_context_get_sink_input_info,pa_context_set_sink_input_volume,pa_context_set_sink_input_muteand (PA_SUBSCRIPTION_MASK_SINK_INPUT) could be needed functionsBreaking change?
Yes — new trait method (requires major version bump)
Alternatives considered
No response