Commit 3ddfd217 authored by Christophe Massiot's avatar Christophe Massiot

VolumeUp/Down/Mute now work even if no file is playing.

parent 305bc15e
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* controls.m: MacOS X interface plugin * controls.m: MacOS X interface plugin
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr> * Christophe Massiot <massiot@via.ecp.fr>
...@@ -240,15 +240,16 @@ ...@@ -240,15 +240,16 @@
intf_thread_t * p_intf = [NSApp getIntf]; intf_thread_t * p_intf = [NSApp getIntf];
aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT, aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
FIND_ANYWHERE ); FIND_ANYWHERE );
audio_volume_t i_volume;
if ( p_aout != NULL ) if ( p_aout != NULL )
{ {
aout_VolumeMute( p_aout, NULL ); aout_VolumeMute( p_aout, &i_volume );
vlc_object_release( (vlc_object_t *)p_aout ); vlc_object_release( (vlc_object_t *)p_aout );
} }
NSMenuItem * o_mi = (NSMenuItem *)sender; 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]; [o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* intf.c : audio output API towards the interface modules * intf.c : audio output API towards the interface modules
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -141,10 +141,18 @@ int aout_VolumeUp( aout_instance_t * p_aout, int i_nb_steps, ...@@ -141,10 +141,18 @@ int aout_VolumeUp( aout_instance_t * p_aout, int i_nb_steps,
if ( p_aout->mixer.b_error ) if ( p_aout->mixer.b_error )
{ {
int i;
/* The output module is destroyed. */ /* The output module is destroyed. */
vlc_mutex_unlock( &p_aout->mixer_lock ); vlc_mutex_unlock( &p_aout->mixer_lock );
msg_Err( p_aout, "VolumeUp called without output module" ); i = config_GetInt( p_aout, "volume" );
return -1; 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 ) ) 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, ...@@ -154,7 +162,7 @@ int aout_VolumeUp( aout_instance_t * p_aout, int i_nb_steps,
} }
i_volume += AOUT_VOLUME_STEP * 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 ); 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, ...@@ -180,10 +188,18 @@ int aout_VolumeDown( aout_instance_t * p_aout, int i_nb_steps,
if ( p_aout->mixer.b_error ) if ( p_aout->mixer.b_error )
{ {
int i;
/* The output module is destroyed. */ /* The output module is destroyed. */
vlc_mutex_unlock( &p_aout->mixer_lock ); vlc_mutex_unlock( &p_aout->mixer_lock );
msg_Err( p_aout, "VolumeUp called without output module" ); i = config_GetInt( p_aout, "volume" );
return -1; 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 ) ) 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 ) ...@@ -220,10 +236,12 @@ int aout_VolumeMute( aout_instance_t * p_aout, audio_volume_t * pi_volume )
if ( p_aout->mixer.b_error ) if ( p_aout->mixer.b_error )
{ {
int i;
/* The output module is destroyed. */ /* The output module is destroyed. */
vlc_mutex_unlock( &p_aout->mixer_lock ); vlc_mutex_unlock( &p_aout->mixer_lock );
msg_Err( p_aout, "VolumeUp called without output module" ); config_PutInt( p_aout, "volume", 0 );
return -1; if ( pi_volume != NULL ) *pi_volume = 0;
return 0;
} }
if ( p_aout->output.pf_volume_get( p_aout, &i_volume ) ) if ( p_aout->output.pf_volume_get( p_aout, &i_volume ) )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment