Commit d7dc1dec authored by Laurent Aimar's avatar Laurent Aimar

Converted transcode to vlc_clone().

parent f2dda725
......@@ -253,15 +253,12 @@ static int Open( vlc_object_t *p_this )
sout_stream_sys_t *p_sys;
char *psz_string;
p_sys = vlc_object_create( p_this, sizeof( sout_stream_sys_t ) );
if( !p_stream->p_next )
{
msg_Err( p_stream, "cannot create chain" );
vlc_object_release( p_sys );
return VLC_EGENERIC;
}
p_sys = calloc( 1, sizeof( *p_sys ) );
p_sys->i_master_drift = 0;
config_ChainParse( p_stream, SOUT_CFG_PREFIX, ppsz_sout_options,
......@@ -507,7 +504,7 @@ static void Close( vlc_object_t * p_this )
config_ChainDestroy( p_sys->p_osd_cfg );
free( p_sys->psz_osdenc );
vlc_object_release( p_sys );
free( p_sys );
}
static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
......
......@@ -17,14 +17,14 @@
struct sout_stream_sys_t
{
VLC_COMMON_MEMBERS
sout_stream_id_t *id_video;
block_t *p_buffers;
vlc_mutex_t lock_out;
vlc_cond_t cond;
bool b_abort;
picture_t * pp_pics[PICTURE_RING_SIZE];
int i_first_pic, i_last_pic;
vlc_thread_t thread;
/* Audio */
vlc_fourcc_t i_acodec; /* codec audio (0 if not transcode) */
......
......@@ -125,24 +125,22 @@ static void transcode_video_filter_allocation_clear( filter_t *p_filter )
VLC_UNUSED(p_filter);
}
static void* EncoderThread( vlc_object_t* p_this )
static void* EncoderThread( void *obj )
{
sout_stream_sys_t *p_sys = (sout_stream_sys_t*)p_this;
sout_stream_sys_t *p_sys = (sout_stream_sys_t*)obj;
sout_stream_id_t *id = p_sys->id_video;
picture_t *p_pic;
int canc = vlc_savecancel ();
while( vlc_object_alive (p_sys) )
for( ;; )
{
block_t *p_block;
vlc_mutex_lock( &p_sys->lock_out );
while( p_sys->i_last_pic == p_sys->i_first_pic )
{
while( !p_sys->b_abort && p_sys->i_last_pic == p_sys->i_first_pic )
vlc_cond_wait( &p_sys->cond, &p_sys->lock_out );
if( !vlc_object_alive (p_sys) ) break;
}
if( !vlc_object_alive (p_sys) )
if( p_sys->b_abort )
{
vlc_mutex_unlock( &p_sys->lock_out );
break;
......@@ -274,8 +272,8 @@ int transcode_video_new( sout_stream_t *p_stream, sout_stream_id_t *id )
p_sys->i_first_pic = 0;
p_sys->i_last_pic = 0;
p_sys->p_buffers = NULL;
p_sys->b_die = 0;
if( vlc_thread_create( p_sys, EncoderThread, i_priority ) )
p_sys->b_abort = 0;
if( vlc_clone( &p_sys->thread, EncoderThread, p_sys, i_priority ) )
{
msg_Err( p_stream, "cannot spawn encoder thread" );
module_unneed( id->p_decoder, id->p_decoder->p_module );
......@@ -564,10 +562,11 @@ void transcode_video_close( sout_stream_t *p_stream,
if( p_stream->p_sys->i_threads >= 1 )
{
vlc_mutex_lock( &p_stream->p_sys->lock_out );
vlc_object_kill( p_stream->p_sys );
p_stream->p_sys->b_abort = true;
vlc_cond_signal( &p_stream->p_sys->cond );
vlc_mutex_unlock( &p_stream->p_sys->lock_out );
vlc_thread_join( p_stream->p_sys );
vlc_join( p_stream->p_sys->thread, NULL );
vlc_mutex_destroy( &p_stream->p_sys->lock_out );
vlc_cond_destroy( &p_stream->p_sys->cond );
}
......
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