]> git.sesse.net Git - vlc/commitdiff
Replaced a certain amount of vlc_object_find by pl_Yield
authorFelix Paul Kühne <fkuehne@videolan.org>
Fri, 13 Jun 2008 07:48:13 +0000 (09:48 +0200)
committerFelix Paul Kühne <fkuehne@videolan.org>
Fri, 13 Jun 2008 07:48:38 +0000 (09:48 +0200)
Great news: there is no need to check for the existance of the playlist!

13 files changed:
modules/codec/cmml/intf.c
modules/control/gestures.c
modules/control/rc.c
modules/gui/macosx/applescript.m
modules/gui/macosx/playlist.m
modules/gui/macosx/vout.m
modules/gui/qt4/input_manager.cpp
modules/gui/skins2/src/skin_main.cpp
modules/misc/dummy/input.c
modules/video_filter/atmo/atmo.cpp
modules/video_output/caca.c
modules/video_output/msw/directx.c
modules/video_output/msw/events.c

index 1ecfbf0a409b32be67b2db3bc6131e86ab007cb6..ac908726e08ffeb8044a3c3691da250f37e78f63 100644 (file)
@@ -435,13 +435,7 @@ static void FollowAnchor ( intf_thread_t *p_intf )
         mtime_t i_seconds;
         vlc_value_t time;
 
-        p_playlist = (playlist_t *) vlc_object_find( p_intf,
-                VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-        if ( !p_playlist )
-        {
-            msg_Warn( p_intf, "can't find playlist" );
-            return;
-        }
+        p_playlist = pl_Yield( p_intf );
 
         /* Get new URL */
         p_current_item = p_playlist->status.p_item;
@@ -644,13 +638,7 @@ void GoBack( intf_thread_t *p_intf )
 #endif
 
     /* Find the playlist */
-    p_playlist = (playlist_t *) vlc_object_find( p_intf,
-            VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-    if ( !p_playlist )
-    {
-        msg_Warn( p_intf, "can't find playlist" );
-        return;
-    }
+    p_playlist = pl_Yield( p_intf );
 
     /* Retrieve navigation history from playlist */
     if( var_Get( p_playlist, "navigation-history", &history ) != VLC_SUCCESS ||
@@ -722,13 +710,7 @@ void GoForward( intf_thread_t *p_intf )
 #endif
 
     /* Find the playlist */
-    p_playlist = (playlist_t *) vlc_object_find( p_intf,
-            VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-    if ( !p_playlist )
-    {
-        msg_Warn( p_intf, "can't find playlist" );
-        return;
-    }
+    p_playlist = pl_Yield( p_intf );
 
     /* Retrieve navigation history from playlist */
     if( var_Get( p_playlist, "navigation-history", &history ) != VLC_SUCCESS ||
index d2d02dfafc685d09976bd4f291b462bbdf7bb693..282aaf6a00b32e9484f1136428311e10f8b7acdd 100644 (file)
@@ -226,11 +226,7 @@ static void RunIntf( intf_thread_t *p_intf )
             case GESTURE(RIGHT,LEFT,NONE,NONE):
                 {
                     input_thread_t * p_input;
-                    p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
-                                              FIND_ANYWHERE );
-
-                   if( !p_playlist )
-                        break;
+                    p_playlist = pl_Yield( p_intf );
 
                     p_input = input_from_playlist( p_playlist );
                     vlc_object_release( p_playlist );
@@ -257,23 +253,13 @@ static void RunIntf( intf_thread_t *p_intf )
                 }
                 break;
             case GESTURE(LEFT,DOWN,NONE,NONE):
-                p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
-                                              FIND_ANYWHERE );
-                if( p_playlist == NULL )
-                {
-                    break;
-                }
+                p_playlist = pl_Yield( p_intf );
 
                 playlist_Prev( p_playlist );
                 vlc_object_release( p_playlist );
                 break;
             case GESTURE(RIGHT,DOWN,NONE,NONE):
-                p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
-                                              FIND_ANYWHERE );
-                if( p_playlist == NULL )
-                {
-                    break;
-                }
+                p_playlist = pl_Yield( p_intf );
 
                 playlist_Next( p_playlist );
                 vlc_object_release( p_playlist );
@@ -306,11 +292,7 @@ static void RunIntf( intf_thread_t *p_intf )
                    vlc_value_t val, list, list2;
                    int i_count, i;
 
-                    p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
-                                              FIND_ANYWHERE );
-
-                   if( !p_playlist )
-                        break;
+                    p_playlist = pl_Yield( p_intf );
 
                     p_input = input_from_playlist( p_playlist );
 
@@ -365,11 +347,7 @@ static void RunIntf( intf_thread_t *p_intf )
                     vlc_value_t val, list, list2;
                     int i_count, i;
 
-                    p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
-                                              FIND_ANYWHERE );
-
-                    if( !p_playlist )
-                        break;
+                    p_playlist = pl_Yield( p_intf );
 
                     p_input = input_from_playlist( p_playlist );
                     vlc_object_release( p_playlist );
index 5df1f3f35f47660bbe21dc0c10f3ba388c8eb801..5d7744caf1720b90d22500ebe54e606aba3d577a 100644 (file)
@@ -499,8 +499,7 @@ static void Run( intf_thread_t *p_intf )
                                                    FIND_ANYWHERE );
                 if( p_input )
                 {
-                    p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST,
-                                                           FIND_PARENT );
+                    p_playlist = pl_Yield( p_input );
                 }
             }
             /* New input has been registered */
@@ -984,29 +983,26 @@ static int StateChanged( vlc_object_t *p_this, char const *psz_cmd,
     p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
     if( p_input )
     {
-        p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, FIND_PARENT );
-        if( p_playlist )
+        p_playlist = pl_Yield( p_input );
+        char cmd[6];
+        switch( p_playlist->status.i_status )
         {
-            char cmd[6];
-            switch( p_playlist->status.i_status )
-            {
-            case PLAYLIST_STOPPED:
-                strcpy( cmd, "stop" );
-                break;
-            case PLAYLIST_RUNNING:
-                strcpy( cmd, "play" );
-                break;
-            case PLAYLIST_PAUSED:
-                strcpy( cmd, "pause" );
-                break;
-            default:
-                cmd[0] = '\0';
-            } /* var_GetInteger( p_input, "state" )  */
-            msg_rc( STATUS_CHANGE "( %s state: %d ): %s",
-                                  &cmd[0], newval.i_int,
-                                  ppsz_input_state[ newval.i_int ] );
-            vlc_object_release( p_playlist );
-        }
+        case PLAYLIST_STOPPED:
+            strcpy( cmd, "stop" );
+            break;
+        case PLAYLIST_RUNNING:
+            strcpy( cmd, "play" );
+            break;
+        case PLAYLIST_PAUSED:
+            strcpy( cmd, "pause" );
+            break;
+        default:
+            cmd[0] = '\0';
+        } /* var_GetInteger( p_input, "state" )  */
+        msg_rc( STATUS_CHANGE "( %s state: %d ): %s",
+                              &cmd[0], newval.i_int,
+                              ppsz_input_state[ newval.i_int ] );
+        vlc_object_release( p_playlist );
         vlc_object_release( p_input );
     }
     vlc_mutex_unlock( &p_intf->p_sys->status_lock );
@@ -1521,12 +1517,10 @@ static int Quit( vlc_object_t *p_this, char const *psz_cmd,
     VLC_UNUSED(oldval); VLC_UNUSED(newval);
     playlist_t *p_playlist;
 
-    p_playlist = vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-    if( p_playlist )
-    {
-        playlist_Stop( p_playlist );
-        vlc_object_release( p_playlist );
-    }
+    p_playlist = pl_Yield( p_this );
+    playlist_Stop( p_playlist );
+    vlc_object_release( p_playlist );
+    
     vlc_object_kill( p_this->p_libvlc );
     return VLC_SUCCESS;
 }
@@ -1910,9 +1904,7 @@ static int Menu( vlc_object_t *p_this, char const *psz_cmd,
         return VLC_EGENERIC;
     }
 
-    p_playlist = vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-    if( !p_playlist )
-        return VLC_ENOOBJ;
+    p_playlist = pl_Yield( p_this );
 
     if( p_playlist->p_input )
     {
index 232d7e53d42680993302bd9166266152b5099b6c..f860af6e32f1bc14abe97594f2ee3cb1013466d7 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * applescript.m: MacOS X AppleScript support
  *****************************************************************************
- * Copyright (C) 2002-2003, 2005, 2007 the VideoLAN team
+ * Copyright (C) 2002-2003, 2005, 2007-2008 the VideoLAN team
  * $Id$
  *
  * Authors: Derk-Jan Hartman <thedj@users.sourceforge.net>
@@ -41,8 +41,7 @@
     if ( [o_command isEqualToString:@"GetURL"] || [o_command isEqualToString:@"OpenURL"] )
     {
         intf_thread_t * p_intf = VLCIntf;
-        playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
-                                                        FIND_ANYWHERE );
+        playlist_t * p_playlist = pl_Yield( p_intf );
         if( p_playlist == NULL )
         {
             return nil;
@@ -91,8 +90,7 @@
     NSString *o_command = [[self commandDescription] commandName];
 
     intf_thread_t * p_intf = VLCIntf;
-    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
-                                                    FIND_ANYWHERE );
+    playlist_t * p_playlist = pl_Yield( p_intf );
     if( p_playlist == NULL )
     {
         return nil;
index 762e8d929cd063b5e17eff827697abdfc3e396f9..b9927dd096c9ed6e69076e26474cc766ee844f30 100644 (file)
         else
         {
             char *psz_name = input_item_GetName( p_item->p_input );
-            if( psz_name != NULL )
+            if( !EMPTY_STR( psz_name ) )
             {
                 o_value = [NSString stringWithUTF8String: psz_name];
             }
         @"VLCPlaylistItemPboardType", nil]];
     [o_outline_view setIntercellSpacing: NSMakeSize (0.0, 1.0)];
 
-    /* This uses private Apple API which works fine until 10.4.
+    /* This uses private Apple API which works fine until 10.5.
      * We need to keep checking in the future!
      * These methods are being added artificially to NSOutlineView's interface above */
     o_ascendingSortingImage = [[NSOutlineView class] _defaultTableHeaderSortImage];
         }
         else if( b_selected_item_met == YES &&
                     ( [o_current_name rangeOfString:[o_search_field
-                        stringValue] options:NSCaseInsensitiveSearch ].length ||
+                        stringValue] options:NSCaseInsensitiveSearch].length ||
                       [o_current_author rangeOfString:[o_search_field
-                        stringValue] options:NSCaseInsensitiveSearch ].length ) )
+                        stringValue] options:NSCaseInsensitiveSearch].length ) )
         {
             vlc_object_release( p_playlist );
             /*Adds the parent items in the result array as well, so that we can
index e6465b5c7aa356b00070e964b20250b26b719d24..4fde1d1078f382f32f094909ba53117092f1a1b7 100644 (file)
@@ -1208,8 +1208,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
 - (BOOL)windowShouldClose:(id)sender
 {
-    playlist_t * p_playlist = vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST,
-                                                       FIND_ANYWHERE );
+    playlist_t * p_playlist = pl_Yield( p_vout );
     if( p_playlist == NULL )
     {
         return NO;
index 1280485f4e5aefe4b710d8a71f870d47998204f6..40c4e66edcc6cc5e75065677715b51782db85e23 100644 (file)
@@ -545,13 +545,9 @@ void MainInputManager::customEvent( QEvent *event )
     else
     {
         /* we are working as a dialogs provider */
-        playlist_t *p_playlist = (playlist_t *) vlc_object_find( p_intf,
-                                       VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-        if( p_playlist )
-        {
-            p_input = p_playlist->p_input;
-            emit inputChanged( p_input );
-        }
+        playlist_t *p_playlist = pl_Yield( p_intf );
+        p_input = p_playlist->p_input;
+        emit inputChanged( p_input );
     }
 }
 
index 2784db7abf929aa322e73792572b4ea49d660b65..cbc8a64b369020ac293122a1fc6308f875276256 100644 (file)
@@ -98,14 +98,7 @@ static int Open( vlc_object_t *p_this )
     p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
 
     p_intf->p_sys->p_input = NULL;
-    p_intf->p_sys->p_playlist = (playlist_t *)vlc_object_find( p_intf,
-        VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-    if( p_intf->p_sys->p_playlist == NULL )
-    {
-        msg_Err( p_intf, "No playlist object found" );
-        msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
-        return VLC_EGENERIC;
-    }
+    p_intf->p_sys->p_playlist = pl_Yield( p_intf );
 
     // Initialize "singleton" objects
     p_intf->p_sys->p_logger = NULL;
@@ -290,16 +283,11 @@ static int DemuxOpen( vlc_object_t *p_this )
         // Do nothing is skins2 is not the main interface
         if( var_Type( p_intf, "skin-to-load" ) == VLC_VAR_STRING )
         {
-            playlist_t *p_playlist =
-                (playlist_t *) vlc_object_find( p_this, VLC_OBJECT_PLAYLIST,
-                                                FIND_ANYWHERE );
-            if( p_playlist != NULL )
-            {
-                // Make sure the item is deleted afterwards
-                /// \bug does not always work
-                p_playlist->status.p_item->i_flags |= PLAYLIST_REMOVE_FLAG;
-                vlc_object_release( p_playlist );
-            }
+            playlist_t *p_playlist = pl_Yield( p_this );
+            // Make sure the item is deleted afterwards
+            /// \bug does not always work
+            p_playlist->status.p_item->i_flags |= PLAYLIST_REMOVE_FLAG;
+            vlc_object_release( p_playlist );
 
             vlc_value_t val;
             val.psz_string = p_demux->psz_path;
index 81e24b072292196442862b3d89e9bb6fdfd1f78e..64ba12dde34d2412b8dee6be5c09de8908b64f8d 100644 (file)
@@ -206,13 +206,7 @@ static int Demux( demux_t *p_demux )
     playlist_t *p_playlist;
     bool b_eof = false;
 
-    p_playlist = vlc_object_find( p_demux, VLC_OBJECT_PLAYLIST, FIND_PARENT );
-
-    if( p_playlist == NULL )
-    {
-        msg_Err( p_demux, "we are not attached to a playlist" );
-        return -1;
-    }
+    p_playlist = pl_Yield( p_demux );
 
     switch( p_sys->i_command )
     {
index 38a6696849eac462f4a64720017bcdaf2acb640c..84b3cd94bcc4d0ff6ee4f5890e7c1089fad76291 100644 (file)
@@ -1926,18 +1926,13 @@ static int StateCallback( vlc_object_t *p_this, char const *psz_cmd,
 *****************************************************************************/
 static void AddStateVariableCallback(filter_t *p_filter)
 {
-    playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_filter,
-        VLC_OBJECT_PLAYLIST,
-        FIND_ANYWHERE );
-    if( p_playlist )
+    playlist_t *p_playlist = pl_Yield( p_filter );
+    input_thread_t *p_input = p_playlist->p_input;
+    if(p_input)
     {
-        input_thread_t *p_input = p_playlist->p_input;
-        if(p_input)
-        {
-            var_AddCallback( p_input, "state", StateCallback, p_filter );
-        }
-        vlc_object_release( p_playlist );
+        var_AddCallback( p_input, "state", StateCallback, p_filter );
     }
+    vlc_object_release( p_playlist );
 }
 
 /*****************************************************************************
@@ -1949,18 +1944,13 @@ static void AddStateVariableCallback(filter_t *p_filter)
 *****************************************************************************/
 static void DelStateVariableCallback( filter_t *p_filter )
 {
-    playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_filter,
-        VLC_OBJECT_PLAYLIST,
-        FIND_ANYWHERE );
-    if( p_playlist )
+    playlist_t *p_playlist = pl_Yield( p_filter );
+    input_thread_t *p_input = p_playlist->p_input;
+    if(p_input)
     {
-        input_thread_t *p_input = p_playlist->p_input;
-        if(p_input)
-        {
-            var_DelCallback( p_input, "state", StateCallback, p_filter );
-        }
-        vlc_object_release( p_playlist );
+        var_DelCallback( p_input, "state", StateCallback, p_filter );
     }
+    vlc_object_release( p_playlist );
 }
 
 
index 41292b4b47ce9b62ba403056ce8ebcf4fcb3accf..54d7cfc7ab9c1d1bf5b465378536069020c25a92 100644 (file)
@@ -371,13 +371,9 @@ static int Manage( vout_thread_t *p_vout )
             break;
         case CACA_EVENT_QUIT:
         {
-            p_playlist = vlc_object_find( p_vout,
-                                          VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-            if( p_playlist )
-            {
-                playlist_Stop( p_playlist );
-                vlc_object_release( p_playlist );
-            }
+            p_playlist = pl_Yield( p_vout );
+            playlist_Stop( p_playlist );
+            vlc_object_release( p_playlist );
             vlc_object_kill( p_vout->p_libvlc );
             break;
         }
index 56aade1f8be2968483240de30caabe42c8b1ffb9..084968d7b4dcd587366063cb3a295c4c148233d5 100644 (file)
@@ -2125,18 +2125,12 @@ static int WallpaperCallback( vlc_object_t *p_this, char const *psz_cmd,
     {
         playlist_t *p_playlist;
 
-        p_playlist =
-            (playlist_t *)vlc_object_find( p_this, VLC_OBJECT_PLAYLIST,
-                                           FIND_PARENT );
-        if( p_playlist )
-        {
-            /* Modify playlist as well because the vout might have to be
-             * restarted */
-            var_Create( p_playlist, "directx-wallpaper", VLC_VAR_BOOL );
-            var_Set( p_playlist, "directx-wallpaper", newval );
-
-            vlc_object_release( p_playlist );
-        }
+        p_playlist = pl_Yield( p_this );
+        /* Modify playlist as well because the vout might have to be
+         * restarted */
+        var_Create( p_playlist, "directx-wallpaper", VLC_VAR_BOOL );
+        var_Set( p_playlist, "directx-wallpaper", newval );
+        vlc_object_release( p_playlist );
 
         p_vout->p_sys->i_changes |= DX_WALLPAPER_CHANGE;
     }
index 7987ab283f6499b5a8b3714066f1f5e68c267493..8ee36bf5a455830614b3db3d5a5afd0b6906f58d 100644 (file)
@@ -77,15 +77,11 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args );
 
 static void DirectXPopupMenu( event_thread_t *p_event, bool b_open )
 {
-    playlist_t *p_playlist =
-        vlc_object_find( p_event, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-    if( p_playlist != NULL )
-    {
-        vlc_value_t val;
-        val.b_bool = b_open;
-        var_Set( p_playlist, "intf-popupmenu", val );
-        vlc_object_release( p_playlist );
-    }
+    playlist_t *p_playlist = pl_Yield( p_event );
+    vlc_value_t val;
+    val.b_bool = b_open;
+    var_Set( p_playlist, "intf-popupmenu", val );
+    vlc_object_release( p_playlist );
 }
 
 static int DirectXConvertKey( int i_key );
@@ -870,14 +866,7 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
     /* the user wants to close the window */
     case WM_CLOSE:
     {
-        playlist_t * p_playlist =
-            (playlist_t *)vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST,
-                                           FIND_ANYWHERE );
-        if( p_playlist == NULL )
-        {
-            return 0;
-        }
-
+        playlist_t * p_playlist = pl_Yield( p_vout );
         playlist_Stop( p_playlist );
         vlc_object_release( p_playlist );
         return 0;