#include <vlc_charset.h>
#include <vlc_fs.h>
#include <vlc_strings.h>
+#include <vlc_modules.h>
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
input_ControlPush( p_input, INPUT_CONTROL_SET_DIE, NULL );
}
-input_resource_t *input_DetachResource( input_thread_t *p_input )
-{
- assert( p_input->b_dead );
-
- input_resource_SetInput( p_input->p->p_resource, NULL );
-
- input_resource_t *p_resource = input_resource_Detach( p_input->p->p_resource );
- p_input->p->p_sout = NULL;
-
- return p_resource;
-}
-
/**
* Get the item from an input thread
* FIXME it does not increase ref count of the item.
/* */
if( p_resource )
- p_input->p->p_resource = p_resource;
+ {
+ p_input->p->p_resource_private = NULL;
+ p_input->p->p_resource = input_resource_Hold( p_resource );
+ }
else
- p_input->p->p_resource = input_resource_New();
+ {
+ p_input->p->p_resource_private = input_resource_New( VLC_OBJECT( p_input ) );
+ p_input->p->p_resource = input_resource_Hold( p_input->p->p_resource_private );
+ }
input_resource_SetInput( p_input->p->p_resource, p_input );
/* Init control buffer */
es_out_Delete( p_input->p->p_es_out_display );
if( p_input->p->p_resource )
- input_resource_Delete( p_input->p->p_resource );
+ input_resource_Release( p_input->p->p_resource );
+ if( p_input->p->p_resource_private )
+ input_resource_Release( p_input->p->p_resource_private );
vlc_gc_decref( p_input->p->p_item );
static void InitPrograms( input_thread_t * p_input )
{
int i_es_out_mode;
- vlc_value_t val;
+ vlc_list_t list;
/* Compute correct pts_delay */
UpdatePtsDelay( p_input );
i_es_out_mode = ES_OUT_MODE_AUTO;
if( p_input->p->p_sout )
{
+ char *prgms;
+
if( var_GetBool( p_input, "sout-all" ) )
{
i_es_out_mode = ES_OUT_MODE_ALL;
}
else
+ if( (prgms = var_GetNonEmptyString( p_input, "programs" )) != NULL )
{
- var_Get( p_input, "programs", &val );
- if( val.p_list && val.p_list->i_count )
+ char *buf;
+
+ TAB_INIT( list.i_count, list.p_values );
+ for( const char *prgm = strtok_r( prgms, ",", &buf );
+ prgm != NULL;
+ prgm = strtok_r( NULL, ",", &buf ) )
{
+ vlc_value_t val = { .i_int = atoi( prgm ) };
+ INSERT_ELEM( list.p_values, list.i_count, list.i_count, val );
+ }
+
+ if( list.i_count > 0 )
i_es_out_mode = ES_OUT_MODE_PARTIAL;
/* Note : we should remove the "program" callback. */
- }
- else
- {
- var_FreeList( &val, NULL );
- }
+
+ free( prgms );
}
}
es_out_SetMode( p_input->p->p_es_out, i_es_out_mode );
else if( i_es_out_mode == ES_OUT_MODE_PARTIAL )
{
demux_Control( p_input->p->input.p_demux, DEMUX_SET_GROUP, -1,
- val.p_list );
+ &list );
+ TAB_CLEAN( list.i_count, list.p_values );
}
else
{
demux_Control( p_input->p->input.p_demux, DEMUX_SET_GROUP,
- (int) var_GetInteger( p_input, "program" ), NULL );
+ es_out_GetGroupForced( p_input->p->p_es_out ), NULL );
}
}
input_resource_RequestSout( p_input->p->p_resource,
p_input->p->p_sout, NULL );
input_resource_SetInput( p_input->p->p_resource, NULL );
+ if( p_input->p->p_resource_private )
+ input_resource_Terminate( p_input->p->p_resource_private );
}
if( !p_input->b_preparsing && libvlc_stats( p_input ) )
input_resource_RequestSout( p_input->p->p_resource,
p_input->p->p_sout, NULL );
input_resource_SetInput( p_input->p->p_resource, NULL );
+ if( p_input->p->p_resource_private )
+ input_resource_Terminate( p_input->p->p_resource_private );
}
/*****************************************************************************
if( bookmark.i_time_offset < 0 && bookmark.i_byte_offset < 0 )
{
- msg_Err( p_input, "invalid bookmark %d", val.i_int );
+ msg_Err( p_input, "invalid bookmark %"PRId64, val.i_int );
break;
}
free( psz_path );
}
+ char *url = make_URI( psz_subtitle, "file" );
+
var_Change( p_input, "spu-es", VLC_VAR_CHOICESCOUNT, &count, NULL );
sub = InputSourceNew( p_input );
- if( !sub || InputSourceInit( p_input, sub, psz_subtitle, "subtitle" ) )
+ if( !sub || !url
+ || InputSourceInit( p_input, sub, url, "subtitle" ) )
{
free( sub );
+ free( url );
return;
}
+ free( url );
TAB_APPEND( p_input->p->i_slave, p_input->p->slave, sub );
/* Select the ES */