Commit 998746af authored by Laurent Aimar's avatar Laurent Aimar

Used vlc_clone() in src/input/stream_demux.c

parent 083b7bcd
...@@ -46,13 +46,14 @@ struct stream_sys_t ...@@ -46,13 +46,14 @@ struct stream_sys_t
es_out_t *out; es_out_t *out;
demux_t *p_demux; demux_t *p_demux;
vlc_thread_t thread;
}; };
static int DStreamRead ( stream_t *, void *p_read, unsigned int i_read ); static int DStreamRead ( stream_t *, void *p_read, unsigned int i_read );
static int DStreamPeek ( stream_t *, const uint8_t **pp_peek, unsigned int i_peek ); static int DStreamPeek ( stream_t *, const uint8_t **pp_peek, unsigned int i_peek );
static int DStreamControl( stream_t *, int i_query, va_list ); static int DStreamControl( stream_t *, int i_query, va_list );
static void DStreamDelete ( stream_t * ); static void DStreamDelete ( stream_t * );
static void* DStreamThread ( vlc_object_t * ); static void* DStreamThread ( void * );
stream_t *stream_DemuxNew( demux_t *p_demux, const char *psz_demux, es_out_t *out ) stream_t *stream_DemuxNew( demux_t *p_demux, const char *psz_demux, es_out_t *out )
...@@ -96,7 +97,7 @@ stream_t *stream_DemuxNew( demux_t *p_demux, const char *psz_demux, es_out_t *ou ...@@ -96,7 +97,7 @@ stream_t *stream_DemuxNew( demux_t *p_demux, const char *psz_demux, es_out_t *ou
vlc_object_attach( s, p_obj ); vlc_object_attach( s, p_obj );
if( vlc_thread_create( s, DStreamThread, VLC_THREAD_PRIORITY_INPUT ) ) if( vlc_clone( &p_sys->thread, DStreamThread, s, VLC_THREAD_PRIORITY_INPUT ) )
{ {
stream_CommonDelete( s ); stream_CommonDelete( s );
free( p_sys->psz_name ); free( p_sys->psz_name );
...@@ -124,7 +125,7 @@ static void DStreamDelete( stream_t *s ) ...@@ -124,7 +125,7 @@ static void DStreamDelete( stream_t *s )
vlc_object_kill( p_sys->p_demux ); vlc_object_kill( p_sys->p_demux );
p_empty = block_New( s, 1 ); p_empty->i_buffer = 0; p_empty = block_New( s, 1 ); p_empty->i_buffer = 0;
block_FifoPut( p_sys->p_fifo, p_empty ); block_FifoPut( p_sys->p_fifo, p_empty );
vlc_thread_join( s ); vlc_join( p_sys->thread, NULL );
if( p_sys->p_demux ) if( p_sys->p_demux )
demux_Delete( p_sys->p_demux ); demux_Delete( p_sys->p_demux );
...@@ -146,7 +147,7 @@ static int DStreamRead( stream_t *s, void *p_read, unsigned int i_read ) ...@@ -146,7 +147,7 @@ static int DStreamRead( stream_t *s, void *p_read, unsigned int i_read )
//msg_Dbg( s, "DStreamRead: wanted %d bytes", i_read ); //msg_Dbg( s, "DStreamRead: wanted %d bytes", i_read );
while( !s->b_die && !s->b_error && i_read ) while( vlc_object_alive( s ) && !s->b_error && i_read )
{ {
block_t *p_block = p_sys->p_block; block_t *p_block = p_sys->p_block;
int i_copy; int i_copy;
...@@ -189,7 +190,7 @@ static int DStreamPeek( stream_t *s, const uint8_t **pp_peek, unsigned int i_pee ...@@ -189,7 +190,7 @@ static int DStreamPeek( stream_t *s, const uint8_t **pp_peek, unsigned int i_pee
//msg_Dbg( s, "DStreamPeek: wanted %d bytes", i_peek ); //msg_Dbg( s, "DStreamPeek: wanted %d bytes", i_peek );
while( !s->b_die && !s->b_error && i_peek ) while( vlc_object_alive( s ) && !s->b_error && i_peek )
{ {
int i_copy; int i_copy;
...@@ -274,9 +275,9 @@ static int DStreamControl( stream_t *s, int i_query, va_list args ) ...@@ -274,9 +275,9 @@ static int DStreamControl( stream_t *s, int i_query, va_list args )
} }
} }
static void* DStreamThread( vlc_object_t* p_this ) static void* DStreamThread( void *obj )
{ {
stream_t *s = (stream_t *)p_this; stream_t *s = (stream_t *)obj;
stream_sys_t *p_sys = s->p_sys; stream_sys_t *p_sys = s->p_sys;
demux_t *p_demux; demux_t *p_demux;
int canc = vlc_savecancel(); int canc = vlc_savecancel();
...@@ -294,7 +295,7 @@ static void* DStreamThread( vlc_object_t* p_this ) ...@@ -294,7 +295,7 @@ static void* DStreamThread( vlc_object_t* p_this )
p_sys->p_demux = p_demux; p_sys->p_demux = p_demux;
/* Main loop */ /* Main loop */
while( !s->b_die && !p_demux->b_die ) while( vlc_object_alive( s ) && vlc_object_alive( p_demux ) )
{ {
if( demux_Demux( p_demux ) <= 0 ) break; if( demux_Demux( p_demux ) <= 0 ) break;
} }
......
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