]> git.sesse.net Git - vlc/commitdiff
libvlc input and video update:
authorFilippo Carone <littlejohn@videolan.org>
Mon, 5 Jun 2006 18:23:56 +0000 (18:23 +0000)
committerFilippo Carone <littlejohn@videolan.org>
Mon, 5 Jun 2006 18:23:56 +0000 (18:23 +0000)
* video.c: added 1 release object in GetVout
* input.c: added libvlc_get_input_thread helper

src/control/input.c
src/control/video.c

index d2b46b26a11f790d0732b9077eba4e455c13e3b3..94026c1b0af5362e72c252fe4995a8868c1c7327 100644 (file)
@@ -32,18 +32,18 @@ void libvlc_input_free( libvlc_input_t *p_input )
         free( p_input );
 }
 
-/**************************************************************************
- * Getters for stream information
- **************************************************************************/
-vlc_int64_t libvlc_input_get_length( libvlc_input_t *p_input,
-                             libvlc_exception_t *p_exception )
+/*
+ * Retrieve the input thread. Be sure to release the object
+ * once you are done with it.
+ */
+input_thread_t *libvlc_get_input_thread( libvlc_input_t *p_input,
+                                         libvlc_exception_t *p_e ) 
 {
     input_thread_t *p_input_thread;
-    vlc_value_t val;
 
     if( !p_input )
     {
-        libvlc_exception_raise( p_exception, "Input is NULL" );
+        libvlc_exception_raise( p_e, "Input is NULL" );
         return -1;
     }
 
@@ -52,9 +52,29 @@ vlc_int64_t libvlc_input_get_length( libvlc_input_t *p_input,
                                  p_input->i_input_id );
     if( !p_input_thread )
     {
-        libvlc_exception_raise( p_exception, "Input does not exist" );
-        return -1;
+        libvlc_exception_raise( p_e, "Input does not exist" );
+        return NULL;
     }
+
+    return p_input_thread;
+}
+
+    
+
+/**************************************************************************
+ * Getters for stream information
+ **************************************************************************/
+vlc_int64_t libvlc_input_get_length( libvlc_input_t *p_input,
+                             libvlc_exception_t *p_exception )
+{
+    input_thread_t *p_input_thread;
+    vlc_value_t val;
+
+    p_input_thread = libvlc_get_input_thread ( p_input, p_exception);
+
+    if ( libvlc_exception_raised( p_exception ) )
+        return -1.0;
+       
     var_Get( p_input_thread, "length", &val );
     vlc_object_release( p_input_thread );
 
@@ -67,20 +87,12 @@ vlc_int64_t libvlc_input_get_time( libvlc_input_t *p_input,
     input_thread_t *p_input_thread;
     vlc_value_t val;
 
-    if( !p_input )
-    {
-        libvlc_exception_raise( p_exception, "Input is NULL" );
-        return -1;
-    }
 
-    p_input_thread = (input_thread_t*)vlc_object_get(
-                                 p_input->p_instance->p_vlc,
-                                 p_input->i_input_id );
-    if( !p_input_thread )
-    {
-        libvlc_exception_raise( p_exception, "Input does not exist" );
-        return -1;
-    }
+    p_input_thread = libvlc_get_input_thread ( p_input, p_exception);
+
+    if ( libvlc_exception_raised( p_exception ) )
+        return -1.0;
+
     var_Get( p_input_thread , "time", &val );
     vlc_object_release( p_input_thread );
 
@@ -93,20 +105,11 @@ float libvlc_input_get_position( libvlc_input_t *p_input,
     input_thread_t *p_input_thread;
     vlc_value_t val;
 
-    if( !p_input )
-    {
-        libvlc_exception_raise( p_exception, "Input is NULL" );
-        return -1;
-    }
+    p_input_thread = libvlc_get_input_thread ( p_input, p_exception);
 
-    p_input_thread = (input_thread_t*)vlc_object_get(
-                            p_input->p_instance->p_vlc,
-                            p_input->i_input_id );
-    if( !p_input_thread )
-    {
-        libvlc_exception_raise( p_exception, "Input does not exist" );
+    if ( libvlc_exception_raised( p_exception ) )
         return -1.0;
-    }
+
     var_Get( p_input_thread, "position", &val );
     vlc_object_release( p_input_thread );
 
@@ -118,21 +121,10 @@ vlc_bool_t libvlc_input_will_play( libvlc_input_t *p_input,
 {
     input_thread_t *p_input_thread;
 
-    if( !p_input )
-    {
-        libvlc_exception_raise( p_exception, "Input is NULL" );
-        return VLC_FALSE;
-    }
-
-    p_input_thread = (input_thread_t*)vlc_object_get(
-                            p_input->p_instance->p_vlc,
-                            p_input->i_input_id );
+    p_input_thread = libvlc_get_input_thread ( p_input, p_exception);
 
-    if( !p_input_thread )
-    {
-        libvlc_exception_raise( p_exception, "Input does not exist" );
+    if ( libvlc_exception_raised( p_exception ) )
         return VLC_FALSE;
-    }
 
     if ( !p_input_thread->b_die && !p_input_thread->b_dead ) 
     {
index d0bf557152fce4a1ed43b430f1d0d54ecc5e538e..968d51bea71c14c3f796c5a329530dd7f0e0d975 100644 (file)
@@ -51,9 +51,12 @@ static vout_thread_t *GetVout( libvlc_input_t *p_input,
     p_vout = vlc_object_find( p_input_thread, VLC_OBJECT_VOUT, FIND_CHILD );
     if( !p_vout )
     {
+        vlc_object_release( p_input_thread );
         libvlc_exception_raise( p_exception, "No active video output" );
         return NULL;
     }
+    vlc_object_release( p_input_thread );
+    
     return p_vout;
 }
 /**********************************************************************