@@ -205,9 +205,10 @@ fn get_setup(args: &[String]) -> Setup {
205205 const FORMAT : & str = "format" ;
206206 const HELP : & str = "h" ;
207207 const INITIAL_VOLUME : & str = "initial-volume" ;
208- const MIXER_CARD : & str = "mixer-card" ;
209- const MIXER_INDEX : & str = "mixer-index" ;
210- const MIXER_NAME : & str = "mixer-name" ;
208+ const MIXER_TYPE : & str = "mixer" ;
209+ const ALSA_MIXER_DEVICE : & str = "alsa-mixer-device" ;
210+ const ALSA_MIXER_INDEX : & str = "alsa-mixer-index" ;
211+ const ALSA_MIXER_CONTROL : & str = "alsa-mixer-control" ;
211212 const NAME : & str = "name" ;
212213 const NORMALISATION_ATTACK : & str = "normalisation-attack" ;
213214 const NORMALISATION_GAIN_TYPE : & str = "normalisation-gain-type" ;
@@ -295,24 +296,42 @@ fn get_setup(args: &[String]) -> Setup {
295296 "Specify the dither algorithm to use - [none, gpdf, tpdf, tpdf_hp]. Defaults to 'tpdf' for formats S16, S24, S24_3 and 'none' for other formats." ,
296297 "DITHER" ,
297298 )
298- . optopt ( "" , "mixer" , "Mixer to use {alsa|softvol}." , "MIXER" )
299+ . optopt ( "m " , MIXER_TYPE , "Mixer to use {alsa|softvol}." , "MIXER" )
299300 . optopt (
300- "m" ,
301- MIXER_NAME ,
301+ "" ,
302+ "mixer-name" , // deprecated
303+ "" ,
304+ "" ,
305+ )
306+ . optopt (
307+ "" ,
308+ ALSA_MIXER_CONTROL ,
302309 "Alsa mixer control, e.g. 'PCM' or 'Master'. Defaults to 'PCM'." ,
303310 "NAME" ,
304311 )
305312 . optopt (
306313 "" ,
307- MIXER_CARD ,
308- "Alsa mixer card, e.g 'hw:0' or similar from `aplay -l`. Defaults to DEVICE if specified, 'default' otherwise." ,
309- "MIXER_CARD" ,
314+ "mixer-card" , // deprecated
315+ "" ,
316+ "" ,
317+ )
318+ . optopt (
319+ "" ,
320+ ALSA_MIXER_DEVICE ,
321+ "Alsa mixer device, e.g 'hw:0' or similar from `aplay -l`. Defaults to `--device` if specified, 'default' otherwise." ,
322+ "DEVICE" ,
323+ )
324+ . optopt (
325+ "" ,
326+ "mixer-index" , // deprecated
327+ "" ,
328+ "" ,
310329 )
311330 . optopt (
312331 "" ,
313- MIXER_INDEX ,
332+ ALSA_MIXER_INDEX ,
314333 "Alsa index of the cards mixer. Defaults to 0." ,
315- "INDEX " ,
334+ "NUMBER " ,
316335 )
317336 . optopt (
318337 "" ,
@@ -454,28 +473,58 @@ fn get_setup(args: &[String]) -> Setup {
454473 exit ( 0 ) ;
455474 }
456475
457- let mixer_name = matches. opt_str ( MIXER_NAME ) ;
458- let mixer = mixer:: find ( mixer_name . as_deref ( ) ) . expect ( "Invalid mixer" ) ;
476+ let mixer_type = matches. opt_str ( MIXER_TYPE ) ;
477+ let mixer = mixer:: find ( mixer_type . as_deref ( ) ) . expect ( "Invalid mixer" ) ;
459478
460479 let mixer_config = {
461- let card = matches. opt_str ( MIXER_CARD ) . unwrap_or_else ( || {
462- if let Some ( ref device_name ) = device {
463- device_name . to_string ( )
464- } else {
465- MixerConfig :: default ( ) . card
480+ let mixer_device = match matches. opt_str ( "mixer-card" ) {
481+ Some ( card ) => {
482+ warn ! ( "--mixer-card is deprecated and will be removed in a future release." ) ;
483+ warn ! ( "Please use --alsa-mixer-device instead." ) ;
484+ card
466485 }
467- } ) ;
468- let index = matches
469- . opt_str ( MIXER_INDEX )
470- . map ( |index| index. parse :: < u32 > ( ) . unwrap ( ) )
471- . unwrap_or ( 0 ) ;
472- let control = matches
473- . opt_str ( MIXER_NAME )
474- . unwrap_or_else ( || MixerConfig :: default ( ) . control ) ;
486+ None => matches. opt_str ( ALSA_MIXER_DEVICE ) . unwrap_or_else ( || {
487+ if let Some ( ref device_name) = device {
488+ device_name. to_string ( )
489+ } else {
490+ MixerConfig :: default ( ) . device
491+ }
492+ } ) ,
493+ } ;
494+
495+ let index = match matches. opt_str ( "mixer-index" ) {
496+ Some ( index) => {
497+ warn ! ( "--mixer-index is deprecated and will be removed in a future release." ) ;
498+ warn ! ( "Please use --alsa-mixer-index instead." ) ;
499+ index
500+ . parse :: < u32 > ( )
501+ . expect ( "Mixer index is not a valid number" )
502+ }
503+ None => matches
504+ . opt_str ( ALSA_MIXER_INDEX )
505+ . map ( |index| {
506+ index
507+ . parse :: < u32 > ( )
508+ . expect ( "Alsa mixer index is not a valid number" )
509+ } )
510+ . unwrap_or ( 0 ) ,
511+ } ;
512+
513+ let control = match matches. opt_str ( "mixer-name" ) {
514+ Some ( name) => {
515+ warn ! ( "--mixer-name is deprecated and will be removed in a future release." ) ;
516+ warn ! ( "Please use --alsa-mixer-control instead." ) ;
517+ name
518+ }
519+ None => matches
520+ . opt_str ( ALSA_MIXER_CONTROL )
521+ . unwrap_or_else ( || MixerConfig :: default ( ) . control ) ,
522+ } ;
523+
475524 let mut volume_range = matches
476525 . opt_str ( VOLUME_RANGE )
477526 . map ( |range| range. parse :: < f64 > ( ) . unwrap ( ) )
478- . unwrap_or_else ( || match mixer_name . as_deref ( ) {
527+ . unwrap_or_else ( || match mixer_type . as_deref ( ) {
479528 #[ cfg( feature = "alsa-backend" ) ]
480529 Some ( AlsaMixer :: NAME ) => 0.0 , // let Alsa query the control
481530 _ => VolumeCtrl :: DEFAULT_DB_RANGE ,
@@ -502,7 +551,7 @@ fn get_setup(args: &[String]) -> Setup {
502551 } ) ;
503552
504553 MixerConfig {
505- card ,
554+ device : mixer_device ,
506555 control,
507556 index,
508557 volume_ctrl,
@@ -563,7 +612,7 @@ fn get_setup(args: &[String]) -> Setup {
563612 }
564613 ( volume as f32 / 100.0 * VolumeCtrl :: MAX_VOLUME as f32 ) as u16
565614 } )
566- . or_else ( || match mixer_name . as_deref ( ) {
615+ . or_else ( || match mixer_type . as_deref ( ) {
567616 #[ cfg( feature = "alsa-backend" ) ]
568617 Some ( AlsaMixer :: NAME ) => None ,
569618 _ => cache. as_ref ( ) . and_then ( Cache :: volume) ,
0 commit comments