[vlc-commits] rc: lock the player only once while processing commands

Thomas Guillem git at videolan.org
Tue May 28 19:27:11 CEST 2019


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue May 28 10:15:10 2019 +0200| [60220ade5614d1b619ef27977f30e87648ade298] | committer: Rémi Denis-Courmont

rc: lock the player only once while processing commands

And avoid racy states due to successive lock/unlock

Refs #22328

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

Conflicts:
	modules/control/rc.c

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

 modules/control/rc.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/modules/control/rc.c b/modules/control/rc.c
index 3971916eb1..4ec92712e8 100644
--- a/modules/control/rc.c
+++ b/modules/control/rc.c
@@ -1569,12 +1569,11 @@ static void *Run( void *data )
         b_complete = ReadCommand( p_intf, p_buffer, &i_size );
         canc = vlc_savecancel( );
 
+        vlc_player_Lock(player);
         /* Manage the input part */
         if( item == NULL )
         {
-            vlc_player_Lock(player);
             item = vlc_player_HoldCurrentMedia(player);
-            vlc_player_Unlock(player);
             /* New input has been registered */
             if( item )
             {
@@ -1584,7 +1583,6 @@ static void *Run( void *data )
             }
         }
 
-        vlc_player_Lock(player);
         if( !vlc_player_IsStarted( player ) )
         {
             if (item)
@@ -1596,13 +1594,10 @@ static void *Run( void *data )
             p_sys->last_state = VLC_PLAYER_STATE_STOPPED;
             msg_rc( STATUS_CHANGE "( stop state: 0 )" );
         }
-        vlc_player_Unlock(player);
 
         if( item != NULL )
         {
-            vlc_player_Lock(player);
             enum vlc_player_state state = vlc_player_GetState(player);
-            vlc_player_Unlock(player);
 
             if (p_sys->last_state != state)
             {
@@ -1627,15 +1622,14 @@ static void *Run( void *data )
 
         if( item && b_showpos )
         {
-            vlc_player_Lock(player);
             i_newpos = 100 * vlc_player_GetPosition( player );
-            vlc_player_Unlock(player);
             if( i_oldpos != i_newpos )
             {
                 i_oldpos = i_newpos;
                 msg_rc( "pos: %d%%", i_newpos );
             }
         }
+        vlc_player_Unlock(player);
 
         /* Is there something to do? */
         if( !b_complete ) continue;



More information about the vlc-commits mailing list