[vlc-devel] commit: Fix regression in libvlc_video_set_spu() and libvlc_audio_set_track (). (Jean-Paul Saman )

git version control git at videolan.org
Sat Oct 4 14:39:42 CEST 2008


vlc | branch: 0.9-bugfix | Jean-Paul Saman <jpsaman at videolan.org> | Fri Oct  3 13:56:45 2008 +0200| [7957fe56f0677ba2783a943e7819e5b2c7cdd15e] | committer: Jean-Paul Saman 

Fix regression in libvlc_video_set_spu() and libvlc_audio_set_track().
(cherry picked from commit 36088cd5e25bfeb49704c194fb194d1d569b34a5)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7957fe56f0677ba2783a943e7819e5b2c7cdd15e
---

 src/control/audio.c |   27 ++++++++++++---------------
 src/control/video.c |   33 ++++++++++++++-------------------
 2 files changed, 26 insertions(+), 34 deletions(-)

diff --git a/src/control/audio.c b/src/control/audio.c
index 22a886e..96c0f37 100644
--- a/src/control/audio.c
+++ b/src/control/audio.c
@@ -172,7 +172,6 @@ int libvlc_audio_get_track( libvlc_media_player_t *p_mi,
     return i_track;
 }
 
-
 /*****************************************************************************
  * libvlc_audio_set_track : Set the current audio track
  *****************************************************************************/
@@ -181,28 +180,26 @@ void 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, p_e );
     vlc_value_t val_list;
+    vlc_value_t newval;
     int i_ret = -1;
-    int i;
 
     if( !p_input_thread )
         return;
 
     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( (i_track < 0) && (i_track > val_list.p_list->i_count) )
     {
-        vlc_value_t val = val_list.p_list->p_values[i];
-        if( i_track == val.i_int )
-        {
-            i_ret = var_Set( p_input_thread, "audio-es", val );
-            if( i_ret < 0 )
-            {
-                libvlc_exception_raise( p_e, "Setting audio track failed" );
-            }
-            vlc_object_release( p_input_thread );
-            return;
-        }
+        libvlc_exception_raise( p_e, "Audio track out of range" );
+        vlc_object_release( p_input_thread );
+        return;
+    }
+
+    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" );
     }
-    libvlc_exception_raise( p_e, "Audio track out of range" );
     vlc_object_release( p_input_thread );
 }
 
diff --git a/src/control/video.c b/src/control/video.c
index c4a3e83..ec9b740 100644
--- a/src/control/video.c
+++ b/src/control/video.c
@@ -252,9 +252,9 @@ libvlc_drawable_t libvlc_video_get_parent( libvlc_instance_t *p_instance, libvlc
     VLC_UNUSED(p_e);
 
     libvlc_drawable_t result;
- 
+
     result = var_GetInteger( p_instance->p_libvlc_int, "drawable" );
- 
+
     return result;
 }
 
@@ -388,30 +388,25 @@ void libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu,
 {
     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
     vlc_value_t val_list;
+    vlc_value_t newval;
     int i_ret = -1;
-    int i;
 
     if( !p_input_thread ) return;
 
     var_Change( p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &val_list, NULL );
-    for( i = 0; i < val_list.p_list->i_count; i++ )
+    if( (i_spu < 0) && (i_spu > val_list.p_list->i_count) )
     {
-        vlc_value_t val = val_list.p_list->p_values[i];
-        if( i_spu == val.i_int )
-        {
-            vlc_value_t new_val;
-
-            new_val.i_int = val.i_int;
-            i_ret = var_Set( p_input_thread, "spu-es", new_val );
-            if( i_ret < 0 )
-            {
-                libvlc_exception_raise( p_e, "Setting subtitle value failed" );
-            }
-            vlc_object_release( p_input_thread );
-            return;
-        }
+        libvlc_exception_raise( p_e, "Subtitle value out of range" );
+        vlc_object_release( p_input_thread );
+        return;
+    }
+
+    newval = val_list.p_list->p_values[i_spu];
+    i_ret = var_Set( p_input_thread, "spu-es", newval );
+    if( i_ret < 0 )
+    {
+        libvlc_exception_raise( p_e, "Setting subtitle value failed" );
     }
-    libvlc_exception_raise( p_e, "Subtitle value out of range" );
     vlc_object_release( p_input_thread );
 }
 




More information about the vlc-devel mailing list