mirror of
https://github.com/videolan/vlc.git
synced 2024-11-27 11:57:03 +08:00
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@remlab.net>
This commit is contained in:
parent
c8d3f4ae27
commit
1ce2223d32
@ -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
|
||||
|
@ -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 );
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user