]> git.sesse.net Git - vlc/blobdiff - src/input/input_ext-intf.c
* Bug fixes and enhancements in the Gtk+/Gnome interfaces.
[vlc] / src / input / input_ext-intf.c
index db49b7bbd30b507c11417b439559e0148b7c0b50..061fe273173a5b52c2a007c0a57891543ae20176 100644 (file)
@@ -167,7 +167,7 @@ char * input_OffsetToTime( input_thread_t * p_input, char * psz_buffer,
 
     if( p_input->stream.i_mux_rate )
     {
-        i_seconds = i_offset * 50 / p_input->stream.i_mux_rate;
+        i_seconds = i_offset / 50 / p_input->stream.i_mux_rate;
         snprintf( psz_buffer, OFFSETTOTIME_MAX_SIZE, "%d:%02d:%02d",
                  (int) (i_seconds / (60 * 60)),
                  (int) (i_seconds / 60 % 60),
@@ -177,7 +177,7 @@ char * input_OffsetToTime( input_thread_t * p_input, char * psz_buffer,
     else
     {
         /* Divide by zero is not my friend. */
-        sprintf( psz_buffer, "NA" );
+        sprintf( psz_buffer, "-:--:--" );
         return( psz_buffer );
     }
 }
@@ -225,3 +225,73 @@ void input_DumpStream( input_thread_t * p_input )
     }
 }
 
+/*****************************************************************************
+ * input_ChangeES: answers to a user request with calls to (Un)SelectES
+ * ---
+ * Useful since the interface plugins know p_es
+ *****************************************************************************/
+int input_ChangeES( input_thread_t * p_input, es_descriptor_t * p_es,
+                    int i_type )
+{
+    boolean_t               b_audio;
+    boolean_t               b_spu;
+    int                     i_index;
+    int                     i;
+
+    i_index = -1;
+    b_audio = ( i_type == 1 ) ? 1 : 0;
+    b_spu   = ( i_type == 2 ) ? 1 : 0;
+
+    vlc_mutex_lock( &p_input->stream.stream_lock );
+
+    for( i = 0 ; i < p_input->stream.i_selected_es_number ; i++ )
+    {
+        if( ( b_audio && p_input->stream.pp_selected_es[i]->b_audio ) 
+         || ( b_spu   && p_input->stream.pp_selected_es[i]->b_spu ) )
+        {
+            i_index = i;
+            break;
+        }
+    }
+
+
+    if( p_es != NULL )
+    {
+
+    
+        if( i_index != -1 )
+        {
+            
+            if( p_input->stream.pp_selected_es[i_index] != p_es )
+            {
+                input_UnselectES( p_input,
+                                  p_input->stream.pp_selected_es[i_index] );
+                input_SelectES( p_input, p_es );
+                intf_WarnMsg( 1, "input info: es selected -> %s (0x%x)",
+                                                p_es->psz_desc, p_es->i_id );
+            }
+        }
+        else
+        {
+            input_SelectES( p_input, p_es );
+            intf_WarnMsg( 1, "input info: es selected -> %s (0x%x)",
+                          p_es->psz_desc, p_es->i_id );
+        }
+    }
+    else
+    {
+        if( i_index != -1 )
+        {
+            intf_WarnMsg( 1, "input info: es unselected -> %s (0x%x)",
+                          p_input->stream.pp_selected_es[i_index]->psz_desc,
+                          p_input->stream.pp_selected_es[i_index]->i_id );
+
+            input_UnselectES( p_input,
+                              p_input->stream.pp_selected_es[i_index] );
+        }
+    }
+
+    vlc_mutex_unlock( &p_input->stream.stream_lock );
+
+    return 0;
+}