Skip to content

Commit e350259

Browse files
committed
transcode: simplify thread init
1 parent ead2838 commit e350259

File tree

1 file changed

+28
-30
lines changed
  • modules/stream_out/transcode

1 file changed

+28
-30
lines changed

modules/stream_out/transcode/video.c

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -212,37 +212,35 @@ int transcode_video_new( sout_stream_t *p_stream, sout_stream_id_sys_t *id )
212212
}
213213
id->p_encoder->p_module = NULL;
214214

215-
if( p_sys->i_threads >= 1 )
215+
if( p_sys->i_threads <= 0 )
216+
return VLC_SUCCESS;
217+
218+
int i_priority = p_sys->b_high_priority ? VLC_THREAD_PRIORITY_OUTPUT :
219+
VLC_THREAD_PRIORITY_VIDEO;
220+
p_sys->id_video = id;
221+
p_sys->pp_pics = picture_fifo_New();
222+
if( p_sys->pp_pics == NULL )
216223
{
217-
int i_priority = p_sys->b_high_priority ? VLC_THREAD_PRIORITY_OUTPUT :
218-
VLC_THREAD_PRIORITY_VIDEO;
219-
p_sys->id_video = id;
220-
vlc_mutex_init( &p_sys->lock_out );
221-
vlc_cond_init( &p_sys->cond );
222-
p_sys->pp_pics = picture_fifo_New();
223-
if( p_sys->pp_pics == NULL )
224-
{
225-
msg_Err( p_stream, "cannot create picture fifo" );
226-
vlc_mutex_destroy( &p_sys->lock_out );
227-
vlc_cond_destroy( &p_sys->cond );
228-
module_unneed( id->p_decoder, id->p_decoder->p_module );
229-
id->p_decoder->p_module = NULL;
230-
free( id->p_decoder->p_owner );
231-
return VLC_ENOMEM;
232-
}
233-
p_sys->p_buffers = NULL;
234-
p_sys->b_abort = false;
235-
if( vlc_clone( &p_sys->thread, EncoderThread, p_sys, i_priority ) )
236-
{
237-
msg_Err( p_stream, "cannot spawn encoder thread" );
238-
vlc_mutex_destroy( &p_sys->lock_out );
239-
vlc_cond_destroy( &p_sys->cond );
240-
picture_fifo_Delete( p_sys->pp_pics );
241-
module_unneed( id->p_decoder, id->p_decoder->p_module );
242-
id->p_decoder->p_module = NULL;
243-
free( id->p_decoder->p_owner );
244-
return VLC_EGENERIC;
245-
}
224+
msg_Err( p_stream, "cannot create picture fifo" );
225+
module_unneed( id->p_decoder, id->p_decoder->p_module );
226+
id->p_decoder->p_module = NULL;
227+
free( id->p_decoder->p_owner );
228+
return VLC_ENOMEM;
229+
}
230+
vlc_mutex_init( &p_sys->lock_out );
231+
vlc_cond_init( &p_sys->cond );
232+
p_sys->p_buffers = NULL;
233+
p_sys->b_abort = false;
234+
if( vlc_clone( &p_sys->thread, EncoderThread, p_sys, i_priority ) )
235+
{
236+
msg_Err( p_stream, "cannot spawn encoder thread" );
237+
vlc_mutex_destroy( &p_sys->lock_out );
238+
vlc_cond_destroy( &p_sys->cond );
239+
picture_fifo_Delete( p_sys->pp_pics );
240+
module_unneed( id->p_decoder, id->p_decoder->p_module );
241+
id->p_decoder->p_module = NULL;
242+
free( id->p_decoder->p_owner );
243+
return VLC_EGENERIC;
246244
}
247245
return VLC_SUCCESS;
248246
}

0 commit comments

Comments
 (0)