Commit 2b0981f7 authored by Rafaël Carré's avatar Rafaël Carré

ncurses: simplify IsIndex() and DrawPlaylist()

parent e425c7c0
...@@ -462,16 +462,6 @@ static int PlaylistChanged(vlc_object_t *p_this, const char *psz_variable, ...@@ -462,16 +462,6 @@ static int PlaylistChanged(vlc_object_t *p_this, const char *psz_variable,
} }
/* Playlist suxx */ /* Playlist suxx */
/* This function have to be called with the playlist locked */
static inline bool PlaylistIsPlaying(playlist_t *p_playlist,
playlist_item_t *p_item)
{
playlist_item_t *p_played_item = playlist_CurrentPlayingItem(p_playlist);
return p_item && p_played_item
&& p_item->p_input && p_played_item->p_input
&& p_item->p_input->i_id == p_played_item->p_input->i_id;
}
static int SubSearchPlaylist(intf_sys_t *p_sys, char *psz_searchstring, static int SubSearchPlaylist(intf_sys_t *p_sys, char *psz_searchstring,
int i_start, int i_stop) int i_start, int i_stop)
{ {
...@@ -510,8 +500,18 @@ static void SearchPlaylist(intf_sys_t *p_sys, char *psz_searchstring) ...@@ -510,8 +500,18 @@ static void SearchPlaylist(intf_sys_t *p_sys, char *psz_searchstring)
static inline bool IsIndex(intf_sys_t *p_sys, playlist_t *p_playlist, int i) static inline bool IsIndex(intf_sys_t *p_sys, playlist_t *p_playlist, int i)
{ {
playlist_item_t *p_item = p_sys->pp_plist[i]->p_item; playlist_item_t *p_item = p_sys->pp_plist[i]->p_item;
return (p_item->i_children == 0 && p_item == p_sys->p_node) || playlist_item_t *p_played_item;
PlaylistIsPlaying(p_playlist, p_item);
PL_ASSERT_LOCKED;
if (p_item->i_children == 0 && p_item == p_sys->p_node)
return true;
p_played_item = playlist_CurrentPlayingItem(p_playlist);
if (p_played_item && p_item->p_input && p_played_item->p_input)
return p_item->p_input->i_id == p_played_item->p_input->i_id;
return false;
} }
static void FindIndex(intf_sys_t *p_sys, playlist_t *p_playlist) static void FindIndex(intf_sys_t *p_sys, playlist_t *p_playlist)
...@@ -1002,28 +1002,23 @@ static int DrawPlaylist(intf_thread_t *p_intf) ...@@ -1002,28 +1002,23 @@ static int DrawPlaylist(intf_thread_t *p_intf)
for(int i = 0; i < p_sys->i_plist_entries; i++) for(int i = 0; i < p_sys->i_plist_entries; i++)
{ {
char c = ' '; char c;
playlist_item_t *p_current_item, *p_item, *p_node; playlist_item_t *p_current_item;
input_thread_t *p_input2; playlist_item_t *p_item = p_sys->pp_plist[i]->p_item;
playlist_item_t *p_node = p_sys->p_node;
p_item = p_sys->pp_plist[i]->p_item;
p_node = p_sys->p_node;
p_input2 = playlist_CurrentInput(p_playlist);
PL_LOCK; PL_LOCK;
assert(p_item); assert(p_item);
p_current_item = playlist_CurrentPlayingItem(p_playlist); p_current_item = playlist_CurrentPlayingItem(p_playlist);
if ((p_node && p_item->p_input == p_node->p_input) || if ((p_node && p_item->p_input == p_node->p_input) ||
(!p_node && p_input2 && p_current_item && (!p_node && p_current_item && p_item->p_input == p_current_item->p_input))
p_item->p_input == p_current_item->p_input))
c = '*'; c = '*';
else if (p_item == p_node || PlaylistIsPlaying(p_playlist, p_item)) else if (p_item == p_node || p_current_item == p_item)
c = '>'; c = '>';
else
c = ' ';
PL_UNLOCK; PL_UNLOCK;
if (p_input2)
vlc_object_release(p_input2);
if (p_sys->b_color) color_set(i%3 + C_PLAYLIST_1, NULL); if (p_sys->b_color) color_set(i%3 + C_PLAYLIST_1, NULL);
MainBoxWrite(p_sys, i, "%c%s", c, p_sys->pp_plist[i]->psz_display); MainBoxWrite(p_sys, i, "%c%s", c, p_sys->pp_plist[i]->psz_display);
if (p_sys->b_color) color_set(C_DEFAULT, NULL); if (p_sys->b_color) color_set(C_DEFAULT, NULL);
......
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