Commit 9ceef3c7 authored by zorglub's avatar zorglub
Browse files

* Playlist :

  - fix crash when deleting current item
  - SAP: don't store pointers
  - don't pass pointers to interface in item-appended
  - remove VIEW_SIMPLE that was confusing and bug-generating

* wx: 
  - Fix open layout
  - Fix slider behaviour, patch by Greg Hazel
parent 14c10390
......@@ -84,6 +84,7 @@ struct playlist_item_t
#define PLAYLIST_ENA_FLAG 0x04 /**< Is it enabled ? */
#define PLAYLIST_DEL_FLAG 0x08 /**< Autodelete ? */
#define PLAYLIST_RO_FLAG 0x10 /**< Write-enabled ? */
#define PLAYLIST_REMOVE_FLAG 0x20 /**< Remove this item at the end */
/**
* playlist view
......@@ -215,8 +216,8 @@ struct playlist_t
/* Helper to add an item */
struct playlist_add_t
{
playlist_item_t *p_node;
playlist_item_t *p_item;
int i_node;
int i_item;
int i_view;
int i_position;
};
......
......@@ -110,7 +110,7 @@
FIND_ANYWHERE );
int i_index;
i_current_view = VIEW_SIMPLE;
i_current_view = VIEW_CATEGORY;
playlist_ViewUpdate( p_playlist, i_current_view );
[o_outline_view setTarget: self];
......
......@@ -224,7 +224,7 @@ static int Open( vlc_object_t *p_this )
var_Set( p_intf->p_vlc, "verbose", val );
/* Set defaul playlist view */
p_sys->i_current_view = VIEW_SIMPLE;
p_sys->i_current_view = VIEW_CATEGORY;
p_sys->pp_plist = NULL;
p_sys->i_plist_entries = 0;
p_sys->b_need_update = VLC_FALSE;
......@@ -439,14 +439,11 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
case 'v':
switch( p_sys->i_current_view )
{
case VIEW_SIMPLE:
p_sys->i_current_view = VIEW_CATEGORY;
break;
case VIEW_CATEGORY:
p_sys->i_current_view = VIEW_ALL;
break;
default:
p_sys->i_current_view = VIEW_SIMPLE;
p_sys->i_current_view = VIEW_CATEGORY;
}
PlaylistRebuild( p_intf );
FindIndex( p_intf );
......
......@@ -212,6 +212,7 @@ BEGIN_EVENT_TABLE(Interface, wxFrame)
EVT_COMMAND(1, wxEVT_INTF, Interface::OnControlEvent)
EVT_TIMER(ID_CONTROLS_TIMER, Interface::OnControlsTimer)
EVT_TIMER(ID_SLIDER_TIMER, Interface::OnSliderTimer)
END_EVENT_TABLE()
/*****************************************************************************
......@@ -303,6 +304,7 @@ Interface::Interface( intf_thread_t *_p_intf, long style ):
SetupHotkeys();
m_controls_timer.SetOwner(this, ID_CONTROLS_TIMER);
m_slider_timer.SetOwner(this, ID_SLIDER_TIMER);
/* Start timer */
timer = new Timer( p_intf, this );
......@@ -677,6 +679,73 @@ void Interface::SetupHotkeys()
delete [] p_entries;
}
void Interface::HideSlider(bool layout)
{
ShowSlider(false, layout);
}
void Interface::ShowSlider(bool show, bool layout)
{
int size_to_video = config_GetInt( p_intf, "wxwin-size-to-video" );
if (show)
{
//prevent the hide timers from hiding it now
m_slider_timer.Stop();
m_controls_timer.Stop();
slider_frame->Show();
frame_sizer->Show( slider_frame );
}
else
{
slider_frame->Hide();
frame_sizer->Hide( slider_frame );
}
if (layout)
{
frame_sizer->Layout();
if (size_to_video)
{
frame_sizer->Fit( this );
}
}
}
void Interface::HideDiscFrame(bool layout)
{
ShowDiscFrame(false, layout);
}
void Interface::ShowDiscFrame(bool show, bool layout)
{
int size_to_video = config_GetInt( p_intf, "wxwin-size-to-video" );
if (show)
{
//prevent the hide timer from hiding it now
m_controls_timer.Stop();
disc_frame->Show();
slider_sizer->Show( disc_frame );
}
else
{
disc_frame->Hide();
slider_sizer->Hide( disc_frame );
}
if (layout)
{
slider_sizer->Layout();
if (size_to_video)
{
slider_sizer->Fit( slider_frame );
}
}
}
/*****************************************************************************
* Event Handlers.
*****************************************************************************/
......@@ -686,21 +755,20 @@ void Interface::OnControlsTimer(wxTimerEvent& WXUNUSED(event))
int size_to_video = config_GetInt( p_intf, "wxwin-size-to-video" );
/* Hide slider and Disc Buttons */
disc_frame->Hide();
slider_sizer->Hide( disc_frame );
//postpone layout, we'll do it ourselves
HideDiscFrame(false);
HideSlider(false);
slider_sizer->Layout();
if (size_to_video)
{
slider_sizer->Fit( slider_frame );
}
}
slider_frame->Hide();
frame_sizer->Hide( slider_frame );
frame_sizer->Layout();
if (size_to_video)
void Interface::OnSliderTimer(wxTimerEvent& WXUNUSED(event))
{
frame_sizer->Fit( this );
}
HideSlider();
}
void Interface::OnMenuOpen(wxMenuEvent& event)
......
......@@ -542,6 +542,8 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
#if (!wxCHECK_VERSION(2,5,0))
panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
#else
panel_sizer->Add( notebook, 1, wxEXPAND | wxALL, 5 );
#endif
panel_sizer->Add( common_opt_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
......
......@@ -216,7 +216,7 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
p_view_menu = NULL;
p_sd_menu = SDMenu();
i_current_view = VIEW_SIMPLE;
i_current_view = VIEW_CATEGORY;
b_changed_view = VLC_FALSE;
i_title_sorted = 0;
......@@ -540,26 +540,31 @@ void Playlist::UpdateTreeItem( wxTreeItemId item )
void Playlist::AppendItem( wxCommandEvent& event )
{
playlist_add_t *p_add = (playlist_add_t *)event.GetClientData();
playlist_item_t *p_item = NULL;
wxTreeItemId item,node;
if( p_add->i_view != i_current_view || !p_add->p_node )
if( p_add->i_view != i_current_view )
{
goto update;
}
node = FindItem( treectrl->GetRootItem(), p_add->p_node->input.i_id );
node = FindItem( treectrl->GetRootItem(), p_add->i_node );
if( !node.IsOk() )
{
goto update;
}
p_item = playlist_ItemGetById( p_playlist, p_add->i_item );
if( !p_item )
goto update;
item = treectrl->AppendItem( node,
wxL2U( p_add->p_item->input.psz_name ), -1,-1,
new PlaylistItem( p_add->p_item ) );
treectrl->SetItemImage( item, p_add->p_item->input.i_type );
wxL2U( p_item->input.psz_name ), -1,-1,
new PlaylistItem( p_item ) );
treectrl->SetItemImage( item, p_item->input.i_type );
if( item.IsOk() && p_add->p_item->i_children == -1 )
if( item.IsOk() && p_item->i_children == -1 )
{
UpdateTreeItem( item );
}
......@@ -1175,10 +1180,6 @@ wxMenu * Playlist::ViewMenu()
/* FIXME : have a list of "should have" views */
p_view_menu->Append( FirstView_Event + VIEW_CATEGORY,
wxU(_("Normal") ) );
/* p_view_menu->Append( FirstView_Event + VIEW_SIMPLE,
wxU(_("Manually added") ) );
p_view_menu->Append( FirstView_Event + VIEW_ALL,
wxU(_("All items, unsorted") ) ); */
p_view_menu->Append( FirstView_Event + VIEW_S_AUTHOR,
wxU(_("Sorted by artist") ) );
......
......@@ -132,8 +132,6 @@ void Timer::Notify()
if( p_intf->p_sys->p_input )
{
p_main_interface->slider->SetValue( 0 );
b_slider_shown = VLC_FALSE;
b_disc_shown = VLC_FALSE;
char *psz_now_playing = vlc_input_item_GetInfo(
p_intf->p_sys->p_input->input.p_item,
......@@ -221,9 +219,8 @@ void Timer::Notify()
var_Get( p_input, "position", &pos );
var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &val, NULL );
if( val.i_int > 0 && !b_disc_shown )
if( val.i_int > 0 && !p_main_interface->disc_menu_button->IsShown() )
{
b_disc_shown = VLC_TRUE;
vlc_value_t val;
#define HELP_MENU N_("Menu")
......@@ -262,47 +259,21 @@ void Timer::Notify()
wxU(_( HELP_NTR ) ) );
}
p_main_interface->disc_frame->Show();
p_main_interface->slider_sizer->Show(
p_main_interface->disc_frame );
p_main_interface->ShowDiscFrame();
}
if( pos.f_float > 0.0 )
{
/* Done like this, as it's the only way to know if the */
/* slider has to be displayed */
if( !b_slider_shown )
{
b_slider_shown = VLC_TRUE;
p_main_interface->slider_frame->Show();
p_main_interface->frame_sizer->Show(
p_main_interface->slider_frame );
p_main_interface->frame_sizer->Layout();
if (size_to_video)
if( pos.f_float > 0.0 )
{
p_main_interface->frame_sizer->Fit( p_main_interface );
}
}
/* Show the slider if it's position is significant */
p_main_interface->ShowSlider();
}
else
{
if( b_slider_shown )
{
p_main_interface->slider_frame->Hide();
p_main_interface->frame_sizer->Hide(
p_main_interface->slider_frame );
p_main_interface->frame_sizer->Layout();
if (size_to_video)
{
p_main_interface->frame_sizer->Fit( p_main_interface );
}
}
p_main_interface->m_slider_timer.Start(1000, wxTIMER_ONE_SHOT);
}
if( p_intf->p_sys->b_playing && b_slider_shown )
if( p_intf->p_sys->b_playing && p_main_interface->slider_frame->IsShown() )
{
/* Update the slider if the user isn't dragging it. */
if( p_intf->p_sys->b_slider_free )
......@@ -337,16 +308,12 @@ void Timer::Notify()
}
#if 0
vlc_mutex_lock( &p_input->stream.stream_lock );
if( p_intf->p_sys->p_input->stream.b_seekable && !b_slider_shown )
if( p_intf->p_sys->p_input->stream.b_seekable &&
!p_main_interface->slider_frame->IsShown() )
{
/* Done like this because b_seekable is set slightly after
* the new input object is available. */
b_slider_shown = VLC_TRUE;
p_main_interface->slider_frame->Show();
p_main_interface->frame_sizer->Show(
p_main_interface->slider_frame );
p_main_interface->frame_sizer->Layout();
p_main_interface->frame_sizer->Fit( p_main_interface );
p_main_interface->ShowSlider();
}
if( p_input->stream.b_seekable && p_intf->p_sys->b_playing )
{
......
......@@ -89,6 +89,7 @@ DECLARE_LOCAL_EVENT_TYPE( wxEVT_INTF, 1 );
enum{
ID_CONTROLS_TIMER,
ID_SLIDER_TIMER,
};
class DialogsProvider;
......@@ -184,13 +185,14 @@ public:
virtual void Notify();
private:
//use wxWindow::IsShown instead
//vlc_bool_t b_slider_shown;
//vlc_bool_t b_disc_shown;
intf_thread_t *p_intf;
Interface *p_main_interface;
vlc_bool_t b_init;
int i_old_playing_status;
int i_old_rate;
vlc_bool_t b_slider_shown;
vlc_bool_t b_disc_shown;
};
......@@ -333,11 +335,17 @@ public:
wxBoxSizer *frame_sizer;
wxStatusBar *statusbar;
void HideSlider(bool layout = true);
void ShowSlider(bool show = true, bool layout = true);
wxSlider *slider;
wxWindow *slider_frame;
wxBoxSizer *slider_sizer;
wxPanel *extra_frame;
void HideDiscFrame(bool layout = true);
void ShowDiscFrame(bool show = true, bool layout = true);
wxPanel *disc_frame;
wxBoxSizer *disc_sizer;
wxBitmapButton *disc_menu_button;
......@@ -356,6 +364,7 @@ public:
#endif
wxTimer m_controls_timer;
wxTimer m_slider_timer;
private:
void SetupHotkeys();
......@@ -367,6 +376,7 @@ private:
/* Event handlers (these functions should _not_ be virtual) */
void OnControlsTimer(wxTimerEvent& WXUNUSED(event));
void OnSliderTimer(wxTimerEvent& WXUNUSED(event));
void OnExit( wxCommandEvent& event );
void OnAbout( wxCommandEvent& event );
......
......@@ -191,7 +191,8 @@ struct sap_announce_t
/* SAP annnounces must only contain one SDP */
sdp_t *p_sdp;
playlist_item_t *p_item;
int i_item_id;
// playlist_item_t *p_item;
};
struct services_discovery_sys_t
......@@ -527,18 +528,23 @@ static void Run( services_discovery_t *p_sd )
if( mdate() - p_sd->p_sys->pp_announces[i]->i_last > i_timeout )
{
struct sap_announce_t *p_announce;
playlist_item_t * p_item;
p_announce = p_sd->p_sys->pp_announces[i];
msg_Dbg( p_sd, "Time out for %s, deleting (%i/%i)",
p_announce->p_item->input.psz_name,
i , p_sd->p_sys->i_announces );
/* Remove the playlist item */
p_playlist = vlc_object_find( p_sd, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{
playlist_Delete( p_playlist, p_announce->p_item->input.i_id );
p_item = playlist_ItemGetById( p_playlist,
p_announce->i_item_id );
if( !p_item ) continue;
msg_Dbg( p_sd, "Time out for %s, deleting (%i/%i)",
p_item->input.psz_name,
i , p_sd->p_sys->i_announces );
playlist_Delete( p_playlist, p_announce->i_item_id );
vlc_object_release( p_playlist );
}
......@@ -802,7 +808,7 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint16_t i_hash,
p_sap->i_last = mdate();
p_sap->i_hash = i_hash;
p_sap->p_sdp = p_sdp;
p_sap->p_item = NULL;
p_sap->i_item_id = -1;
/* Create the playlist item here */
p_item = playlist_ItemNew( p_sd, p_sap->p_sdp->psz_uri, psz_value );
......@@ -877,7 +883,7 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint16_t i_hash,
vlc_object_release( p_playlist );
p_sap->p_item = p_item;
p_sap->i_item_id = p_item->input.i_id;
TAB_APPEND( p_sd->p_sys->i_announces,
p_sd->p_sys->pp_announces, p_sap );
......@@ -1432,9 +1438,9 @@ static int RemoveAnnounce( services_discovery_t *p_sd,
return VLC_EGENERIC;
}
if( p_announce->p_item )
if( p_announce->i_item_id > -1 )
{
playlist_LockDelete( p_playlist, p_announce->p_item->input.i_id );
playlist_LockDelete( p_playlist, p_announce->i_item_id );
}
for( i = 0; i< p_sd->p_sys->i_announces; i++)
......
......@@ -200,8 +200,8 @@ int playlist_AddItem( playlist_t *p_playlist, playlist_item_t *p_item,
{
playlist_NodeAppend( p_playlist, VIEW_CATEGORY, p_item,
p_playlist->p_general );
p_add->p_item = p_item;
p_add->p_node = p_playlist->p_general;
p_add->i_item = p_item->input.i_id;
p_add->i_node = p_playlist->p_general->input.i_id;
p_add->i_view = VIEW_CATEGORY;
val.p_address = p_add;
var_Set( p_playlist, "item-append", val );
......@@ -216,26 +216,6 @@ int playlist_AddItem( playlist_t *p_playlist, playlist_item_t *p_item,
p_view = playlist_ViewFind( p_playlist, VIEW_ALL );
playlist_ItemAddParent( p_item, VIEW_ALL, p_view->p_root );
/* Also add the item to the "simple" view */
p_view = playlist_ViewFind( p_playlist, VIEW_SIMPLE );
if( b_end == VLC_TRUE )
{
playlist_NodeAppend( p_playlist, VIEW_SIMPLE,p_item,
p_view->p_root );
p_add->p_item = p_item;
p_add->p_node = p_view->p_root;
p_add->i_view = VIEW_SIMPLE;
val.p_address = p_add;
var_Set( p_playlist, "item-append", val );
}
else
{
playlist_NodeInsert( p_playlist, VIEW_SIMPLE,p_item,
p_view->p_root, i_pos );
}
/* FIXME : Update sorted views */
if( p_playlist->i_index >= i_pos )
......@@ -252,7 +232,7 @@ int playlist_AddItem( playlist_t *p_playlist, playlist_item_t *p_item,
{
p_playlist->request.b_request = VLC_TRUE;
/* FIXME ... */
p_playlist->request.i_view = VIEW_SIMPLE;
p_playlist->request.i_view = VIEW_CATEGORY;
p_playlist->request.p_node = p_view->p_root;
p_playlist->request.p_item = p_item;
......@@ -356,8 +336,8 @@ int playlist_NodeAddItem( playlist_t *p_playlist, playlist_item_t *p_item,
/* TODO: Handle modes */
playlist_NodeAppend( p_playlist, i_view, p_item, p_parent );
p_add->p_item = p_item;
p_add->p_node = p_parent;
p_add->i_item = p_item->input.i_id;
p_add->i_node = p_parent->input.i_id;
p_add->i_view = i_view;
val.p_address = p_add;
var_Set( p_playlist, "item-append", val );
......@@ -480,7 +460,6 @@ playlist_item_t * playlist_ItemGetById( playlist_t * p_playlist , int i_id )
{
return p_playlist->pp_all_items[i];
}
return NULL;
}
......@@ -643,6 +622,7 @@ int playlist_Replace( playlist_t *p_playlist, playlist_item_t *p_olditem,
int playlist_Delete( playlist_t * p_playlist, int i_id )
{
int i, i_top, i_bottom;
vlc_bool_t b_flag = VLC_FALSE;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id );
......@@ -672,14 +652,15 @@ int playlist_Delete( playlist_t * p_playlist, int i_id )
REMOVE_ELEM( p_playlist->pp_all_items, p_playlist->i_all_size, i );
}
/* Check if it is the current item */
if( p_playlist->status.p_item == p_item )
{
/* Hack we don't call playlist_Control for lock reasons */
p_playlist->status.i_status = PLAYLIST_STOPPED;
p_playlist->request.b_request = VLC_TRUE;
p_playlist->status.p_item = NULL;
// p_playlist->status.p_item = NULL;
msg_Info( p_playlist, "stopping playback" );
b_flag = VLC_TRUE;
}
msg_Info( p_playlist, "deleting playlist item `%s'",
......@@ -698,7 +679,10 @@ int playlist_Delete( playlist_t * p_playlist, int i_id )
/* TODO : Update views */
playlist_ItemDelete( p_item );
if( b_flag == VLC_FALSE )
playlist_ItemDelete( p_item );
else
p_item->i_flags |= PLAYLIST_REMOVE_FLAG;
return VLC_SUCCESS;
}
......
......@@ -123,7 +123,6 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent )
p_playlist->pp_all_items = 0;
playlist_ViewInsert( p_playlist, VIEW_CATEGORY, TITLE_CATEGORY );
playlist_ViewInsert( p_playlist, VIEW_SIMPLE, TITLE_SIMPLE );
playlist_ViewInsert( p_playlist, VIEW_ALL, TITLE_ALL );
p_view = playlist_ViewFind( p_playlist, VIEW_CATEGORY );
......@@ -135,8 +134,8 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent )
/* Set startup status
* We set to simple view on startup for interfaces that don't do
* anything */
p_view = playlist_ViewFind( p_playlist, VIEW_SIMPLE );
p_playlist->status.i_view = VIEW_SIMPLE;
p_view = playlist_ViewFind( p_playlist, VIEW_CATEGORY );
p_playlist->status.i_view = VIEW_CATEGORY;
p_playlist->status.p_item = NULL;
p_playlist->status.p_node = p_view->p_root;
p_playlist->request.b_request = VLC_FALSE;
......@@ -544,6 +543,13 @@ static void RunThread ( playlist_t *p_playlist )
i_vout_destroyed_date = 0;
i_sout_destroyed_date = 0;
if( p_playlist->status.p_item->i_flags
& PLAYLIST_REMOVE_FLAG )
{
playlist_ItemDelete( p_item );
p_playlist->status.p_item = NULL;
}
continue;
}
/* This input is dying, let him do */
......
......@@ -309,8 +309,8 @@ playlist_item_t * playlist_NodeCreate( playlist_t *p_playlist, int i_view,
playlist_NodeAppend( p_playlist, i_view, p_item, p_parent );
}
p_add->p_node = p_parent;
p_add->p_item = p_item;
p_add->i_node = p_parent ? p_parent->input.i_id : -1;
p_add->i_item = p_item->input.i_id;
p_add->i_view = i_view;
val.p_address = p_add;
var_Set( p_playlist, "item-append", val);
......@@ -419,7 +419,6 @@ int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
{
REMOVE_ELEM( p_playlist->pp_all_items, p_playlist->i_all_size, i );
}
playlist_ItemDelete( p_root );
}
return VLC_SUCCESS;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please registe