direct3d11: set the texture size after we know we use a staging one
[vlc.git] / src / playlist / search.c
blobee09ca8c36268f1ba52961b48c4e5eeab51f974b
1 /*****************************************************************************
2 * search.c : Search functions
3 *****************************************************************************
4 * Copyright (C) 1999-2009 VLC authors and VideoLAN
5 * $Id$
7 * Authors: Clément Stenac <zorglub@videolan.org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
23 #ifdef HAVE_CONFIG_H
24 # include "config.h"
25 #endif
26 #include <assert.h>
28 #include <vlc_common.h>
29 #include <vlc_playlist.h>
30 #include <vlc_charset.h>
31 #include "playlist_internal.h"
33 /***************************************************************************
34 * Item search functions
35 ***************************************************************************/
37 /***************************************************************************
38 * Live search handling
39 ***************************************************************************/
41 /**
42 * Enable all items in the playlist
43 * @param p_root: the current root item
45 static void playlist_LiveSearchClean( playlist_item_t *p_root )
47 for( int i = 0; i < p_root->i_children; i++ )
49 playlist_item_t *p_item = p_root->pp_children[i];
50 if( p_item->i_children >= 0 )
51 playlist_LiveSearchClean( p_item );
52 p_item->i_flags &= ~PLAYLIST_DBL_FLAG;
57 /**
58 * Enable/Disable items in the playlist according to the search argument
59 * @param p_root: the current root item
60 * @param psz_string: the string to search
61 * @return true if an item match
63 static bool playlist_LiveSearchUpdateInternal( playlist_item_t *p_root,
64 const char *psz_string, bool b_recursive )
66 int i;
67 bool b_match = false;
68 for( i = 0 ; i < p_root->i_children ; i ++ )
70 bool b_enable = false;
71 playlist_item_t *p_item = p_root->pp_children[i];
72 // Go recurssively if their is some children
73 if( b_recursive && p_item->i_children >= 0 &&
74 playlist_LiveSearchUpdateInternal( p_item, psz_string, true ) )
76 b_enable = true;
79 if( !b_enable )
81 vlc_mutex_lock( &p_item->p_input->lock );
82 // Do we have some meta ?
83 if( p_item->p_input->p_meta )
85 // Use Title or fall back to psz_name
86 const char *psz_title = vlc_meta_Get( p_item->p_input->p_meta, vlc_meta_Title );
87 if( !psz_title )
88 psz_title = p_item->p_input->psz_name;
89 const char *psz_album = vlc_meta_Get( p_item->p_input->p_meta, vlc_meta_Album );
90 const char *psz_artist = vlc_meta_Get( p_item->p_input->p_meta, vlc_meta_Artist );
91 b_enable = ( psz_title && vlc_strcasestr( psz_title, psz_string ) ) ||
92 ( psz_album && vlc_strcasestr( psz_album, psz_string ) ) ||
93 ( psz_artist && vlc_strcasestr( psz_artist, psz_string ) );
95 else
96 b_enable = p_item->p_input->psz_name && vlc_strcasestr( p_item->p_input->psz_name, psz_string );
97 vlc_mutex_unlock( &p_item->p_input->lock );
100 if( b_enable )
101 p_item->i_flags &= ~PLAYLIST_DBL_FLAG;
102 else
103 p_item->i_flags |= PLAYLIST_DBL_FLAG;
105 b_match |= b_enable;
107 return b_match;
113 * Launch the recursive search in the playlist
114 * @param p_playlist: the playlist
115 * @param p_root: the current root item
116 * @param psz_string: the string to find
117 * @return VLC_SUCCESS
119 int playlist_LiveSearchUpdate( playlist_t *p_playlist, playlist_item_t *p_root,
120 const char *psz_string, bool b_recursive )
122 PL_ASSERT_LOCKED;
123 pl_priv(p_playlist)->b_reset_currently_playing = true;
124 if( *psz_string )
125 playlist_LiveSearchUpdateInternal( p_root, psz_string, b_recursive );
126 else
127 playlist_LiveSearchClean( p_root );
128 vlc_cond_signal( &pl_priv(p_playlist)->signal );
129 return VLC_SUCCESS;