]> git.sesse.net Git - vlc/commitdiff
Add input resource support to the LibVLC Media Player
authorNiles Bindel <zaggal69@gmail.com>
Tue, 25 Aug 2009 17:11:06 +0000 (12:11 -0500)
committerRémi Denis-Courmont <remi@remlab.net>
Wed, 26 Aug 2009 18:05:55 +0000 (21:05 +0300)
This change allows for smoother transitioning between playlist items by
not having to recreate the related video/audio resources from scratch on
every item switch. This problem was very apparent in fullscreen mode
when the current display would close out showing the OS background and
then go back to fullscreen before playing the next item.

Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
include/vlc_input.h
src/control/media_player.c
src/control/media_player_internal.h
src/input/input_interface.h
src/libvlccore.sym

index d6048f50b6f889d7901d021b2384cdfb8d30f760..d58da61183b67f6711000870db9fa1247a16f7a9 100644 (file)
@@ -613,4 +613,18 @@ VLC_EXPORT( void, input_SplitMRL, ( const char **ppsz_access, const char **ppsz_
  */
 VLC_EXPORT( char *, input_CreateFilename, ( vlc_object_t *, const char *psz_path, const char *psz_prefix, const char *psz_extension ) );
 
+/**
+ * This function detaches resources from a dead input.
+ *
+ * It MUST be called on a dead input (p_input->b_dead true) otherwise
+ * it will assert.
+ * It does not support concurrent calls.
+ */
+VLC_EXPORT(input_resource_t *, input_DetachResource, ( input_thread_t * ) );
+
+/**
+ * This function releases the input resource.
+ */
+VLC_EXPORT(void, input_resource_Delete, ( input_resource_t * ) );
+
 #endif
index 290155f1722b60aa6942dd5eebd6fc127e9cbb7e..2fec2ae9a476f968b9f7c43226d80f5cbe6a218a 100644 (file)
@@ -82,8 +82,14 @@ static void release_input_thread( libvlc_media_player_t *p_mi, bool b_input_abor
 
     /* We owned this one */
     input_Stop( p_input_thread, b_input_abort );
+
     vlc_thread_join( p_input_thread );
 
+    assert( p_mi->p_input_resource == NULL );
+    assert( p_input_thread->b_dead );
+    /* Store the input resource for future use. */
+    p_mi->p_input_resource = input_DetachResource( p_input_thread );
+
     var_Destroy( p_input_thread, "drawable-hwnd" );
     var_Destroy( p_input_thread, "drawable-xid" );
     var_Destroy( p_input_thread, "drawable-agl" );
@@ -288,6 +294,7 @@ libvlc_media_player_new( libvlc_instance_t * p_libvlc_instance,
     p_mi->drawable.nsobject = NULL;
     p_mi->p_libvlc_instance = p_libvlc_instance;
     p_mi->p_input_thread = NULL;
+    p_mi->p_input_resource = NULL;
     p_mi->i_refcount = 1;
     vlc_mutex_init( &p_mi->object_lock );
     p_mi->p_event_manager = libvlc_event_manager_new( p_mi,
@@ -382,9 +389,15 @@ static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi )
     var_DelCallback( p_mi->p_libvlc_instance->p_libvlc_int,
                      "vout-snapshottaken", SnapshotTakenCallback, p_mi );
 
-    /* Realease the input thread */
+    /* Release the input thread */
     release_input_thread( p_mi, true );
 
+    if( p_mi->p_input_resource )
+    {
+        input_resource_Delete( p_mi->p_input_resource );
+        p_mi->p_input_resource = NULL;    
+    }
+
     libvlc_event_manager_release( p_mi->p_event_manager );
     libvlc_media_release( p_mi->p_md );
     vlc_mutex_destroy( &p_mi->object_lock );
@@ -553,7 +566,7 @@ void libvlc_media_player_play( libvlc_media_player_t *p_mi,
     }
 
     p_mi->p_input_thread = input_Create( p_mi->p_libvlc_instance->p_libvlc_int,
-                                         p_mi->p_md->p_input_item, NULL, NULL );
+                                         p_mi->p_md->p_input_item, NULL, p_mi->p_input_resource );
 
     if( !p_mi->p_input_thread )
     {
@@ -561,6 +574,7 @@ void libvlc_media_player_play( libvlc_media_player_t *p_mi,
         return;
     }
 
+    p_mi->p_input_resource = NULL;
     p_input_thread = p_mi->p_input_thread;
 
     var_Create( p_input_thread, "drawable-agl", VLC_VAR_INTEGER );
index 3eeda533aa2601f5a423e8b11a8191134343f89b..4bc73fda322959adc90c9e752bf1b11d7441cf00 100644 (file)
 #include <vlc/vlc.h>
 #include <vlc/libvlc_structures.h>
 #include <vlc/libvlc_media.h>
+#include <vlc_input.h>
 
 struct libvlc_media_player_t
 {
     int                i_refcount;
     vlc_mutex_t        object_lock;
     input_thread_t *   p_input_thread;
+       input_resource_t * p_input_resource;
     struct libvlc_instance_t * p_libvlc_instance; /* Parent instance */
     libvlc_media_t * p_md; /* current media descriptor */
     libvlc_event_manager_t * p_event_manager;
index b7cde94803ffc461e2869f64b09e2c5f7d4323c6..b48b2046ea883e0d967ab96c8debd709b09a15d7 100644 (file)
@@ -46,11 +46,6 @@ int input_Preparse( vlc_object_t *, input_item_t * );
  * FIXME it should NOT be defined here or not coded in misc/stats.c */
 input_stats_t *stats_NewInputStats( input_thread_t *p_input );
 
-/**
- * This function releases an input_resource_t and all associated resources.
- */
-void input_resource_Delete( input_resource_t * );
-
 /**
  * This function deletes the current sout in the resources.
  */
@@ -70,15 +65,6 @@ bool input_resource_HasVout( input_resource_t *p_resource );
 
 /* input.c */
 
-/**
- * This function detaches resources from a dead input.
- *
- * It MUST be called on a dead input (p_input->b_dead true) otherwise
- * it will assert.
- * It does not support concurrent calls.
- */
-input_resource_t *input_DetachResource( input_thread_t * );
-
 /* */
 typedef enum
 {
index d0dc3672089f14e30d2e987536600ce0a840ff07..792b10663b4724bdb9bc451a741d32898711b3d8 100644 (file)
@@ -181,6 +181,7 @@ input_CreateFilename
 input_DecoderDecode
 input_DecoderDelete
 input_DecoderNew
+input_DetachResource
 input_GetItem
 input_item_AddInfo
 input_item_AddOption
@@ -206,6 +207,7 @@ input_item_SetURI
 input_item_WriteMeta
 input_MetaTypeToLocalizedString
 __input_Read
+input_resource_Delete
 input_SplitMRL
 input_Start
 input_Stop