Commit fd629427 authored by Felix Paul Kühne's avatar Felix Paul Kühne

Replaced a certain amount of vlc_object_find by pl_Yield

Great news: there is no need to check for the existance of the playlist!
parent 6a498752
...@@ -435,13 +435,7 @@ static void FollowAnchor ( intf_thread_t *p_intf ) ...@@ -435,13 +435,7 @@ static void FollowAnchor ( intf_thread_t *p_intf )
mtime_t i_seconds; mtime_t i_seconds;
vlc_value_t time; vlc_value_t time;
p_playlist = (playlist_t *) vlc_object_find( p_intf, p_playlist = pl_Yield( p_intf );
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if ( !p_playlist )
{
msg_Warn( p_intf, "can't find playlist" );
return;
}
/* Get new URL */ /* Get new URL */
p_current_item = p_playlist->status.p_item; p_current_item = p_playlist->status.p_item;
...@@ -644,13 +638,7 @@ void GoBack( intf_thread_t *p_intf ) ...@@ -644,13 +638,7 @@ void GoBack( intf_thread_t *p_intf )
#endif #endif
/* Find the playlist */ /* Find the playlist */
p_playlist = (playlist_t *) vlc_object_find( p_intf, p_playlist = pl_Yield( p_intf );
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if ( !p_playlist )
{
msg_Warn( p_intf, "can't find playlist" );
return;
}
/* Retrieve navigation history from playlist */ /* Retrieve navigation history from playlist */
if( var_Get( p_playlist, "navigation-history", &history ) != VLC_SUCCESS || if( var_Get( p_playlist, "navigation-history", &history ) != VLC_SUCCESS ||
...@@ -722,13 +710,7 @@ void GoForward( intf_thread_t *p_intf ) ...@@ -722,13 +710,7 @@ void GoForward( intf_thread_t *p_intf )
#endif #endif
/* Find the playlist */ /* Find the playlist */
p_playlist = (playlist_t *) vlc_object_find( p_intf, p_playlist = pl_Yield( p_intf );
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if ( !p_playlist )
{
msg_Warn( p_intf, "can't find playlist" );
return;
}
/* Retrieve navigation history from playlist */ /* Retrieve navigation history from playlist */
if( var_Get( p_playlist, "navigation-history", &history ) != VLC_SUCCESS || if( var_Get( p_playlist, "navigation-history", &history ) != VLC_SUCCESS ||
......
...@@ -226,11 +226,7 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -226,11 +226,7 @@ static void RunIntf( intf_thread_t *p_intf )
case GESTURE(RIGHT,LEFT,NONE,NONE): case GESTURE(RIGHT,LEFT,NONE,NONE):
{ {
input_thread_t * p_input; input_thread_t * p_input;
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, p_playlist = pl_Yield( p_intf );
FIND_ANYWHERE );
if( !p_playlist )
break;
p_input = input_from_playlist( p_playlist ); p_input = input_from_playlist( p_playlist );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
...@@ -257,23 +253,13 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -257,23 +253,13 @@ static void RunIntf( intf_thread_t *p_intf )
} }
break; break;
case GESTURE(LEFT,DOWN,NONE,NONE): case GESTURE(LEFT,DOWN,NONE,NONE):
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, p_playlist = pl_Yield( p_intf );
FIND_ANYWHERE );
if( p_playlist == NULL )
{
break;
}
playlist_Prev( p_playlist ); playlist_Prev( p_playlist );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
break; break;
case GESTURE(RIGHT,DOWN,NONE,NONE): case GESTURE(RIGHT,DOWN,NONE,NONE):
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, p_playlist = pl_Yield( p_intf );
FIND_ANYWHERE );
if( p_playlist == NULL )
{
break;
}
playlist_Next( p_playlist ); playlist_Next( p_playlist );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
...@@ -306,11 +292,7 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -306,11 +292,7 @@ static void RunIntf( intf_thread_t *p_intf )
vlc_value_t val, list, list2; vlc_value_t val, list, list2;
int i_count, i; int i_count, i;
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, p_playlist = pl_Yield( p_intf );
FIND_ANYWHERE );
if( !p_playlist )
break;
p_input = input_from_playlist( p_playlist ); p_input = input_from_playlist( p_playlist );
...@@ -365,11 +347,7 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -365,11 +347,7 @@ static void RunIntf( intf_thread_t *p_intf )
vlc_value_t val, list, list2; vlc_value_t val, list, list2;
int i_count, i; int i_count, i;
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, p_playlist = pl_Yield( p_intf );
FIND_ANYWHERE );
if( !p_playlist )
break;
p_input = input_from_playlist( p_playlist ); p_input = input_from_playlist( p_playlist );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
......
...@@ -499,8 +499,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -499,8 +499,7 @@ static void Run( intf_thread_t *p_intf )
FIND_ANYWHERE ); FIND_ANYWHERE );
if( p_input ) if( p_input )
{ {
p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, p_playlist = pl_Yield( p_input );
FIND_PARENT );
} }
} }
/* New input has been registered */ /* New input has been registered */
...@@ -984,29 +983,26 @@ static int StateChanged( vlc_object_t *p_this, char const *psz_cmd, ...@@ -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 ); p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( p_input ) if( p_input )
{ {
p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, FIND_PARENT ); p_playlist = pl_Yield( p_input );
if( p_playlist ) char cmd[6];
switch( p_playlist->status.i_status )
{ {
char cmd[6]; case PLAYLIST_STOPPED:
switch( p_playlist->status.i_status ) strcpy( cmd, "stop" );
{ break;
case PLAYLIST_STOPPED: case PLAYLIST_RUNNING:
strcpy( cmd, "stop" ); strcpy( cmd, "play" );
break; break;
case PLAYLIST_RUNNING: case PLAYLIST_PAUSED:
strcpy( cmd, "play" ); strcpy( cmd, "pause" );
break; break;
case PLAYLIST_PAUSED: default:
strcpy( cmd, "pause" ); cmd[0] = '\0';
break; } /* var_GetInteger( p_input, "state" ) */
default: msg_rc( STATUS_CHANGE "( %s state: %d ): %s",
cmd[0] = '\0'; &cmd[0], newval.i_int,
} /* var_GetInteger( p_input, "state" ) */ ppsz_input_state[ newval.i_int ] );
msg_rc( STATUS_CHANGE "( %s state: %d ): %s", vlc_object_release( p_playlist );
&cmd[0], newval.i_int,
ppsz_input_state[ newval.i_int ] );
vlc_object_release( p_playlist );
}
vlc_object_release( p_input ); vlc_object_release( p_input );
} }
vlc_mutex_unlock( &p_intf->p_sys->status_lock ); 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, ...@@ -1521,12 +1517,10 @@ static int Quit( vlc_object_t *p_this, char const *psz_cmd,
VLC_UNUSED(oldval); VLC_UNUSED(newval); VLC_UNUSED(oldval); VLC_UNUSED(newval);
playlist_t *p_playlist; playlist_t *p_playlist;
p_playlist = vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); p_playlist = pl_Yield( p_this );
if( p_playlist ) playlist_Stop( p_playlist );
{ vlc_object_release( p_playlist );
playlist_Stop( p_playlist );
vlc_object_release( p_playlist );
}
vlc_object_kill( p_this->p_libvlc ); vlc_object_kill( p_this->p_libvlc );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -1910,9 +1904,7 @@ static int Menu( vlc_object_t *p_this, char const *psz_cmd, ...@@ -1910,9 +1904,7 @@ static int Menu( vlc_object_t *p_this, char const *psz_cmd,
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_playlist = vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); p_playlist = pl_Yield( p_this );
if( !p_playlist )
return VLC_ENOOBJ;
if( p_playlist->p_input ) if( p_playlist->p_input )
{ {
......
/***************************************************************************** /*****************************************************************************
* applescript.m: MacOS X AppleScript support * 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$ * $Id$
* *
* Authors: Derk-Jan Hartman <thedj@users.sourceforge.net> * Authors: Derk-Jan Hartman <thedj@users.sourceforge.net>
...@@ -41,8 +41,7 @@ ...@@ -41,8 +41,7 @@
if ( [o_command isEqualToString:@"GetURL"] || [o_command isEqualToString:@"OpenURL"] ) if ( [o_command isEqualToString:@"GetURL"] || [o_command isEqualToString:@"OpenURL"] )
{ {
intf_thread_t * p_intf = VLCIntf; intf_thread_t * p_intf = VLCIntf;
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, playlist_t * p_playlist = pl_Yield( p_intf );
FIND_ANYWHERE );
if( p_playlist == NULL ) if( p_playlist == NULL )
{ {
return nil; return nil;
...@@ -91,8 +90,7 @@ ...@@ -91,8 +90,7 @@
NSString *o_command = [[self commandDescription] commandName]; NSString *o_command = [[self commandDescription] commandName];
intf_thread_t * p_intf = VLCIntf; intf_thread_t * p_intf = VLCIntf;
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, playlist_t * p_playlist = pl_Yield( p_intf );
FIND_ANYWHERE );
if( p_playlist == NULL ) if( p_playlist == NULL )
{ {
return nil; return nil;
......
...@@ -274,7 +274,7 @@ ...@@ -274,7 +274,7 @@
else else
{ {
char *psz_name = input_item_GetName( p_item->p_input ); 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]; o_value = [NSString stringWithUTF8String: psz_name];
} }
...@@ -372,7 +372,7 @@ ...@@ -372,7 +372,7 @@
@"VLCPlaylistItemPboardType", nil]]; @"VLCPlaylistItemPboardType", nil]];
[o_outline_view setIntercellSpacing: NSMakeSize (0.0, 1.0)]; [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! * We need to keep checking in the future!
* These methods are being added artificially to NSOutlineView's interface above */ * These methods are being added artificially to NSOutlineView's interface above */
o_ascendingSortingImage = [[NSOutlineView class] _defaultTableHeaderSortImage]; o_ascendingSortingImage = [[NSOutlineView class] _defaultTableHeaderSortImage];
...@@ -1110,9 +1110,9 @@ ...@@ -1110,9 +1110,9 @@
} }
else if( b_selected_item_met == YES && else if( b_selected_item_met == YES &&
( [o_current_name rangeOfString:[o_search_field ( [o_current_name rangeOfString:[o_search_field
stringValue] options:NSCaseInsensitiveSearch ].length || stringValue] options:NSCaseInsensitiveSearch].length ||
[o_current_author rangeOfString:[o_search_field [o_current_author rangeOfString:[o_search_field
stringValue] options:NSCaseInsensitiveSearch ].length ) ) stringValue] options:NSCaseInsensitiveSearch].length ) )
{ {
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
/*Adds the parent items in the result array as well, so that we can /*Adds the parent items in the result array as well, so that we can
......
...@@ -1208,8 +1208,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -1208,8 +1208,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
- (BOOL)windowShouldClose:(id)sender - (BOOL)windowShouldClose:(id)sender
{ {
playlist_t * p_playlist = vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST, playlist_t * p_playlist = pl_Yield( p_vout );
FIND_ANYWHERE );
if( p_playlist == NULL ) if( p_playlist == NULL )
{ {
return NO; return NO;
......
...@@ -545,13 +545,9 @@ void MainInputManager::customEvent( QEvent *event ) ...@@ -545,13 +545,9 @@ void MainInputManager::customEvent( QEvent *event )
else else
{ {
/* we are working as a dialogs provider */ /* we are working as a dialogs provider */
playlist_t *p_playlist = (playlist_t *) vlc_object_find( p_intf, playlist_t *p_playlist = pl_Yield( p_intf );
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); p_input = p_playlist->p_input;
if( p_playlist ) emit inputChanged( p_input );
{
p_input = p_playlist->p_input;
emit inputChanged( p_input );
}
} }
} }
......
...@@ -98,14 +98,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -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_sub = msg_Subscribe( p_intf );
p_intf->p_sys->p_input = NULL; p_intf->p_sys->p_input = NULL;
p_intf->p_sys->p_playlist = (playlist_t *)vlc_object_find( p_intf, p_intf->p_sys->p_playlist = pl_Yield( 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;
}
// Initialize "singleton" objects // Initialize "singleton" objects
p_intf->p_sys->p_logger = NULL; p_intf->p_sys->p_logger = NULL;
...@@ -290,16 +283,11 @@ static int DemuxOpen( vlc_object_t *p_this ) ...@@ -290,16 +283,11 @@ static int DemuxOpen( vlc_object_t *p_this )
// Do nothing is skins2 is not the main interface // Do nothing is skins2 is not the main interface
if( var_Type( p_intf, "skin-to-load" ) == VLC_VAR_STRING ) if( var_Type( p_intf, "skin-to-load" ) == VLC_VAR_STRING )
{ {
playlist_t *p_playlist = playlist_t *p_playlist = pl_Yield( p_this );
(playlist_t *) vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, // Make sure the item is deleted afterwards
FIND_ANYWHERE ); /// \bug does not always work
if( p_playlist != NULL ) p_playlist->status.p_item->i_flags |= PLAYLIST_REMOVE_FLAG;
{ vlc_object_release( p_playlist );
// 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; vlc_value_t val;
val.psz_string = p_demux->psz_path; val.psz_string = p_demux->psz_path;
......
...@@ -206,13 +206,7 @@ static int Demux( demux_t *p_demux ) ...@@ -206,13 +206,7 @@ static int Demux( demux_t *p_demux )
playlist_t *p_playlist; playlist_t *p_playlist;
bool b_eof = false; bool b_eof = false;
p_playlist = vlc_object_find( p_demux, VLC_OBJECT_PLAYLIST, FIND_PARENT ); p_playlist = pl_Yield( p_demux );
if( p_playlist == NULL )
{
msg_Err( p_demux, "we are not attached to a playlist" );
return -1;
}
switch( p_sys->i_command ) switch( p_sys->i_command )
{ {
......
...@@ -1926,18 +1926,13 @@ static int StateCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -1926,18 +1926,13 @@ static int StateCallback( vlc_object_t *p_this, char const *psz_cmd,
*****************************************************************************/ *****************************************************************************/
static void AddStateVariableCallback(filter_t *p_filter) static void AddStateVariableCallback(filter_t *p_filter)
{ {
playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_filter, playlist_t *p_playlist = pl_Yield( p_filter );
VLC_OBJECT_PLAYLIST, input_thread_t *p_input = p_playlist->p_input;
FIND_ANYWHERE ); if(p_input)
if( p_playlist )
{ {
input_thread_t *p_input = p_playlist->p_input; var_AddCallback( p_input, "state", StateCallback, p_filter );
if(p_input)
{
var_AddCallback( p_input, "state", StateCallback, p_filter );
}
vlc_object_release( p_playlist );
} }
vlc_object_release( p_playlist );
} }
/***************************************************************************** /*****************************************************************************
...@@ -1949,18 +1944,13 @@ static void AddStateVariableCallback(filter_t *p_filter) ...@@ -1949,18 +1944,13 @@ static void AddStateVariableCallback(filter_t *p_filter)
*****************************************************************************/ *****************************************************************************/
static void DelStateVariableCallback( filter_t *p_filter ) static void DelStateVariableCallback( filter_t *p_filter )
{ {
playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_filter, playlist_t *p_playlist = pl_Yield( p_filter );
VLC_OBJECT_PLAYLIST, input_thread_t *p_input = p_playlist->p_input;
FIND_ANYWHERE ); if(p_input)
if( p_playlist )
{ {
input_thread_t *p_input = p_playlist->p_input; var_DelCallback( p_input, "state", StateCallback, p_filter );
if(p_input)
{
var_DelCallback( p_input, "state", StateCallback, p_filter );
}
vlc_object_release( p_playlist );
} }
vlc_object_release( p_playlist );
} }
......
...@@ -371,13 +371,9 @@ static int Manage( vout_thread_t *p_vout ) ...@@ -371,13 +371,9 @@ static int Manage( vout_thread_t *p_vout )
break; break;
case CACA_EVENT_QUIT: case CACA_EVENT_QUIT:
{ {
p_playlist = vlc_object_find( p_vout, p_playlist = pl_Yield( p_vout );
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); playlist_Stop( p_playlist );
if( p_playlist ) vlc_object_release( p_playlist );
{
playlist_Stop( p_playlist );
vlc_object_release( p_playlist );
}
vlc_object_kill( p_vout->p_libvlc ); vlc_object_kill( p_vout->p_libvlc );
break; break;
} }
......
...@@ -2125,18 +2125,12 @@ static int WallpaperCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -2125,18 +2125,12 @@ static int WallpaperCallback( vlc_object_t *p_this, char const *psz_cmd,
{ {
playlist_t *p_playlist; playlist_t *p_playlist;
p_playlist = p_playlist = pl_Yield( p_this );
(playlist_t *)vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, /* Modify playlist as well because the vout might have to be
FIND_PARENT ); * restarted */
if( p_playlist ) var_Create( p_playlist, "directx-wallpaper", VLC_VAR_BOOL );
{ var_Set( p_playlist, "directx-wallpaper", newval );
/* Modify playlist as well because the vout might have to be vlc_object_release( p_playlist );
* 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; p_vout->p_sys->i_changes |= DX_WALLPAPER_CHANGE;
} }
......
...@@ -77,15 +77,11 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args ); ...@@ -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 ) static void DirectXPopupMenu( event_thread_t *p_event, bool b_open )
{ {
playlist_t *p_playlist = playlist_t *p_playlist = pl_Yield( p_event );
vlc_object_find( p_event, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); vlc_value_t val;
if( p_playlist != NULL ) val.b_bool = b_open;
{ var_Set( p_playlist, "intf-popupmenu", val );
vlc_value_t val; vlc_object_release( p_playlist );
val.b_bool = b_open;
var_Set( p_playlist, "intf-popupmenu", val );
vlc_object_release( p_playlist );
}
} }
static int DirectXConvertKey( int i_key ); static int DirectXConvertKey( int i_key );
...@@ -870,14 +866,7 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message, ...@@ -870,14 +866,7 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
/* the user wants to close the window */ /* the user wants to close the window */
case WM_CLOSE: case WM_CLOSE:
{ {
playlist_t * p_playlist = playlist_t * p_playlist = pl_Yield( p_vout );
(playlist_t *)vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
{
return 0;
}
playlist_Stop( p_playlist ); playlist_Stop( p_playlist );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment