Commit ed344453 authored by Rémi Duraffort's avatar Rémi Duraffort

Use pl_Yield and pl_Release instead of vlc_object_find.

parent 4a6b8ccc
......@@ -203,8 +203,7 @@ InterfaceWindow::InterfaceWindow( intf_thread_t * _p_intf, BRect frame,
fLastUpdateTime( system_time() ),
fSettings( new BMessage( 'sett' ) )
{
p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
p_playlist = pl_Yield( p_intf );
var_AddCallback( p_playlist, "intf-change", PlaylistChanged, this );
var_AddCallback( p_playlist, "item-change", PlaylistChanged, this );
......@@ -355,7 +354,7 @@ InterfaceWindow::~InterfaceWindow()
}
if( p_playlist )
{
vlc_object_release( p_playlist );
pl_Release( p_playlist );
}
#if 0
if( fPlaylistWindow )
......
......@@ -690,13 +690,11 @@ PlaylistView::MouseDown( BPoint where )
// only do something if user clicked the same item twice
if ( fLastClickedItem == item )
{
playlist_t * p_playlist;
p_playlist = (playlist_t *) vlc_object_find( p_intf,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
playlist_t * p_playlist = pl_Yield( p_intf );
if( p_playlist )
{
playlist_Goto( p_playlist, i );
vlc_object_release( p_playlist );
pl_Release( p_playlist );
}
handled = true;
}
......@@ -1079,9 +1077,7 @@ PlaylistView::SetDisplayMode( uint32 mode )
BListItem*
PlaylistView::_PlayingItem() const
{
playlist_t * p_playlist;
p_playlist = (playlist_t *) vlc_object_find( p_intf,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
playlist_t * p_playlist = pl_Yield( p_intf );
if( !p_playlist )
{
......@@ -1089,7 +1085,7 @@ PlaylistView::_PlayingItem() const
}
BListItem * item = ItemAt( p_playlist->i_index );
vlc_object_release( p_playlist );
pl_Release( p_playlist );
return item;
}
......@@ -1103,9 +1099,7 @@ PlaylistView::_SetPlayingIndex( BListItem* playingItem )
{
if ( item == playingItem )
{
playlist_t * p_playlist;
p_playlist = (playlist_t *) vlc_object_find( p_intf,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
playlist_t * p_playlist = pl_Yield( p_intf );
if( !p_playlist )
{
......@@ -1115,7 +1109,7 @@ PlaylistView::_SetPlayingIndex( BListItem* playingItem )
playlist_Goto( p_playlist, i );
SetCurrent( i );
vlc_object_release( p_playlist );
pl_Release( p_playlist );
break;
}
}
......
......@@ -291,11 +291,10 @@ PlayListWindow::UpdatePlaylist( bool rebuild )
if( rebuild )
fListView->RebuildList();
p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
p_playlist = pl_Yield( p_intf );
fListView->SetCurrent( p_playlist->i_index );
fListView->SetPlaying( p_playlist->status.i_status == PLAYLIST_RUNNING );
vlc_object_release( p_playlist );
pl_Release( p_playlist );
_CheckItemsEnableState();
}
......
......@@ -288,7 +288,7 @@ static void Run( intf_thread_t *p_intf )
gtk_tree_view_column_set_sort_column_id(p_column, 2);
#endif
/* update the playlist */
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
p_playlist = pl_Yield( p_intf );
p_playlist_store = gtk_list_store_new (3,
G_TYPE_STRING, /* Filename */
G_TYPE_STRING, /* Time */
......@@ -296,7 +296,7 @@ static void Run( intf_thread_t *p_intf )
PlaylistRebuildListStore(p_intf,p_playlist_store, p_playlist);
gtk_tree_view_set_model(GTK_TREE_VIEW(p_intf->p_sys->p_tvplaylist), GTK_TREE_MODEL(p_playlist_store));
g_object_unref(p_playlist_store);
vlc_object_release(p_playlist); /* Free the playlist */
pl_Release(p_playlist); /* Free the playlist */
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(p_intf->p_sys->p_tvplaylist)),GTK_SELECTION_MULTIPLE);
/* Column properties */
......@@ -426,8 +426,7 @@ static int Manage( intf_thread_t *p_intf )
p_intf->p_sys->b_playing = 1;
/* update playlist interface */
p_playlist = (playlist_t *) vlc_object_find(
p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
p_playlist = pl_Yield( p_intf );
if (p_playlist != NULL)
{
p_liststore = gtk_list_store_new (3,
......@@ -437,7 +436,7 @@ static int Manage( intf_thread_t *p_intf )
PlaylistRebuildListStore(p_intf, p_liststore, p_playlist);
gtk_tree_view_set_model(p_intf->p_sys->p_tvplaylist, (GtkTreeModel*) p_liststore);
g_object_unref(p_liststore);
vlc_object_release( p_playlist );
pl_Release( p_playlist );
}
/* Manage the slider */
......
......@@ -94,8 +94,7 @@ static void PlaylistAddItem(GtkWidget *widget, gchar *name, char **ppsz_options,
int i_id , i_pos=0;
GtkTreeView *p_tvplaylist = NULL;
p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
p_playlist = pl_Yield( p_intf );
if( p_playlist == NULL)
{ /* Bail out when VLC's playlist object is not found. */
......@@ -147,7 +146,7 @@ static void PlaylistAddItem(GtkWidget *widget, gchar *name, char **ppsz_options,
free(ppsz_options);
}
}
vlc_object_release( p_playlist );
pl_Release( p_playlist );
}
void PlaylistRebuildListStore( intf_thread_t *p_intf,
......@@ -379,7 +378,7 @@ void onPause(GtkButton *button, gpointer user_data)
void onPlay(GtkButton *button, gpointer user_data)
{
intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET( button ) );
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)
{
......@@ -394,19 +393,18 @@ void onPlay(GtkButton *button, gpointer user_data)
{
vlc_object_unlock( p_playlist );
}
vlc_object_release( p_playlist );
pl_Release( p_playlist );
}
}
void onStop(GtkButton *button, gpointer user_data)
{
intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET( button ) );
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)
{
playlist_Stop( p_playlist );
vlc_object_release( p_playlist );
pl_Release( p_playlist );
gdk_window_raise( p_intf->p_sys->p_window->window );
}
}
......@@ -773,8 +771,7 @@ void onPlaylistRow(GtkTreeView *treeview, GtkTreePath *path,
{
intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET(treeview) );
GtkTreeSelection *p_selection = gtk_tree_view_get_selection(treeview);
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 )
{
......@@ -805,15 +802,14 @@ void onPlaylistRow(GtkTreeView *treeview, GtkTreePath *path,
i_skip = i_row - p_playlist->i_current_index;
playlist_Skip( p_playlist, i_skip );
}
vlc_object_release( p_playlist );
pl_Release( p_playlist );
}
void onUpdatePlaylist(GtkButton *button, gpointer user_data)
{
intf_thread_t * p_intf = GtkGetIntf( button );
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
playlist_t * p_playlist = pl_Yield( p_intf );
GtkTreeView *p_tvplaylist = NULL;
if( p_playlist == NULL )
......@@ -838,7 +834,7 @@ void onUpdatePlaylist(GtkButton *button, gpointer user_data)
g_object_unref(p_model);
}
}
vlc_object_release( p_playlist );
pl_Release( p_playlist );
}
static void deleteItemFromPlaylist(gpointer data, gpointer user_data)
......@@ -849,8 +845,7 @@ static void deleteItemFromPlaylist(gpointer data, gpointer user_data)
void onDeletePlaylist(GtkButton *button, gpointer user_data)
{
intf_thread_t *p_intf = GtkGetIntf( button );
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
playlist_t * p_playlist = pl_Yield( p_intf );
GtkTreeView *p_tvplaylist;
/* Delete an arbitrary item from the playlist */
......@@ -912,15 +907,14 @@ void onDeletePlaylist(GtkButton *button, gpointer user_data)
g_object_unref(p_store);
}
}
vlc_object_release( p_playlist );
pl_Release( p_playlist );
}
void onClearPlaylist(GtkButton *button, gpointer user_data)
{
intf_thread_t *p_intf = GtkGetIntf( button );
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
playlist_t * p_playlist = pl_Yield( p_intf );
GtkTreeView *p_tvplaylist;
int item;
......@@ -933,7 +927,7 @@ void onClearPlaylist(GtkButton *button, gpointer user_data)
{
msg_Err( p_playlist, "fix pda delete" );
}
vlc_object_release( p_playlist );
pl_Release( p_playlist );
// Remove all entries from the Playlist widget.
p_tvplaylist = (GtkTreeView*) lookup_widget( GTK_WIDGET(button), "tvPlaylist");
......@@ -1045,7 +1039,7 @@ void onAddTranscodeToPlaylist(GtkButton *button, gpointer user_data)
}
/* Update the playlist */
playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
playlist_t *p_playlist = pl_Yield( p_intf );
if( p_playlist == NULL ) return;
/* Get all the options. */
......
......@@ -332,8 +332,7 @@ void DialogsProvider::OnOpenFileSimple( int i_arg )
TCHAR szFile[MAX_PATH] = _T("\0");
static TCHAR szFilter[] = _T("All (*.*)\0*.*\0");
playlist_t *p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
playlist_t *p_playlist = pl_Yield( p_intf );
if( p_playlist == NULL ) return;
memset( &ofn, 0, sizeof(OPENFILENAME) );
......@@ -367,7 +366,7 @@ void DialogsProvider::OnOpenFileSimple( int i_arg )
PLAYLIST_APPEND | (i_arg?PLAYLIST_GO:0), PLAYLIST_END );
}
vlc_object_release( p_playlist );
pl_Release( p_playlist );
}
void DialogsProvider::OnOpenDirectory( int i_arg )
......@@ -406,8 +405,7 @@ void DialogsProvider::OnOpenDirectory( int i_arg )
if( !SUCCEEDED( SHGetMalloc(&p_malloc) ) ) goto error;
p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
p_playlist = pl_Yield( p_intf );
if( !p_playlist ) goto error;
memset( &bi, 0, sizeof(BROWSEINFO) );
......@@ -433,7 +431,7 @@ void DialogsProvider::OnOpenDirectory( int i_arg )
error:
if( p_malloc) p_malloc->Release();
if( p_playlist ) vlc_object_release( p_playlist );
if( p_playlist ) pl_Release( p_playlist );
#ifdef UNDER_CE
FreeLibrary( ceshell_dll );
......
......@@ -637,8 +637,7 @@ void Interface::OnShowDialog( int i_dialog_event )
void Interface::OnPlayStream( void )
{
playlist_t *p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
playlist_t *p_playlist = pl_Yield( p_intf );
if( p_playlist == NULL ) return;
if( p_playlist->i_size )
......@@ -653,7 +652,7 @@ void Interface::OnPlayStream( void )
/* No stream was playing, start one */
playlist_Play( p_playlist );
TogglePlayButton( PLAYING_S );
vlc_object_release( p_playlist );
pl_Release( p_playlist );
return;
}
......@@ -673,14 +672,13 @@ void Interface::OnPlayStream( void )
TogglePlayButton( state.i_int );
vlc_object_release( p_input );
vlc_object_release( p_playlist );
}
else
{
/* If the playlist is empty, open a file requester instead */
vlc_object_release( p_playlist );
OnShowDialog( ID_FILE_QUICKOPEN );
}
pl_Release( p_playlist );
}
void Interface::TogglePlayButton( int i_playing_status )
......@@ -812,33 +810,30 @@ void Interface::VolumeUpdate()
void Interface::OnStopStream( void )
{
playlist_t * p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
playlist_t * p_playlist = pl_Yield( p_intf );
if( p_playlist == NULL ) return;
playlist_Stop( p_playlist );
TogglePlayButton( PAUSE_S );
vlc_object_release( p_playlist );
pl_Release( p_playlist );
}
void Interface::OnPrevStream( void )
{
playlist_t * p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
playlist_t * p_playlist = pl_Yield( p_intf );
if( p_playlist == NULL ) return;
playlist_Prev( p_playlist );
vlc_object_release( p_playlist );
pl_Release( p_playlist );
}
void Interface::OnNextStream( void )
{
playlist_t * p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
playlist_t * p_playlist = pl_Yield( p_intf );
if( p_playlist == NULL ) return;
playlist_Next( p_playlist );
vlc_object_release( p_playlist );
pl_Release( p_playlist );
}
void Interface::OnSlowStream( void )
......
......@@ -269,12 +269,11 @@ void ItemInfoDialog::OnOk()
vlc_mutex_lock( &p_item->input.lock );
bool b_old_enabled = p_item->b_enabled;
playlist_t * p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
playlist_t * p_playlist = pl_Yield( p_intf );
if( p_playlist != NULL )
{
b_state = SendMessage( enabled_checkbox, BM_GETCHECK, 0, 0 );
vlc_object_release( p_playlist );
pl_Release( p_playlist );
}
p_item->b_enabled = (b_state & BST_CHECKED) ? true : false ;
......
......@@ -221,15 +221,13 @@ void PopupMenu( intf_thread_t *p_intf, HWND p_parent, POINT point )
}
else
{
playlist_t * p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
playlist_t * p_playlist = pl_Yield( p_intf );
if( p_playlist && p_playlist->i_size )
{
AppendMenu( hmenu, MF_SEPARATOR, 0, _T("") );
AppendMenu( hmenu, MF_STRING, PlayStream_Event, _T("Play") );
}
if( p_playlist ) vlc_object_release( p_playlist );
if( p_playlist ) pl_Release( p_playlist );
}
AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)MiscMenu( p_intf ),
......
......@@ -609,9 +609,7 @@ void OpenDialog::OnOk()
ComboBox_SetCurSel( mrl_combo, ComboBox_GetCount( mrl_combo ) - 1 );
/* Update the playlist */
playlist_t *p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
playlist_t *p_playlist = pl_Yield( p_intf );
if( p_playlist == NULL ) return;
for( int i = 0; i < i_args; i++ )
......@@ -657,7 +655,7 @@ void OpenDialog::OnOk()
free( pp_args[i_args] );
if( !i_args ) free( pp_args );
}
vlc_object_release( p_playlist );
pl_Release( p_playlist );
}
/*****************************************************************************
......
This diff is collapsed.
......@@ -52,13 +52,11 @@ Timer::Timer( intf_thread_t *_p_intf, HWND hwnd, Interface *_p_main_interface)
i_old_rate = INPUT_RATE_DEFAULT;
/* Register callback for the intf-popupmenu variable */
playlist_t *p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
playlist_t *p_playlist = pl_Yield( p_intf );
if( p_playlist != NULL )
{
var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
vlc_object_release( p_playlist );
pl_Release( p_playlist );
}
SetTimer( hwnd, 1, 200 /*milliseconds*/, NULL );
......@@ -67,13 +65,11 @@ Timer::Timer( intf_thread_t *_p_intf, HWND hwnd, Interface *_p_main_interface)
Timer::~Timer()
{
/* Unregister callback */
playlist_t *p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
playlist_t *p_playlist = pl_Yield( p_intf );
if( p_playlist != NULL )
{
var_DelCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
vlc_object_release( p_playlist );
pl_Release( p_playlist );
}
}
......
......@@ -371,12 +371,11 @@ 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 );
p_playlist = pl_Yield( p_vout );
if( p_playlist )
{
playlist_Stop( p_playlist );
vlc_object_release( p_playlist );
pl_Release( p_vout );
}
vlc_object_kill( p_vout->p_libvlc );
break;
......
......@@ -2123,17 +2123,15 @@ static int WallpaperCallback( vlc_object_t *p_this, char const *psz_cmd,
if( (newval.b_bool && !p_vout->p_sys->b_wallpaper) ||
(!newval.b_bool && p_vout->p_sys->b_wallpaper) )
{
playlist_t *p_playlist;
playlist_t *p_playlist = pl_Yield( p_vout );
p_playlist = vlc_object_find( p_this,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
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 );
pl_Release( p_playlist );
}
p_vout->p_sys->i_changes |= DX_WALLPAPER_CHANGE;
......
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