]> git.sesse.net Git - vlc/commitdiff
VolumeUp/Down/Mute now work even if no file is playing.
authorChristophe Massiot <massiot@videolan.org>
Wed, 15 Jan 2003 11:27:29 +0000 (11:27 +0000)
committerChristophe Massiot <massiot@videolan.org>
Wed, 15 Jan 2003 11:27:29 +0000 (11:27 +0000)
modules/gui/macosx/controls.m
src/audio_output/intf.c

index e5696115bf3e18771e4c7210e130c1bce01b6936..5be13541efd3fffb752827fdad26cc4fed467a63 100644 (file)
@@ -2,7 +2,7 @@
  * controls.m: MacOS X interface plugin
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: controls.m,v 1.6 2003/01/05 16:23:57 massiot Exp $
+ * $Id: controls.m,v 1.7 2003/01/15 11:27:29 massiot Exp $
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *          Christophe Massiot <massiot@via.ecp.fr>
     intf_thread_t * p_intf = [NSApp getIntf];
     aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
                                                 FIND_ANYWHERE );
+    audio_volume_t i_volume;
 
     if ( p_aout != NULL )
     {
-        aout_VolumeMute( p_aout, NULL );
+        aout_VolumeMute( p_aout, &i_volume );
         vlc_object_release( (vlc_object_t *)p_aout );
     }
 
     NSMenuItem * o_mi = (NSMenuItem *)sender;
-    p_intf->p_sys->b_mute = !p_intf->p_sys->b_mute;
+    p_intf->p_sys->b_mute = (i_volume == 0);
     [o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
 }
 
index 2e4d42164b391a3fef87b953592a02ae76a5125b..b23bde8737c1974d4997bdae938203f952277c5a 100644 (file)
@@ -2,7 +2,7 @@
  * intf.c : audio output API towards the interface modules
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: intf.c,v 1.11 2002/12/10 18:22:01 gbazin Exp $
+ * $Id: intf.c,v 1.12 2003/01/15 11:27:29 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -141,10 +141,18 @@ int aout_VolumeUp( aout_instance_t * p_aout, int i_nb_steps,
 
     if ( p_aout->mixer.b_error )
     {
+        int i;
         /* The output module is destroyed. */
         vlc_mutex_unlock( &p_aout->mixer_lock );
-        msg_Err( p_aout, "VolumeUp called without output module" );
-        return -1;
+        i = config_GetInt( p_aout, "volume" );
+        i += AOUT_VOLUME_STEP * i_nb_steps;
+        if ( i > AOUT_VOLUME_MAX )
+        {
+            i = AOUT_VOLUME_MAX;
+        }
+        config_PutInt( p_aout, "volume", i );
+        if ( pi_volume != NULL ) *pi_volume = (audio_volume_t)i;
+        return 0;
     }
 
     if ( p_aout->output.pf_volume_get( p_aout, &i_volume ) )
@@ -154,7 +162,7 @@ int aout_VolumeUp( aout_instance_t * p_aout, int i_nb_steps,
     }
 
     i_volume += AOUT_VOLUME_STEP * i_nb_steps;
-    if ( i_volume > 1024 ) i_volume = 1024;
+    if ( i_volume > AOUT_VOLUME_MAX ) i_volume = AOUT_VOLUME_MAX;
 
     i_result = p_aout->output.pf_volume_set( p_aout, i_volume );
 
@@ -180,10 +188,18 @@ int aout_VolumeDown( aout_instance_t * p_aout, int i_nb_steps,
 
     if ( p_aout->mixer.b_error )
     {
+        int i;
         /* The output module is destroyed. */
         vlc_mutex_unlock( &p_aout->mixer_lock );
-        msg_Err( p_aout, "VolumeUp called without output module" );
-        return -1;
+        i = config_GetInt( p_aout, "volume" );
+        i -= AOUT_VOLUME_STEP * i_nb_steps;
+        if ( i < 0 )
+        {
+            i = AOUT_VOLUME_MAX;
+        }
+        config_PutInt( p_aout, "volume", i );
+        if ( pi_volume != NULL ) *pi_volume = (audio_volume_t)i;
+        return 0;
     }
 
     if ( p_aout->output.pf_volume_get( p_aout, &i_volume ) )
@@ -220,10 +236,12 @@ int aout_VolumeMute( aout_instance_t * p_aout, audio_volume_t * pi_volume )
 
     if ( p_aout->mixer.b_error )
     {
+        int i;
         /* The output module is destroyed. */
         vlc_mutex_unlock( &p_aout->mixer_lock );
-        msg_Err( p_aout, "VolumeUp called without output module" );
-        return -1;
+        config_PutInt( p_aout, "volume", 0 );
+        if ( pi_volume != NULL ) *pi_volume = 0;
+        return 0;
     }
 
     if ( p_aout->output.pf_volume_get( p_aout, &i_volume ) )