[vlc-commits] dec: lock spu channel registration

Thomas Guillem git at videolan.org
Tue Jun 25 20:55:11 CEST 2019


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Jun 25 08:16:08 2019 +0200| [28cf169a6f658b3f1dbacd8a759f8efa68e69b13] | committer: Thomas Guillem

dec: lock spu channel registration

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.

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

 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... */



More information about the vlc-commits mailing list