Commit db602ee3 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Forward port of [17351]. Report input error condition to JavaScript

parent 7cc05363
......@@ -314,7 +314,8 @@ enum input_state_e
BUFFERING_S,
PLAYING_S,
PAUSE_S,
END_S
END_S,
ERROR_S
};
/* "rate" default, min/max
......
......@@ -215,9 +215,9 @@ int libvlc_input_get_state( libvlc_input_t *p_input,
input_thread_t *p_input_thread;
vlc_value_t val;
p_input_thread = libvlc_get_input_thread ( p_input, p_e);
p_input_thread = libvlc_get_input_thread ( p_input, p_e );
if ( libvlc_exception_raised( p_e ) )
return 0;
return 6; /* Return ERROR_S (see include/vlc_input.c) */
var_Get( p_input_thread, "state", &val );
vlc_object_release( p_input_thread );
......
......@@ -270,7 +270,6 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent,
return __input_CreateThread2( p_parent, p_item, NULL );
}
/* Gruik ! */
input_thread_t *__input_CreateThread2( vlc_object_t *p_parent,
input_item_t *p_item,
......@@ -279,6 +278,9 @@ input_thread_t *__input_CreateThread2( vlc_object_t *p_parent,
input_thread_t *p_input = NULL; /* thread descriptor */
p_input = Create( p_parent, p_item, psz_header, VLC_FALSE );
if( !p_input )
return NULL;
/* Now we can attach our new input */
vlc_object_attach( p_input, p_parent );
......@@ -286,6 +288,7 @@ input_thread_t *__input_CreateThread2( vlc_object_t *p_parent,
if( vlc_thread_create( p_input, "input", Run,
VLC_THREAD_PRIORITY_INPUT, VLC_TRUE ) )
{
input_ChangeState( p_input, ERROR_S );
msg_Err( p_input, "cannot create input thread" );
vlc_object_detach( p_input );
vlc_object_destroy( p_input );
......@@ -295,7 +298,6 @@ input_thread_t *__input_CreateThread2( vlc_object_t *p_parent,
return p_input;
}
/**
* Initialize an input thread and run it. This thread will clean after himself,
* you can forget about it. It can work either in blocking or non-blocking mode
......@@ -311,6 +313,9 @@ int __input_Read( vlc_object_t *p_parent, input_item_t *p_item,
input_thread_t *p_input = NULL; /* thread descriptor */
p_input = Create( p_parent, p_item, NULL, VLC_FALSE );
if( !p_input )
return VLC_EGENERIC;
/* Now we can attach our new input */
vlc_object_attach( p_input, p_parent );
......@@ -324,6 +329,7 @@ int __input_Read( vlc_object_t *p_parent, input_item_t *p_item,
if( vlc_thread_create( p_input, "input", RunAndClean,
VLC_THREAD_PRIORITY_INPUT, VLC_TRUE ) )
{
input_ChangeState( p_input, ERROR_S );
msg_Err( p_input, "cannot create input thread" );
vlc_object_detach( p_input );
vlc_object_destroy( p_input );
......@@ -347,6 +353,9 @@ int __input_Preparse( vlc_object_t *p_parent, input_item_t *p_item )
/* Allocate descriptor */
p_input = Create( p_parent, p_item, NULL, VLC_TRUE );
if( !p_input )
return VLC_EGENERIC;
p_input->i_flags |= OBJECT_FLAGS_QUIET;
p_input->i_flags |= OBJECT_FLAGS_NOINTERACT;
......@@ -529,7 +538,6 @@ static int RunAndClean( input_thread_t *p_input )
return 0;
}
/*****************************************************************************
* Main loop: Fill buffers from access, and demux
*****************************************************************************/
......@@ -579,6 +587,7 @@ static void MainLoop( input_thread_t *p_input )
{
/* End of file - we do not set b_die because only the
* playlist is allowed to do so. */
input_ChangeState( p_input, END_S );
msg_Dbg( p_input, "EOF reached" );
p_input->input.b_eof = VLC_TRUE;
}
......@@ -698,7 +707,6 @@ static void MainLoop( input_thread_t *p_input )
}
}
static int Init( input_thread_t * p_input )
{
char *psz;
......@@ -754,6 +762,7 @@ static int Init( input_thread_t * p_input )
p_input->p_sout = sout_NewInstance( p_input, psz );
if( p_input->p_sout == NULL )
{
input_ChangeState( p_input, ERROR_S );
msg_Err( p_input, "cannot start stream output instance, " \
"aborting" );
free( psz );
......@@ -871,7 +880,6 @@ static int Init( input_thread_t * p_input )
p_input->i_stop = 0;
}
/* Load subtitles */
/* Get fps and set it if not already set */
if( !demux2_Control( p_input->input.p_demux, DEMUX_GET_FPS, &f_fps ) &&
......@@ -897,7 +905,6 @@ static int Init( input_thread_t * p_input )
var_SetTime( p_input, "spu-delay", (mtime_t)i_delay * 100000 );
}
/* Look for and add subtitle files */
psz_subtitle = var_GetString( p_input, "sub-file" );
if( *psz_subtitle )
......@@ -913,7 +920,6 @@ static int Init( input_thread_t * p_input )
char **subs = subtitles_Detect( p_input, psz_autopath,
p_input->input.p_item->psz_uri );
input_source_t *sub;
i = 0;
/* Try to autoselect the first autodetected subtitles file
......@@ -1087,11 +1093,13 @@ static int Init( input_thread_t * p_input )
}
/* initialization is complete */
input_ChangeState(p_input, PLAYING_S);
input_ChangeState( p_input, PLAYING_S );
return VLC_SUCCESS;
error:
input_ChangeState( p_input, ERROR_S );
if( p_input->p_es_out )
input_EsOutDelete( p_input->p_es_out );
......@@ -1118,6 +1126,7 @@ static void Error( input_thread_t *p_input )
while( !p_input->b_die )
{
/* Sleep a while */
input_ChangeState( p_input, ERROR_S );
msleep( INPUT_IDLE_SLEEP );
}
}
......@@ -1132,7 +1141,7 @@ static void End( input_thread_t * p_input )
msg_Dbg( p_input, "closing input" );
/* We are at the end */
input_ChangeState(p_input, END_S);
input_ChangeState( p_input, END_S );
/* Clean control variables */
input_ControlVarClean( p_input );
......@@ -1239,6 +1248,10 @@ static inline int ControlPopNoLock( input_thread_t *p_input,
static void ControlReduce( input_thread_t *p_input )
{
int i;
if( !p_input )
return;
for( i = 1; i < p_input->i_control; i++ )
{
const int i_lt = p_input->control[i-1].i_type;
......@@ -1920,6 +1933,7 @@ static int InputSourceInit( input_thread_t *p_input,
vlc_value_t val;
if( !in ) return VLC_EGENERIC;
if( !p_input ) return VLC_EGENERIC;
/* Split uri */
if( !p_input->b_preparsing )
......@@ -2009,7 +2023,7 @@ static int InputSourceInit( input_thread_t *p_input,
{
int64_t i_pts_delay;
input_ChangeState( p_input, OPENING_S);
input_ChangeState( p_input, OPENING_S );
/* Now try a real access */
in->p_access = access2_New( p_input, psz_access, psz_demux, psz_path,
......@@ -2107,7 +2121,7 @@ static int InputSourceInit( input_thread_t *p_input,
var_Set( p_input, "seekable", val );
}
input_ChangeState( p_input, BUFFERING_S);
input_ChangeState( p_input, BUFFERING_S );
/* Create the stream_t */
in->p_stream = stream_AccessNew( in->p_access, p_input->b_preparsing );
......@@ -2160,6 +2174,8 @@ static int InputSourceInit( input_thread_t *p_input,
return VLC_SUCCESS;
error:
input_ChangeState( p_input, ERROR_S );
if( in->p_demux )
demux2_Delete( in->p_demux );
......@@ -2255,6 +2271,8 @@ static void SlaveSeek( input_thread_t *p_input )
int64_t i_time;
int i;
if( !p_input ) return;
if( demux2_Control( p_input->input.p_demux, DEMUX_GET_TIME, &i_time ) )
{
msg_Err( p_input, "demux doesn't like DEMUX_GET_TIME" );
......@@ -2272,6 +2290,7 @@ static void SlaveSeek( input_thread_t *p_input )
}
}
}
/*****************************************************************************
* InputMetaUser:
*****************************************************************************/
......@@ -2301,7 +2320,6 @@ static void InputMetaUser( input_thread_t *p_input )
#undef GET_META
}
/*****************************************************************************
* MRLSplit: parse the access, demux and url part of the
* Media Resource Locator.
......@@ -2492,3 +2510,4 @@ vlc_bool_t input_AddSubtitles( input_thread_t *p_input, char *psz_subtitle,
return VLC_TRUE;
}
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