From: Niles Bindel Date: Tue, 25 Aug 2009 17:11:06 +0000 (-0500) Subject: Add input resource support to the LibVLC Media Player X-Git-Tag: 1.1.0-ff~3864 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=1ce2223d328e3bdb626432866caa5df06adc9828;p=vlc 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 --- diff --git a/include/vlc_input.h b/include/vlc_input.h index d6048f50b6..d58da61183 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 290155f172..2fec2ae9a4 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 3eeda533aa..4bc73fda32 100644 --- a/src/control/media_player_internal.h +++ b/src/control/media_player_internal.h @@ -32,12 +32,14 @@ #include #include #include +#include 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 b7cde94803..b48b2046ea 100644 --- a/src/input/input_interface.h +++ b/src/input/input_interface.h @@ -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 { diff --git a/src/libvlccore.sym b/src/libvlccore.sym index d0dc367208..792b10663b 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