]> git.sesse.net Git - vlc/blob - modules/media_library/item_list.h
fix album art caching for files without artist/album tags
[vlc] / modules / media_library / item_list.h
1 /*****************************************************************************
2  * item_list.h : Item list data structure for Watching system
3  *****************************************************************************
4  * Copyright (C) 2008-2010 the VideoLAN team  and AUTHORS
5  * $Id$
6  *
7  * Authors: Srikanth Raju <srikiraju at gmail dot com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
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 General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifndef ML_ITEM_LIST_H
25 #define ML_ITEM_LIST_H
26
27 #include <vlc_input.h>
28 #include <vlc_arrays.h>
29
30 struct watch_thread_t;
31 typedef struct watch_thread_t watch_thread_t;
32 typedef struct item_list_t item_list_t;
33
34 /**
35  * Definition of item_list_t
36  */
37 struct item_list_t {
38     input_item_t *p_item;     /**< Input item */
39     ml_media_t   *p_media;    /**< Media item */
40     item_list_t  *p_next;     /**< Next element in the list */
41     int           i_media_id; /**< Media id */
42     int           i_age;      /**< Time spent in this list without activity */
43     int           i_refs;     /**< Number of important refs */
44     int           i_update;   /**< Flag set when the input item is updated:
45                                     0: no update,
46                                     1: meta update,
47                                     2: increment play count,
48                                     3: both */
49 };
50
51 #define ML_ITEMLIST_HASH_LENGTH 40
52
53 #define il_foreachhashlist( a, b, c )                                          \
54             for( int c = 0 ; c < ML_ITEMLIST_HASH_LENGTH ; c++ )         \
55                 for( item_list_t* b = a[c]; b; b = b->p_next )
56
57 #define il_foreachlist( a, b )  for( item_list_t* b = a ; b; b = b->p_next )
58
59 #define item_list_add( a, b, c ) __item_list_add( a, b, c, false )
60
61 int __item_list_add( watch_thread_t *p_wt, ml_media_t* p_media,
62                      input_item_t *p_item, bool );
63 item_list_t* item_list_delMedia( watch_thread_t *p_wt, int i_media_id );
64 item_list_t* item_list_delItem( watch_thread_t *p_wt, input_item_t *p_item, bool );
65 item_list_t* item_list_listitemOfMediaId( watch_thread_t *p_wt, int i_media_id );
66 input_item_t* item_list_itemOfMediaId( watch_thread_t *p_wt, int i_media_id );
67 ml_media_t* item_list_mediaOfMediaId( watch_thread_t *p_wt, int i_media_id );
68 ml_media_t* item_list_mediaOfItem( watch_thread_t *p_wt, input_item_t* p_item, bool );
69 int item_list_mediaIdOfItem( watch_thread_t *p_wt, input_item_t *p_item );
70 int item_list_updateInput( watch_thread_t *p_wt, input_item_t *p_item,
71                            bool b_play_count );
72 void item_list_destroy( watch_thread_t* p_wt );
73
74 /**
75  * @brief Simple hash function
76  * @param item_id Hash Key
77  * @return Hash index
78  */
79 static inline int item_hash( input_item_t* p_item )
80 {
81     return DictHash( p_item->psz_uri, ML_ITEMLIST_HASH_LENGTH );
82 }
83
84 #endif /* ML_ITEM_LIST_H */