File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 1- use color_eyre:: eyre:: { self , Context , eyre} ;
1+ use alsa:: device_name:: HintIter ;
2+ use color_eyre:: {
3+ Section ,
4+ eyre:: { self , Context , eyre} ,
5+ } ;
26use librespot_playback:: mixer:: { Mixer , MixerConfig } ;
37use log:: error;
48use std:: sync:: { Arc , Mutex , MutexGuard } ;
59
10+ pub fn get_available_controls ( ) -> alsa:: Result < HintIter > {
11+ alsa:: device_name:: HintIter :: new_str ( None , "ctl" )
12+ }
13+
614pub struct AlsaMixer {
715 pub mixer : Arc < Mutex < alsa:: Mixer > > ,
816 pub config : MixerConfig ,
@@ -20,6 +28,25 @@ impl AlsaMixer {
2028 self . config. control,
2129 self . config. device,
2230 )
31+ . with_suggestion ( || {
32+ format ! (
33+ "maybe try one of the following for 'control':{}" ,
34+ lock. iter( )
35+ . filter_map( |elem| {
36+ let selem = alsa:: mixer:: Selem :: new( elem) ?;
37+ if selem. has_playback_volume( ) {
38+ selem
39+ . get_id( )
40+ . get_name( )
41+ . ok( )
42+ . map( |name| format!( "\n - {name}" ) )
43+ } else {
44+ None
45+ }
46+ } )
47+ . collect:: <String >( )
48+ )
49+ } )
2350 } ) ?;
2451 Ok ( selem)
2552 }
Original file line number Diff line number Diff line change @@ -53,6 +53,13 @@ pub(crate) fn initial_state(
5353 control,
5454 index : 0 ,
5555 volume_ctrl,
56+ } ) . with_suggestion ( || {
57+ match alsa_mixer:: get_available_controls ( ) {
58+ Err ( err) => format ! ( "there are no controls available, maybe check that alsa is available: {err}" ) ,
59+ Ok ( controls) => {
60+ format ! ( "maybe try one of the following as 'mixer':{}" , controls. filter_map( |hint| hint. name. map( |name| format!( "\n - {name}" ) ) ) . collect:: <String >( ) )
61+ }
62+ }
5663 } ) ?)
5764 }
5865 _ => {
You can’t perform that action at this time.
0 commit comments