Commit e87abf62 authored by Laurent Aimar's avatar Laurent Aimar

Reworked/improved the way sout-keep works. (VLM sout-keep does not

work again yet )
parent 0bf39ed3
This diff is collapsed.
...@@ -93,6 +93,7 @@ struct input_thread_private_t ...@@ -93,6 +93,7 @@ struct input_thread_private_t
/* Output */ /* Output */
es_out_t *p_es_out; es_out_t *p_es_out;
sout_instance_t *p_sout; /* XXX Move it to es_out ? */ sout_instance_t *p_sout; /* XXX Move it to es_out ? */
vlc_bool_t b_sout_keep;
vlc_bool_t b_out_pace_control; /* idem ? */ vlc_bool_t b_out_pace_control; /* idem ? */
/* Main input properties */ /* Main input properties */
...@@ -225,8 +226,10 @@ int input_DownloadAndCacheArt ( playlist_t *, input_item_t * ); ...@@ -225,8 +226,10 @@ int input_DownloadAndCacheArt ( playlist_t *, input_item_t * );
***************************************************************************/ ***************************************************************************/
/* input.c */ /* input.c */
#define input_CreateThread2(a,b,c) __input_CreateThread2(VLC_OBJECT(a),b,c) #define input_CreateThreadExtended(a,b,c,d) __input_CreateThreadExtended(VLC_OBJECT(a),b,c,d)
input_thread_t *__input_CreateThread2 ( vlc_object_t *, input_item_t *, const char * ); input_thread_t *__input_CreateThreadExtended ( vlc_object_t *, input_item_t *, const char *, sout_instance_t * );
void input_DestroyThreadExtended( input_thread_t *p_input, sout_instance_t ** );
/* var.c */ /* var.c */
void input_ControlVarInit ( input_thread_t * ); void input_ControlVarInit ( input_thread_t * );
......
...@@ -1140,14 +1140,13 @@ int vlm_MediaSetup( vlm_t *vlm, vlm_media_t *media, const char *psz_cmd, ...@@ -1140,14 +1140,13 @@ int vlm_MediaSetup( vlm_t *vlm, vlm_media_t *media, const char *psz_cmd,
asprintf( &psz_header, _("Media: %s"), media->psz_name ); asprintf( &psz_header, _("Media: %s"), media->psz_name );
if( (p_input = input_CreateThread2( vlm, &media->item, psz_header if( (p_input = input_CreateThreadExtended( vlm, &media->item, psz_header, NULL ) ) )
) ) )
{ {
while( !p_input->b_eof && !p_input->b_error ) while( !p_input->b_eof && !p_input->b_error )
msleep( 100000 ); msleep( 100000 );
input_StopThread( p_input ); input_StopThread( p_input );
input_DestroyThread( p_input ); input_DestroyThreadExtended( p_input, NULL );
} }
free( psz_output ); free( psz_output );
free( psz_header ); free( psz_header );
...@@ -1242,12 +1241,11 @@ int vlm_MediaControl( vlm_t *vlm, vlm_media_t *media, const char *psz_id, ...@@ -1242,12 +1241,11 @@ int vlm_MediaControl( vlm_t *vlm, vlm_media_t *media, const char *psz_id,
if( p_instance->p_input ) if( p_instance->p_input )
{ {
input_StopThread( p_instance->p_input ); input_StopThread( p_instance->p_input );
input_DestroyThread( p_instance->p_input ); input_DestroyThreadExtended( p_instance->p_input, NULL );
} }
asprintf( &psz_header, _("Media: %s"), media->psz_name ); asprintf( &psz_header, _("Media: %s"), media->psz_name );
p_instance->p_input = input_CreateThread2( vlm, &p_instance->item, p_instance->p_input = input_CreateThreadExtended( vlm, &p_instance->item, psz_header, NULL );
psz_header );
if( !p_instance->p_input ) if( !p_instance->p_input )
{ {
TAB_REMOVE( media->i_instance, media->instance, p_instance ); TAB_REMOVE( media->i_instance, media->instance, p_instance );
...@@ -1361,7 +1359,7 @@ int vlm_MediaControl( vlm_t *vlm, vlm_media_t *media, const char *psz_id, ...@@ -1361,7 +1359,7 @@ int vlm_MediaControl( vlm_t *vlm, vlm_media_t *media, const char *psz_id,
if( p_instance->p_input ) if( p_instance->p_input )
{ {
input_StopThread( p_instance->p_input ); input_StopThread( p_instance->p_input );
input_DestroyThread( p_instance->p_input ); input_DestroyThreadExtended( p_instance->p_input, NULL );
} }
input_ItemClean( &p_instance->item ); input_ItemClean( &p_instance->item );
...@@ -2502,7 +2500,7 @@ static int Manage( vlc_object_t* p_object ) ...@@ -2502,7 +2500,7 @@ static int Manage( vlc_object_t* p_object )
char buffer[12]; char buffer[12];
input_StopThread( p_instance->p_input ); input_StopThread( p_instance->p_input );
input_DestroyThread( p_instance->p_input ); input_DestroyThreadExtended( p_instance->p_input, NULL );
p_instance->p_input = NULL; p_instance->p_input = NULL;
/* FIXME, find a way to select the right instance */ /* FIXME, find a way to select the right instance */
......
...@@ -210,6 +210,8 @@ static void ObjectGarbageCollector( playlist_t *p_playlist ) ...@@ -210,6 +210,8 @@ static void ObjectGarbageCollector( playlist_t *p_playlist )
vlc_object_release( p_obj ); vlc_object_release( p_obj );
break; break;
} }
msg_Dbg( p_playlist, "garbage collector destroying 1 sout" );
vlc_object_detach( p_obj );
vlc_object_release( p_obj ); vlc_object_release( p_obj );
sout_DeleteInstance( (sout_instance_t*)p_obj ); sout_DeleteInstance( (sout_instance_t*)p_obj );
} }
...@@ -409,6 +411,7 @@ void playlist_LastLoop( playlist_t *p_playlist ) ...@@ -409,6 +411,7 @@ void playlist_LastLoop( playlist_t *p_playlist )
while( ( p_obj = vlc_object_find( p_playlist, while( ( p_obj = vlc_object_find( p_playlist,
VLC_OBJECT_SOUT, FIND_CHILD ) ) ) VLC_OBJECT_SOUT, FIND_CHILD ) ) )
{ {
vlc_object_detach( p_obj );
vlc_object_release( p_obj ); vlc_object_release( p_obj );
sout_DeleteInstance( (sout_instance_t*)p_obj ); sout_DeleteInstance( (sout_instance_t*)p_obj );
} }
......
...@@ -73,45 +73,6 @@ static void mrl_Clean( mrl_t *p_mrl ); ...@@ -73,45 +73,6 @@ static void mrl_Clean( mrl_t *p_mrl );
sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest ) sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest )
{ {
sout_instance_t *p_sout; sout_instance_t *p_sout;
vlc_value_t keep;
if( var_Get( p_parent, "sout-keep", &keep ) >= 0 && keep.b_bool )
{
/* Remove the sout from the playlist garbage collector */
playlist_t *p_playlist = pl_Yield( p_parent );
vlc_mutex_lock( &p_playlist->gc_lock );
p_sout = vlc_object_find( p_playlist, VLC_OBJECT_SOUT, FIND_CHILD );
if( p_sout && p_sout->p_parent != (vlc_object_t *)p_playlist )
{
vlc_object_release( p_sout );
p_sout = NULL;
}
if( p_sout )
vlc_object_detach( p_sout ); /* Remove it from the GC */
vlc_mutex_unlock( &p_playlist->gc_lock );
pl_Release( p_parent );
/* */
if( p_sout )
{
if( !strcmp( p_sout->psz_sout, psz_dest ) )
{
msg_Dbg( p_parent, "sout keep: reusing sout" );
msg_Dbg( p_parent, "sout keep: you probably want to use "
"gather stream_out" );
vlc_object_attach( p_sout, p_parent );
vlc_object_release( p_sout );
return p_sout;
}
msg_Dbg( p_parent, "sout keep: destroying unusable sout" );
vlc_object_release( p_sout );
sout_DeleteInstance( p_sout );
}
}
/* *** Allocate descriptor *** */ /* *** Allocate descriptor *** */
p_sout = vlc_object_create( p_parent, VLC_OBJECT_SOUT ); p_sout = vlc_object_create( p_parent, VLC_OBJECT_SOUT );
...@@ -164,9 +125,6 @@ sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest ) ...@@ -164,9 +125,6 @@ sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest )
*****************************************************************************/ *****************************************************************************/
void sout_DeleteInstance( sout_instance_t * p_sout ) void sout_DeleteInstance( sout_instance_t * p_sout )
{ {
/* Unlink object */
vlc_object_detach( p_sout );
/* remove the stream out chain */ /* remove the stream out chain */
sout_StreamDelete( p_sout->p_stream ); sout_StreamDelete( p_sout->p_stream );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment