]> git.sesse.net Git - vlc/commitdiff
* src/playlist/playlist.c: Don't do any playlist actions if there are no items in...
authorDerk-Jan Hartman <hartman@videolan.org>
Thu, 29 Apr 2004 19:30:58 +0000 (19:30 +0000)
committerDerk-Jan Hartman <hartman@videolan.org>
Thu, 29 Apr 2004 19:30:58 +0000 (19:30 +0000)
 * REST: remove code duplication in some places. there might be more locations.

modules/control/hotkeys.c
modules/gui/macosx/intf.m
modules/gui/wxwindows/wxwindows.cpp
src/playlist/playlist.c

index 423359bfdcea621d3009860ac64570d0a66561d3..7c7d1b5c37ebd11b752ac5847ed0d0d8111fa4e0 100755 (executable)
@@ -294,13 +294,8 @@ static void Run( intf_thread_t *p_intf )
                                           FIND_ANYWHERE );
             if( p_playlist )
             {
-                vlc_mutex_lock( &p_playlist->object_lock );
-                if( p_playlist->i_size )
-                {
-                    vlc_mutex_unlock( &p_playlist->object_lock );
-                    playlist_Play( p_playlist );
-                    vlc_object_release( p_playlist );
-                }
+                playlist_Play( p_playlist );
+                vlc_object_release( p_playlist );
             }
         }
         else if( i_action == ACTIONID_PLAY_PAUSE )
index ba8542d1bcac1dc60cd5c09dd062543132cb1d87..80f1daf202e82b013f7af5ef07f794ac23d2dc90 100644 (file)
@@ -487,19 +487,18 @@ unsigned int VLCModifiersToCocoa( unsigned int i_key )
     [self setSubmenusEnabled: FALSE];
     [self manageVolumeSlider];
     
-    /* Check if we need to start playing */
-    if( p_intf->b_play )
-    {
-        p_playlist = (playlist_t *) vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    p_playlist = (playlist_t *) vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
 
-        if( p_playlist )
+    if( p_playlist )
+    {
+        /* Check if we need to start playing */
+        if( p_intf->b_play )
         {
             playlist_Play( p_playlist );
-            vlc_object_release( p_playlist );
         }
+        [o_btn_fullscreen setState: ( var_Get( p_playlist, "fullscreen", &val )>=0 && val.b_bool )];
+        vlc_object_release( p_playlist );
     }
-    
-    [o_btn_fullscreen setState: ( var_Get( p_playlist, "fullscreen", &val )>=0 && val.b_bool )];
 }
 
 - (void)initStrings
index 0eeb79cf53d4f8280811051f3ed6e1def12c8721..fa57af8115d5f1ae30ddd502f7a067abc89c200e 100644 (file)
@@ -317,16 +317,7 @@ bool Instance::OnInit()
                                            FIND_ANYWHERE );
         if( p_playlist )
         {
-            vlc_mutex_lock( &p_playlist->object_lock );
-            if( p_playlist->i_size )
-            {
-                vlc_mutex_unlock( &p_playlist->object_lock );
-                playlist_Play( p_playlist );
-            }
-            else
-            {
-                vlc_mutex_unlock( &p_playlist->object_lock );
-            }
+            playlist_Play( p_playlist );
             vlc_object_release( p_playlist );
         }
     }
index bf2a5469f807d708962f10e82183d24f04c9d107..546e539ad5bfd6867f1b29753c5069063fe91a2f 100644 (file)
@@ -156,8 +156,9 @@ void playlist_Destroy( playlist_t * p_playlist )
 
 
 /**
- * Do a playlist action
+ * Do a playlist action.
  *
+ * If there is something in the playlist then you can do playlist actions.
  * \param p_playlist the playlist to do the command on
  * \param i_command the command to do
  * \param i_arg the argument to the command. See playlist_command_t for details
@@ -169,6 +170,12 @@ void playlist_Command( playlist_t * p_playlist, playlist_command_t i_command,
 
     vlc_mutex_lock( &p_playlist->object_lock );
 
+    if( p_playlist->i_size <= 0 )
+    {
+        vlc_mutex_unlock( &p_playlist->object_lock );
+        return;
+    }
+
     switch( i_command )
     {
     case PLAYLIST_STOP: