[vlc-commits] transcode: simplify thread init

Rafaël Carré git at videolan.org
Tue Jan 6 13:47:52 CET 2015


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Tue Jan  6 13:42:06 2015 +0100| [e350259a5f43aa6a85814901b97316fbd69f7f1d] | committer: Rafaël Carré

transcode: simplify thread init

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e350259a5f43aa6a85814901b97316fbd69f7f1d
---

 modules/stream_out/transcode/video.c |   58 ++++++++++++++++------------------
 1 file changed, 28 insertions(+), 30 deletions(-)

diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index 39f5b8b..949a23f 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -212,37 +212,35 @@ int transcode_video_new( sout_stream_t *p_stream, sout_stream_id_sys_t *id )
     }
     id->p_encoder->p_module = NULL;
 
-    if( p_sys->i_threads >= 1 )
+    if( p_sys->i_threads <= 0 )
+        return VLC_SUCCESS;
+
+    int i_priority = p_sys->b_high_priority ? VLC_THREAD_PRIORITY_OUTPUT :
+                       VLC_THREAD_PRIORITY_VIDEO;
+    p_sys->id_video = id;
+    p_sys->pp_pics = picture_fifo_New();
+    if( p_sys->pp_pics == NULL )
     {
-        int i_priority = p_sys->b_high_priority ? VLC_THREAD_PRIORITY_OUTPUT :
-                           VLC_THREAD_PRIORITY_VIDEO;
-        p_sys->id_video = id;
-        vlc_mutex_init( &p_sys->lock_out );
-        vlc_cond_init( &p_sys->cond );
-        p_sys->pp_pics = picture_fifo_New();
-        if( p_sys->pp_pics == NULL )
-        {
-            msg_Err( p_stream, "cannot create picture fifo" );
-            vlc_mutex_destroy( &p_sys->lock_out );
-            vlc_cond_destroy( &p_sys->cond );
-            module_unneed( id->p_decoder, id->p_decoder->p_module );
-            id->p_decoder->p_module = NULL;
-            free( id->p_decoder->p_owner );
-            return VLC_ENOMEM;
-        }
-        p_sys->p_buffers = NULL;
-        p_sys->b_abort = false;
-        if( vlc_clone( &p_sys->thread, EncoderThread, p_sys, i_priority ) )
-        {
-            msg_Err( p_stream, "cannot spawn encoder thread" );
-            vlc_mutex_destroy( &p_sys->lock_out );
-            vlc_cond_destroy( &p_sys->cond );
-            picture_fifo_Delete( p_sys->pp_pics );
-            module_unneed( id->p_decoder, id->p_decoder->p_module );
-            id->p_decoder->p_module = NULL;
-            free( id->p_decoder->p_owner );
-            return VLC_EGENERIC;
-        }
+        msg_Err( p_stream, "cannot create picture fifo" );
+        module_unneed( id->p_decoder, id->p_decoder->p_module );
+        id->p_decoder->p_module = NULL;
+        free( id->p_decoder->p_owner );
+        return VLC_ENOMEM;
+    }
+    vlc_mutex_init( &p_sys->lock_out );
+    vlc_cond_init( &p_sys->cond );
+    p_sys->p_buffers = NULL;
+    p_sys->b_abort = false;
+    if( vlc_clone( &p_sys->thread, EncoderThread, p_sys, i_priority ) )
+    {
+        msg_Err( p_stream, "cannot spawn encoder thread" );
+        vlc_mutex_destroy( &p_sys->lock_out );
+        vlc_cond_destroy( &p_sys->cond );
+        picture_fifo_Delete( p_sys->pp_pics );
+        module_unneed( id->p_decoder, id->p_decoder->p_module );
+        id->p_decoder->p_module = NULL;
+        free( id->p_decoder->p_owner );
+        return VLC_EGENERIC;
     }
     return VLC_SUCCESS;
 }



More information about the vlc-commits mailing list