[vlc-commits] [Git][videolan/vlc][3.0.x] 2 commits: transcode: fix destructive assignment after drain

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Jun 28 06:51:16 UTC 2024



Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC


Commits:
7df61e3e by Alaric Senat at 2024-06-24T18:12:54+02:00
transcode: fix destructive assignment after drain

The drain checks are done after the first encoder output fetch. At this
point, `out` is already filled with some frames gotten from the encoder
some lines above:

```
// ...
    if( p_sys->i_threads >= 1 )
    {
        /* Pick up any return data the encoder thread wants to output. */
        vlc_mutex_lock( &p_sys->lock_out );
        *out = p_sys->p_buffers;
        p_sys->p_buffers = NULL;
        vlc_mutex_unlock( &p_sys->lock_out );
    }

// ...
```

This assignment currently leaks all previously gathered frames to
replace them by the drained output. This patch appends the drained
frames to the existing output instead.

- - - - -
a203e5da by Alaric Senat at 2024-06-24T18:12:54+02:00
transcode: fix picture fifo leak

Draining sets the abort flag. It was skipping the picture fifo deletion
before.

- - - - -


1 changed file:

- modules/stream_out/transcode/video.c


Changes:

=====================================
modules/stream_out/transcode/video.c
=====================================
@@ -658,17 +658,20 @@ static int transcode_video_encoder_open( sout_stream_t *p_stream,
 void transcode_video_close( sout_stream_t *p_stream,
                                    sout_stream_id_sys_t *id )
 {
-    if( p_stream->p_sys->i_threads >= 1 && !p_stream->p_sys->b_abort )
+    if( p_stream->p_sys->i_threads >= 1 )
     {
-        vlc_mutex_lock( &p_stream->p_sys->lock_out );
-        p_stream->p_sys->b_abort = true;
-        vlc_cond_signal( &p_stream->p_sys->cond );
-        vlc_mutex_unlock( &p_stream->p_sys->lock_out );
+        if (!p_stream->p_sys->b_abort)
+        {
+            vlc_mutex_lock( &p_stream->p_sys->lock_out );
+            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_join( p_stream->p_sys->thread, NULL );
+            vlc_join( p_stream->p_sys->thread, NULL );
+            block_ChainRelease( p_stream->p_sys->p_buffers );
+        }
 
         picture_fifo_Delete( p_stream->p_sys->pp_pics );
-        block_ChainRelease( p_stream->p_sys->p_buffers );
     }
 
     if( p_stream->p_sys->i_threads >= 1 )
@@ -906,7 +909,7 @@ end:
 
             vlc_join( p_stream->p_sys->thread, NULL );
             vlc_mutex_lock( &p_sys->lock_out );
-            *out = p_sys->p_buffers;
+            block_ChainAppend(out, p_sys->p_buffers);
             p_sys->p_buffers = NULL;
             vlc_mutex_unlock( &p_sys->lock_out );
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ac310b4b193bd86b741308393aa8d8833a1075ae...a203e5da7486e3ed6435bd3921d71820398b660b

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ac310b4b193bd86b741308393aa8d8833a1075ae...a203e5da7486e3ed6435bd3921d71820398b660b
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list