}
}
+static int PlaylistChanged( vlc_object_t *p_this, const char * psz_variable,
+ vlc_value_t old_val, vlc_value_t new_val,
+ void * param )
+{
+ InterfaceWindow * w = (InterfaceWindow *) param;
+ w->UpdatePlaylist();
+ return VLC_SUCCESS;
+}
/*****************************************************************************
* InterfaceWindow
fLastUpdateTime( system_time() ),
fSettings( new BMessage( 'sett' ) )
{
+ p_playlist = (playlist_t *)
+ vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+
+ var_AddCallback( p_playlist, "intf-change", PlaylistChanged, this );
+ var_AddCallback( p_playlist, "item-change", PlaylistChanged, this );
+ var_AddCallback( p_playlist, "item-append", PlaylistChanged, this );
+ var_AddCallback( p_playlist, "item-deleted", PlaylistChanged, this );
+ var_AddCallback( p_playlist, "playlist-current", PlaylistChanged, this );
+
char psz_tmp[1024];
#define ADD_ELLIPSIS( a ) \
memset( psz_tmp, 0, 1024 ); \
playlist_Add( p_playlist, psz_uri, psz_device,
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
}
- _UpdatePlaylist();
+ UpdatePlaylist();
}
break;
}
}
- _UpdatePlaylist();
+ UpdatePlaylist();
break;
}
*****************************************************************************/
void InterfaceWindow::UpdateInterface()
{
- /* Manage the input part */
- if( !p_playlist )
- {
- p_playlist = (playlist_t *)
- vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
- }
if( !p_input )
{
p_input = (input_thread_t *)
return;
}
+ if( b_playlist_update )
+ {
+ if( fPlaylistWindow->Lock() )
+ {
+ fPlaylistWindow->UpdatePlaylist( true );
+ fPlaylistWindow->Unlock();
+ b_playlist_update = false;
+ }
+ p_mediaControl->SetEnabled( p_playlist->i_size );
+ }
+
if( p_input )
{
vlc_value_t val;
aout_VolumeGet( p_intf, &i_volume );
p_mediaControl->SetAudioEnabled( true );
p_mediaControl->SetMuted( i_volume );
-
- // update playlist as well
- if( fPlaylistWindow->LockWithTimeout( INTERFACE_LOCKING_TIMEOUT ) == B_OK )
- {
- fPlaylistWindow->UpdatePlaylist();
- fPlaylistWindow->Unlock();
- }
}
else
{
}
/*****************************************************************************
- * InterfaceWindow::IsStopped
+ * InterfaceWindow::UpdatePlaylist
*****************************************************************************/
-bool
-InterfaceWindow::IsStopped() const
+void
+InterfaceWindow::UpdatePlaylist()
{
- return (system_time() - fLastUpdateTime > INTERFACE_UPDATE_TIMEOUT);
+ b_playlist_update = true;
}
/*****************************************************************************
- * InterfaceWindow::_UpdatePlaylist
+ * InterfaceWindow::IsStopped
*****************************************************************************/
-void
-InterfaceWindow::_UpdatePlaylist()
+bool
+InterfaceWindow::IsStopped() const
{
- if( fPlaylistWindow->Lock() )
- {
- fPlaylistWindow->UpdatePlaylist( true );
- fPlaylistWindow->Unlock();
- }
- p_mediaControl->SetEnabled( p_playlist->i_size );
+ return (system_time() - fLastUpdateTime > INTERFACE_UPDATE_TIMEOUT);
}
/*****************************************************************************