]> git.sesse.net Git - vlc/blobdiff - lib/audio.c
PulseAudio: remove custom synchronization and resampling code
[vlc] / lib / audio.c
index ba8f8534f752278f13e6bfdd8e03a52b860282db..799bdc8e70537924445cacb667d2d9fc7cf5fd27 100644 (file)
@@ -35,7 +35,6 @@
 
 #include <vlc_common.h>
 #include <vlc_input.h>
-#include <vlc_aout_intf.h>
 #include <vlc_aout.h>
 #include <vlc_modules.h>
 
@@ -50,12 +49,7 @@ static audio_output_t *GetAOut( libvlc_media_player_t *mp )
 {
     assert( mp != NULL );
 
-    input_thread_t *p_input = libvlc_get_input_thread( mp );
-    if( p_input == NULL )
-        return NULL;
-
-    audio_output_t * p_aout = input_GetAout( p_input );
-    vlc_object_release( p_input );
+    audio_output_t *p_aout = input_resource_HoldAout( mp->input.p_resource );
     if( p_aout == NULL )
         libvlc_printerr( "No active audio output" );
     return p_aout;
@@ -254,23 +248,46 @@ void libvlc_audio_output_set_device_type( libvlc_media_player_t *mp,
 
 void libvlc_audio_toggle_mute( libvlc_media_player_t *mp )
 {
-    aout_MuteToggle( mp );
+    int mute = libvlc_audio_get_mute( mp );
+    if( mute != -1 )
+        libvlc_audio_set_mute( mp, !mute );
 }
 
 int libvlc_audio_get_mute( libvlc_media_player_t *mp )
 {
-    return aout_MuteGet( mp );
+    int mute = -1;
+
+    audio_output_t *aout = GetAOut( mp );
+    if( aout != NULL )
+    {
+        mute = aout_MuteGet( aout );
+        vlc_object_release( aout );
+    }
+    return mute;
 }
 
 void libvlc_audio_set_mute( libvlc_media_player_t *mp, int mute )
 {
-    aout_MuteSet( VLC_OBJECT(mp), mute != 0 );
+    audio_output_t *aout = GetAOut( mp );
+    if( aout != NULL )
+    {
+        mute = aout_MuteSet( aout, mute );
+        vlc_object_release( aout );
+    }
 }
 
 int libvlc_audio_get_volume( libvlc_media_player_t *mp )
 {
-    float vol = aout_VolumeGet( mp );
-    return ( vol >= 0.f ) ? lroundf( vol * 100.f ) : -1;
+    int volume = -1;
+
+    audio_output_t *aout = GetAOut( mp );
+    if( aout != NULL )
+    {
+        float vol = aout_VolumeGet( aout );
+        vlc_object_release( aout );
+        volume = lroundf( vol * 100.f );
+    }
+    return volume;
 }
 
 int libvlc_audio_set_volume( libvlc_media_player_t *mp, int volume )
@@ -281,8 +298,15 @@ int libvlc_audio_set_volume( libvlc_media_player_t *mp, int volume )
         libvlc_printerr( "Volume out of range" );
         return -1;
     }
-    aout_VolumeSet (mp, vol);
-    return 0;
+
+    int ret = -1;
+    audio_output_t *aout = GetAOut( mp );
+    if( aout != NULL )
+    {
+        ret = aout_VolumeSet( aout, vol );
+        vlc_object_release( aout );
+    }
+    return ret;
 }
 
 /*****************************************************************************
@@ -317,33 +341,12 @@ libvlc_track_description_t *
 int libvlc_audio_get_track( libvlc_media_player_t *p_mi )
 {
     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
-    vlc_value_t val_list;
-    vlc_value_t val;
-    int i_track = -1;
-    int i;
-
     if( !p_input_thread )
         return -1;
 
-    if( var_Get( p_input_thread, "audio-es", &val ) < 0 )
-    {
-        vlc_object_release( p_input_thread );
-        libvlc_printerr( "Audio track information not found" );
-        return -1;
-    }
-
-    var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL );
-    for( i = 0; i < val_list.p_list->i_count; i++ )
-    {
-        if( val_list.p_list->p_values[i].i_int == val.i_int )
-        {
-            i_track = i;
-            break;
-        }
-    }
-    var_FreeList( &val_list, NULL );
+    int id = var_GetInteger( p_input_thread, "audio-es" );
     vlc_object_release( p_input_thread );
-    return i_track;
+    return id;
 }
 
 /*****************************************************************************
@@ -353,30 +356,23 @@ int libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track )
 {
     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
     vlc_value_t val_list;
-    vlc_value_t newval;
     int i_ret;
 
     if( !p_input_thread )
         return -1;
 
     var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL );
-    if( (i_track < 0) || (i_track > val_list.p_list->i_count) )
-    {
-        libvlc_printerr( "Audio track out of range" );
-        i_ret = -1;
-        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 )
+    for( int i = 0; i < val_list.p_list->i_count; i++ )
     {
-        libvlc_printerr( "Audio track out of range" ); /* Race... */
-        i_ret = -1;
-        goto end;
+        if( i_track == val_list.p_list->p_values[i].i_int )
+        {
+            if( var_SetInteger( p_input_thread, "audio-es", i_track ) < 0 )
+                break;
+            i_ret = 0;
+            goto end;
+        }
     }
-    i_ret = 0;
-
+    libvlc_printerr( "Track identifier not found" );
 end:
     var_FreeList( &val_list, NULL );
     vlc_object_release( p_input_thread );
@@ -392,7 +388,7 @@ int libvlc_audio_get_channel( libvlc_media_player_t *mp )
     if( !p_aout )
         return 0;
 
-    int val = var_GetInteger( p_aout, "audio-channels" );
+    int val = var_GetInteger( p_aout, "stereo-mode" );
     vlc_object_release( p_aout );
     return val;
 }
@@ -408,7 +404,7 @@ int libvlc_audio_set_channel( libvlc_media_player_t *mp, int channel )
     if( !p_aout )
         return -1;
 
-    if( var_SetInteger( p_aout, "audio-channels", channel ) < 0 )
+    if( var_SetInteger( p_aout, "stereo-mode", channel ) < 0 )
     {
         libvlc_printerr( "Audio channel out of range" );
         ret = -1;