[vlc-devel] commit: Add input resource support to the LibVLC Media Player ( Niles Bindel )
git version control
git at videolan.org
Wed Aug 26 20:05:58 CEST 2009
vlc | branch: master | Niles Bindel <zaggal69 at gmail.com> | Tue Aug 25 12:11:06 2009 -0500| [1ce2223d328e3bdb626432866caa5df06adc9828] | committer: Rémi Denis-Courmont
Add input resource support to the LibVLC Media Player
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 at remlab.net>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1ce2223d328e3bdb626432866caa5df06adc9828
---
include/vlc_input.h | 14 ++++++++++++++
src/control/media_player.c | 18 ++++++++++++++++--
src/control/media_player_internal.h | 2 ++
src/input/input_interface.h | 14 --------------
src/libvlccore.sym | 2 ++
5 files changed, 34 insertions(+), 16 deletions(-)
diff --git a/include/vlc_input.h b/include/vlc_input.h
index d6048f5..d58da61 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -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
diff --git a/src/control/media_player.c b/src/control/media_player.c
index 290155f..2fec2ae 100644
--- a/src/control/media_player.c
+++ b/src/control/media_player.c
@@ -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 );
diff --git a/src/control/media_player_internal.h b/src/control/media_player_internal.h
index 3eeda53..4bc73fd 100644
--- a/src/control/media_player_internal.h
+++ b/src/control/media_player_internal.h
@@ -32,12 +32,14 @@
#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;
diff --git a/src/input/input_interface.h b/src/input/input_interface.h
index b7cde94..b48b204 100644
--- a/src/input/input_interface.h
+++ b/src/input/input_interface.h
@@ -47,11 +47,6 @@ int input_Preparse( vlc_object_t *, input_item_t * );
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.
*/
void input_resource_TerminateSout( input_resource_t *p_resource );
@@ -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
{
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index d0dc367..792b106 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -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
More information about the vlc-devel
mailing list