[vlc-commits] Converted transcode to vlc_clone().
Laurent Aimar
git at videolan.org
Wed May 18 22:31:25 CEST 2011
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Wed May 18 21:56:04 2011 +0200| [d7dc1dec5cfeea2dfde81c833c2fbf425c950364] | committer: Laurent Aimar
Converted transcode to vlc_clone().
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d7dc1dec5cfeea2dfde81c833c2fbf425c950364
---
modules/stream_out/transcode/transcode.c | 7 ++-----
modules/stream_out/transcode/transcode.h | 4 ++--
modules/stream_out/transcode/video.c | 23 +++++++++++------------
3 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/modules/stream_out/transcode/transcode.c b/modules/stream_out/transcode/transcode.c
index dd9b152..6692b8b 100644
--- a/modules/stream_out/transcode/transcode.c
+++ b/modules/stream_out/transcode/transcode.c
@@ -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 )
diff --git a/modules/stream_out/transcode/transcode.h b/modules/stream_out/transcode/transcode.h
index 8e8db25..816413a 100644
--- a/modules/stream_out/transcode/transcode.h
+++ b/modules/stream_out/transcode/transcode.h
@@ -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) */
diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index b85b1a5..68b8d88 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -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 );
}
More information about the vlc-commits
mailing list