]> git.sesse.net Git - vlc/blobdiff - src/control/audio.c
config: Change the caching directories of VLC Mac OS X to Library/Caches/VLC
[vlc] / src / control / audio.c
index 21147fe8253cfa729f59c601b65d99f2d614cc90..fb96b70b087a06a4b99f65a462b32b1989439586 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#include "libvlc_internal.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <vlc/libvlc.h>
+#include <vlc/libvlc_media.h>
+#include <vlc/libvlc_media_player.h>
 
+#include <vlc_common.h>
 #include <vlc_input.h>
 #include <vlc_aout.h>
 
+#include "libvlc_internal.h"
+#include "media_player_internal.h"
 
 /*
  * Remember to release the returned aout_instance_t since it is locked at
@@ -87,7 +95,7 @@ VLC_PUBLIC_API libvlc_audio_output_t *
                     p_previous = p_actual;
                 }
             }
-            p_actual->psz_name = strdup( module_get_name( p_module, false ) );
+            p_actual->psz_name = strdup( module_get_object( p_module ) );
             p_actual->psz_description = strdup( module_get_name( p_module, true )  );
             p_actual->p_next = NULL;
             if( p_previous != p_actual ) /* not first item */
@@ -299,18 +307,8 @@ void libvlc_audio_output_set_device_type( libvlc_instance_t *p_instance,
     aout_instance_t *p_aout = GetAOut( p_instance, p_e );
     if( p_aout )
     {
-        vlc_value_t val;
-        int i_ret = -1;
-
-        val.i_int = (int) device_type;
-        i_ret = var_Set( p_aout, "audio-device", val );
-        if( i_ret < 0 )
-        {
+        if( var_SetInteger( p_aout, "audio-device", device_type ) < 0 )
             libvlc_exception_raise( p_e, "Failed setting audio device" );
-            vlc_object_release( p_aout );
-            return;
-        }
-
         vlc_object_release( p_aout );
     }
 }
@@ -329,15 +327,7 @@ void libvlc_audio_toggle_mute( libvlc_instance_t *p_instance,
 int libvlc_audio_get_mute( libvlc_instance_t *p_instance,
                            libvlc_exception_t *p_e )
 {
-    /*
-     * If the volume level is 0, then the channel is muted
-     */
-    audio_volume_t i_volume;
-
-    i_volume = libvlc_audio_get_volume(p_instance, p_e);
-    if ( i_volume == 0 )
-        return true;
-    return false;
+    return (libvlc_audio_get_volume(p_instance, p_e) == 0);
 }
 
 void libvlc_audio_set_mute( libvlc_instance_t *p_instance, int mute,
@@ -390,14 +380,15 @@ int libvlc_audio_get_track_count( libvlc_media_player_t *p_mi,
                                   libvlc_exception_t *p_e )
 {
     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
-    vlc_value_t val_list;
+    int i_track_count;
 
     if( !p_input_thread )
         return -1;
 
-    var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL );
+    i_track_count = var_CountChoices( p_input_thread, "audio-es" );
+
     vlc_object_release( p_input_thread );
-    return val_list.p_list->i_count;
+    return i_track_count;
 }
 
 /*****************************************************************************
@@ -437,13 +428,13 @@ int libvlc_audio_get_track( libvlc_media_player_t *p_mi,
     var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL );
     for( i = 0; i < val_list.p_list->i_count; i++ )
     {
-        vlc_value_t track_val = val_list.p_list->p_values[i];
-        if( track_val.i_int == val.i_int )
+        if( val_list.p_list->p_values[i].i_int == val.i_int )
         {
             i_track = i;
             break;
-       }
+        }
     }
+    var_FreeList( &val_list, NULL );
     vlc_object_release( p_input_thread );
     return i_track;
 }
@@ -466,16 +457,16 @@ void libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track,
     if( (i_track < 0) && (i_track > val_list.p_list->i_count) )
     {
         libvlc_exception_raise( p_e, "Audio track out of range" );
-        vlc_object_release( p_input_thread );
-        return;
+        goto end;
     }
 
     newval = val_list.p_list->p_values[i_track];
     i_ret = var_Set( p_input_thread, "audio-es", newval );
     if( i_ret < 0 )
-    {
         libvlc_exception_raise( p_e, "Setting audio track failed" );
-    }
+
+end:
+    var_FreeList( &val_list, NULL );
     vlc_object_release( p_input_thread );
 }