Commit a0d182be authored by Gildas Bazin's avatar Gildas Bazin

* modules/gui/wxwidgets/playlist.cpp: if too many items are queued to be added...

* modules/gui/wxwidgets/playlist.cpp: if too many items are queued to be added to the playlist then it is quicker to just rebuild the whole playlist instead of inserting items one by one (fixes huge slowdown when using shoutcast).
parent 77595c2b
...@@ -204,6 +204,7 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ): ...@@ -204,6 +204,7 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
i_update_counter = 0; i_update_counter = 0;
i_sort_mode = MODE_NONE; i_sort_mode = MODE_NONE;
b_need_update = VLC_FALSE; b_need_update = VLC_FALSE;
i_items_to_append = 0;
p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE ); FIND_ANYWHERE );
if( p_playlist == NULL ) return; if( p_playlist == NULL ) return;
...@@ -540,23 +541,23 @@ void Playlist::AppendItem( wxCommandEvent& event ) ...@@ -540,23 +541,23 @@ void Playlist::AppendItem( wxCommandEvent& event )
{ {
playlist_add_t *p_add = (playlist_add_t *)event.GetClientData(); playlist_add_t *p_add = (playlist_add_t *)event.GetClientData();
playlist_item_t *p_item = NULL; playlist_item_t *p_item = NULL;
wxTreeItemId item, node;
wxTreeItemId item,node; i_items_to_append--;
if( p_add->i_view != i_current_view ) /* No need to do anything if the playlist is going to be rebuilt */
{ if( b_need_update ) return;
goto update;
} if( p_add->i_view != i_current_view ) goto update;
node = FindItem( treectrl->GetRootItem(), p_add->i_node ); node = FindItem( treectrl->GetRootItem(), p_add->i_node );
if( !node.IsOk() ) if( !node.IsOk() ) goto update;
{
goto update;
}
p_item = playlist_ItemGetById( p_playlist, p_add->i_item ); p_item = playlist_ItemGetById( p_playlist, p_add->i_item );
if( !p_item ) if( !p_item ) goto update;
goto update;
item = FindItem( treectrl->GetRootItem(), p_add->i_item );
if( item.IsOk() ) goto update;
item = treectrl->AppendItem( node, item = treectrl->AppendItem( node,
wxL2U( p_item->input.psz_name ), -1,-1, wxL2U( p_item->input.psz_name ), -1,-1,
...@@ -755,6 +756,8 @@ void Playlist::Rebuild( vlc_bool_t b_root ) ...@@ -755,6 +756,8 @@ void Playlist::Rebuild( vlc_bool_t b_root )
{ {
playlist_view_t *p_view; playlist_view_t *p_view;
i_items_to_append = 0;
/* We can remove the callbacks before locking, anyway, we won't /* We can remove the callbacks before locking, anyway, we won't
* miss anything */ * miss anything */
if( b_root ) if( b_root )
...@@ -1509,9 +1512,16 @@ static int ItemAppended( vlc_object_t *p_this, const char *psz_variable, ...@@ -1509,9 +1512,16 @@ static int ItemAppended( vlc_object_t *p_this, const char *psz_variable,
Playlist *p_playlist_dialog = (Playlist *)param; Playlist *p_playlist_dialog = (Playlist *)param;
playlist_add_t *p_add = (playlist_add_t *)malloc(sizeof( playlist_add_t)); playlist_add_t *p_add = (playlist_add_t *)malloc(sizeof( playlist_add_t));
memcpy( p_add, nval.p_address, sizeof( playlist_add_t ) ); memcpy( p_add, nval.p_address, sizeof( playlist_add_t ) );
if( p_playlist_dialog->i_items_to_append++ > 50 )
{
/* Too many items waiting to be added, it will be quicker to rebuild
* the whole playlist */
p_playlist_dialog->b_need_update = VLC_TRUE;
return VLC_SUCCESS;
}
wxCommandEvent event( wxEVT_PLAYLIST, AppendItem_Event ); wxCommandEvent event( wxEVT_PLAYLIST, AppendItem_Event );
event.SetClientData( (void *)p_add ); event.SetClientData( (void *)p_add );
p_playlist_dialog->AddPendingEvent( event ); p_playlist_dialog->AddPendingEvent( event );
......
...@@ -878,6 +878,7 @@ public: ...@@ -878,6 +878,7 @@ public:
void AppendItem( wxCommandEvent& ); void AppendItem( wxCommandEvent& );
bool b_need_update; bool b_need_update;
int i_items_to_append;
private: private:
void RemoveItem( int ); void RemoveItem( int );
......
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