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 )
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 ||
......
......@@ -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 );
......
......@@ -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 )
{
......
/*****************************************************************************
* 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;
......
......@@ -274,7 +274,7 @@
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];
}
......@@ -372,7 +372,7 @@
@"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];
......@@ -1110,9 +1110,9 @@
}
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
......
......@@ -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;
......
......@@ -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 );
}
}
......
......@@ -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;
......
......@@ -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 )
{
......
......@@ -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 );
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
......
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