*****************************************************************************/
static void Destructor( input_thread_t * p_input );
-static int Run ( input_thread_t *p_input );
-static int RunAndDestroy ( input_thread_t *p_input );
+static void* Run ( vlc_object_t *p_this );
+static void* RunAndDestroy ( vlc_object_t *p_this );
static input_thread_t * Create ( vlc_object_t *, input_item_t *,
const char *, bool, sout_instance_t * );
static int Init ( input_thread_t *p_input );
-static void Error ( input_thread_t *p_input );
+static void WaitDie ( input_thread_t *p_input );
static void End ( input_thread_t *p_input );
static void MainLoop( input_thread_t *p_input );
* - seekable (if you can seek, it doesn't say if 'bar display' has be shown
* or not, for that check position != 0.0)
* - can-pause
+ * - teletext-es to get the index of spu track that is teletext --1 if no teletext)
* * For intf callback upon changes
* - intf-change
* - rate-change for when playback rate changes
/* Parse input options */
vlc_mutex_lock( &p_item->lock );
- assert( p_item->optflagc == p_item->i_options );
+ assert( (int)p_item->optflagc == p_item->i_options );
for( i = 0; i < p_item->i_options; i++ )
var_OptionParse( VLC_OBJECT(p_input), p_item->ppsz_options[i],
!!(p_item->optflagv[i] & VLC_INPUT_OPTION_TRUSTED) );
if( b_block )
{
- RunAndDestroy( p_input );
+ RunAndDestroy( VLC_OBJECT(p_input) );
return VLC_SUCCESS;
}
else
* This is the "normal" thread that spawns the input processing chain,
* reads the stream, cleans up and waits
*****************************************************************************/
-static int Run( input_thread_t *p_input )
+static void* Run( vlc_object_t *p_this )
{
+ input_thread_t *p_input = (input_thread_t *)p_this;
/* Signal that the thread is launched */
vlc_thread_ready( p_input );
/* If we failed, wait before we are killed, and exit */
p_input->b_error = true;
- Error( p_input );
+ WaitDie( p_input );
/* Tell we're dead */
p_input->b_dead = true;
- return 0;
+ return NULL;
}
MainLoop( p_input );
/* Wait until we are asked to die */
if( !p_input->b_die )
{
- Error( p_input );
+ WaitDie( p_input );
}
/* Clean up */
End( p_input );
- return 0;
+ return NULL;
}
/*****************************************************************************
* This is the "just forget me" thread that spawns the input processing chain,
* reads the stream, cleans up and releases memory
*****************************************************************************/
-static int RunAndDestroy( input_thread_t *p_input )
+static void* RunAndDestroy( vlc_object_t *p_this )
{
+ input_thread_t *p_input = (input_thread_t *)p_this;
/* Signal that the thread is launched */
vlc_thread_ready( p_input );
}
/*****************************************************************************
- * Error: RunThread() error loop
+ * WaitDie: Wait until we are asked to die.
*****************************************************************************
* This function is called when an error occurred during thread main's loop.
*****************************************************************************/
-static void Error( input_thread_t *p_input )
+static void WaitDie( input_thread_t *p_input )
{
- input_ChangeState( p_input, ERROR_S );
+ input_ChangeState( p_input, p_input->b_error ? ERROR_S : END_S );
while( !p_input->b_die )
{
/* Sleep a while */
*****************************************************************************/
static input_source_t *InputSourceNew( input_thread_t *p_input )
{
+ (void)p_input;
input_source_t *in = (input_source_t*) malloc( sizeof( input_source_t ) );
if( in )
memset( in, 0, sizeof( input_source_t ) );
if( !p_input ) return VLC_EGENERIC;
/* Split uri */
- MRLSplit( psz_dup, &psz_access, &psz_demux, &psz_path );
+ input_SplitMRL( &psz_access, &psz_demux, &psz_path, psz_dup );
msg_Dbg( p_input, "`%s' gives access `%s' demux `%s' path `%s'",
psz_mrl, psz_access, psz_demux, psz_path );
{
const char *psz_a, *psz_d;
psz_buf = strdup( in->p_access->psz_path );
- MRLSplit( psz_buf, &psz_a, &psz_d, &psz_real_path );
+ input_SplitMRL( &psz_a, &psz_d, &psz_real_path, psz_buf );
}
else
{
* MRLSplit: parse the access, demux and url part of the
* Media Resource Locator.
*****************************************************************************/
-void MRLSplit( char *psz_dup, const char **ppsz_access, const char **ppsz_demux,
- char **ppsz_path )
+void input_SplitMRL( const char **ppsz_access, const char **ppsz_demux, char **ppsz_path,
+ char *psz_dup )
{
char *psz_access = NULL;
char *psz_demux = NULL;
{
psz_path = psz_dup;
}
+ *ppsz_access = psz_access ? psz_access : (char*)"";
+ *ppsz_demux = psz_demux ? psz_demux : (char*)"";
+ *ppsz_path = psz_path;
+}
- *ppsz_access = psz_access ? psz_access : "";
- *ppsz_demux = psz_demux ? psz_demux : "";
- *ppsz_path = psz_path ? psz_path : "";
+static inline bool next(char ** src)
+{
+ char *end;
+ errno = 0;
+ long result = strtol( *src, &end, 0 );
+ if( errno != 0 || result >= LONG_MAX || result <= LONG_MIN ||
+ end == *src )
+ {
+ return false;
+ }
+ *src = end;
+ return true;
}
/*****************************************************************************
/* Start by parsing titles and chapters */
if( !psz_source || !( psz = strrchr( psz_source, '@' ) ) ) return;
+
/* Check we are really dealing with a title/chapter section */
psz_check = psz + 1;
if( !*psz_check ) return;
- if( isdigit(*psz_check) ) strtol( psz_check, &psz_check, 0 );
+ if( isdigit(*psz_check) )
+ if(!next(&psz_check)) return;
if( *psz_check != ':' && *psz_check != '-' && *psz_check ) return;
if( *psz_check == ':' && ++psz_check )
- if( isdigit(*psz_check) ) strtol( psz_check, &psz_check, 0 );
+ {
+ if( isdigit(*psz_check) )
+ if(!next(&psz_check)) return;
+ }
if( *psz_check != '-' && *psz_check ) return;
if( *psz_check == '-' && ++psz_check )
- if( isdigit(*psz_check) ) strtol( psz_check, &psz_check, 0 );
+ {
+ if( isdigit(*psz_check) )
+ if(!next(&psz_check)) return;
+ }
if( *psz_check != ':' && *psz_check ) return;
if( *psz_check == ':' && ++psz_check )
- if( isdigit(*psz_check) ) strtol( psz_check, &psz_check, 0 );
+ {
+ if( isdigit(*psz_check) )
+ if(!next(&psz_check)) return;
+ }
if( *psz_check ) return;
/* Separate start and end */
/*****************************************************************************
* input_get_event_manager
*****************************************************************************/
-vlc_event_manager_t *
-input_get_event_manager( input_thread_t *p_input )
+vlc_event_manager_t *input_get_event_manager( input_thread_t *p_input )
{
return &p_input->p->event_manager;
}