]> git.sesse.net Git - vlc/blobdiff - src/audio_output/intf.c
* src/audio_output/intf.c: optimise aout_VolumeGet a bit.
[vlc] / src / audio_output / intf.c
index 8b11f496490316a5ee6626af264e3fb503e4f9ab..a80df9f4811d8712e928f227aca3d5f650e3ca20 100644 (file)
@@ -18,7 +18,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
  *****************************************************************************/
 int __aout_VolumeGet( vlc_object_t * p_object, audio_volume_t * pi_volume )
 {
-    int i_volume, i_result = 0;
+    int i_result = 0;
     aout_instance_t * p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT,
                                                 FIND_ANYWHERE );
 
-    i_volume = config_GetInt( p_object, "volume" );
-    if ( pi_volume != NULL ) *pi_volume = (audio_volume_t)i_volume;
+    if ( pi_volume == NULL ) return -1;
 
-    if ( p_aout == NULL ) return 0;
+    if ( p_aout == NULL )
+    {
+        *pi_volume = (audio_volume_t)config_GetInt( p_object, "volume" );
+        return 0;
+    }
 
     vlc_mutex_lock( &p_aout->mixer_lock );
     if ( !p_aout->mixer.b_error )
     {
         i_result = p_aout->output.pf_volume_get( p_aout, pi_volume );
     }
+    else
+    {
+        *pi_volume = (audio_volume_t)config_GetInt( p_object, "volume" );
+    }
     vlc_mutex_unlock( &p_aout->mixer_lock );
 
     vlc_object_release( p_aout );
@@ -92,6 +99,9 @@ int __aout_VolumeSet( vlc_object_t * p_object, audio_volume_t i_volume )
 
     config_PutInt( p_object, "volume", i_volume );
 
+    val.b_bool = VLC_TRUE;
+    var_Set( p_object->p_vlc, "volume-change", val );
+
     if ( p_aout == NULL ) return 0;
 
     vlc_mutex_lock( &p_aout->mixer_lock );
@@ -101,11 +111,7 @@ int __aout_VolumeSet( vlc_object_t * p_object, audio_volume_t i_volume )
     }
     vlc_mutex_unlock( &p_aout->mixer_lock );
 
-    vlc_object_release( p_aout );
-
-    val.b_bool = VLC_TRUE;
     var_Set( p_aout, "intf-change", val );
-    var_Set( p_aout->p_vlc, "volume-change", val );
     vlc_object_release( p_aout );
     return i_result;
 }
@@ -159,7 +165,8 @@ int __aout_VolumeUp( vlc_object_t * p_object, int i_nb_steps,
     }
     config_PutInt( p_object, "volume", i_volume );
     var_Create( p_object->p_libvlc, "saved-volume", VLC_VAR_INTEGER );
-    var_SetInteger( p_object->p_libvlc, "saved-volume" , (audio_volume_t) i_volume );
+    var_SetInteger( p_object->p_libvlc, "saved-volume" ,
+                    (audio_volume_t) i_volume );
     if ( pi_volume != NULL ) *pi_volume = (audio_volume_t) i_volume;
 
     if ( p_aout == NULL ) return 0;
@@ -167,7 +174,8 @@ int __aout_VolumeUp( vlc_object_t * p_object, int i_nb_steps,
     vlc_mutex_lock( &p_aout->mixer_lock );
     if ( !p_aout->mixer.b_error )
     {
-        i_result = p_aout->output.pf_volume_set( p_aout, (audio_volume_t) i_volume );
+        i_result = p_aout->output.pf_volume_set( p_aout,
+                                                (audio_volume_t) i_volume );
     }
     vlc_mutex_unlock( &p_aout->mixer_lock );