[vlc-devel] [PATCH] dec: lock spu channel registration

Thomas Guillem thomas at gllm.fr
Tue Jun 25 08:23:22 CEST 2019


The spu channel must be registered/unregistered within the same lock of the
vout since we assume that a valid vout means a valid spu channel (for SPU_ES).

This didn't fixes any races since there is no async SPU decoders.
---
 src/input/decoder.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 89d68830a8..160150b671 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -610,12 +610,12 @@ static subpicture_t *spu_new_buffer( decoder_t *p_dec,
         msg_Warn( p_dec, "no vout found, dropping subpicture" );
         if( p_owner->p_vout )
         {
+            vlc_mutex_lock( &p_owner->lock );
             assert(p_owner->i_spu_channel != VOUT_SPU_CHANNEL_INVALID);
             vout_UnregisterSubpictureChannel(p_owner->p_vout,
                                              p_owner->i_spu_channel);
             p_owner->i_spu_channel = VOUT_SPU_CHANNEL_INVALID;
 
-            vlc_mutex_lock( &p_owner->lock );
             vout_Release(p_owner->p_vout);
             p_owner->p_vout = NULL;
             vlc_mutex_unlock( &p_owner->lock );
@@ -625,23 +625,21 @@ static subpicture_t *spu_new_buffer( decoder_t *p_dec,
 
     if( p_owner->p_vout != p_vout )
     {
+        vlc_mutex_lock(&p_owner->lock);
+
         if (p_owner->p_vout)
         {
             /* Unregister the SPU channel of the previous vout */
             assert(p_owner->i_spu_channel != VOUT_SPU_CHANNEL_INVALID);
             vout_UnregisterSubpictureChannel(p_owner->p_vout,
                                              p_owner->i_spu_channel);
+            vout_Release(p_owner->p_vout);
         }
 
         p_owner->i_spu_channel =
             vout_RegisterSubpictureChannelInternal(p_vout, p_owner->p_clock);
         p_owner->i_spu_order = 0;
 
-        vlc_mutex_lock(&p_owner->lock);
-        /* Release the previous vout */
-        if (p_owner->p_vout)
-            vout_Release(p_owner->p_vout);
-
         if (p_owner->i_spu_channel == VOUT_SPU_CHANNEL_INVALID)
         {
             /* The new vout doesn't support SPU, aborting... */
-- 
2.20.1



More information about the vlc-devel mailing list