transcode: change error handling
authorThomas Guillem <thomas@gllm.fr>
Fri, 19 Jan 2018 07:31:53 +0000 (08:31 +0100)
committerThomas Guillem <thomas@gllm.fr>
Fri, 19 Jan 2018 07:33:56 +0000 (08:33 +0100)
Don't reset b_transcode to false in case of error, otherwise transcoding
resources won't be freed.

modules/stream_out/transcode/audio.c
modules/stream_out/transcode/transcode.c
modules/stream_out/transcode/transcode.h
modules/stream_out/transcode/video.c

index c60569a..c7ce848 100644 (file)
@@ -285,7 +285,7 @@ int transcode_audio_process( sout_stream_t *p_stream,
         p_audio_bufs = p_audio_bufs->p_next;
         p_audio_buf->p_next = NULL;
 
-        if( b_error )
+        if( id->b_error )
         {
             block_Release( p_audio_buf );
             continue;
@@ -312,7 +312,10 @@ int transcode_audio_process( sout_stream_t *p_stream,
             {
                 id->id = sout_StreamIdAdd( p_stream->p_next, &id->p_encoder->fmt_out );
                 if (!id->id)
-                    id->b_transcode = false;
+                {
+                    vlc_mutex_unlock(&id->fifo.lock);
+                    goto error;
+                }
             }
         }
 
@@ -365,10 +368,7 @@ int transcode_audio_process( sout_stream_t *p_stream,
         p_audio_buf = aout_FiltersPlay( id->p_af_chain, p_audio_buf,
                                         INPUT_RATE_DEFAULT );
         if( !p_audio_buf )
-        {
-            b_error = true;
-            continue;
-        }
+            goto error;
 
         p_audio_buf->i_dts = p_audio_buf->i_pts;
 
@@ -378,8 +378,9 @@ int transcode_audio_process( sout_stream_t *p_stream,
         block_Release( p_audio_buf );
         continue;
 error:
-        block_Release( p_audio_buf );
-        b_error = true;
+        if( p_audio_buf )
+            block_Release( p_audio_buf );
+        id->b_error = true;
     } while( p_audio_bufs );
 
 end:
index ced21cf..9cd403f 100644 (file)
@@ -586,6 +586,9 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
 {
     block_t *p_out = NULL;
 
+    if( id->b_error )
+        goto error;
+
     if( !id->b_transcode )
     {
         if( id->id )
index 144502a..3c76a3d 100644 (file)
@@ -75,6 +75,7 @@ struct aout_filters;
 struct sout_stream_id_sys_t
 {
     bool            b_transcode;
+    bool            b_error;
 
     /* id of the out stream */
     void *id;
index e26fc99..fbe7475 100644 (file)
@@ -61,9 +61,6 @@ static int video_update_format_decoder( decoder_t *p_dec )
         .sys = sys,
     };
 
-    if( !id->b_transcode )
-        return 0;
-
     if( id->p_encoder->fmt_in.i_codec == p_dec->fmt_out.i_codec ||
         video_format_IsSimilar( &id->video_dec_out,
                                 &p_dec->fmt_out.video ) )
@@ -434,7 +431,6 @@ static void transcode_video_framerate_init( sout_stream_t *p_stream,
         id->p_decoder->fmt_out.video.i_frame_rate_base,
         id->p_encoder->fmt_in.video.i_frame_rate,
         id->p_encoder->fmt_in.video.i_frame_rate_base );
-
 }
 
 static void transcode_video_size_init( sout_stream_t *p_stream,
@@ -782,7 +778,7 @@ int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
         p_pics = p_pics->p_next;
         p_pic->p_next = NULL;
 
-        if( b_error )
+        if( id->b_error )
         {
             picture_Release( p_pic );
             continue;
@@ -868,8 +864,7 @@ int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
 error:
         if( p_pic )
             picture_Release( p_pic );
-        id->b_transcode = false;
-        b_error = true;
+        id->b_error = true;
     } while( p_pics );
 
     if( p_sys->i_threads >= 1 )