1 /*****************************************************************************
2 * flat_media_list.c: libvlc flat media list functions. (extension to
4 *****************************************************************************
5 * Copyright (C) 2007 the VideoLAN team
6 * $Id: flat_media_list.c 21287 2007-08-20 01:28:12Z pdherbemont $
8 * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #include "libvlc_internal.h"
26 #include <vlc/libvlc.h>
28 #include "vlc_arrays.h"
30 //#define DEBUG_FLAT_LIST
32 #ifdef DEBUG_FLAT_LIST
33 # define trace( fmt, ... ) printf( "%s(): " fmt, __FUNCTION__, ##__VA_ARGS__ )
43 * Public libvlc functions
46 /* Limited to four args, because it should be enough */
48 #define AN_SELECT( collapser, dec1, dec2, dec3, dec4, p, ...) p
49 #define ARGS(...) AN_SELECT( collapser, ##__VA_ARGS__, \
50 (p_mlv, arg1, arg2, arg3, arg4, p_e), \
51 (p_mlv, arg1, arg2, arg3, p_e), \
52 (p_mlv, arg1, arg2, p_e), \
53 (p_mlv, arg1, p_e), (p_mlv, p_e) )
55 #define MEDIA_LIST_VIEW_FUNCTION( name, ret_type, default_ret_value, /* Params */ ... ) \
57 libvlc_media_list_view_##name( libvlc_media_list_view_t * p_mlv, \
59 libvlc_exception_t * p_e ) \
61 if( p_mlv->pf_##name ) \
62 return p_mlv->pf_##name ARGS(__VA_ARGS__) ; \
63 libvlc_exception_raise( p_e, "No '" #name "' method in this media_list_view" ); \
64 return default_ret_value;\
67 #define MEDIA_LIST_VIEW_FUNCTION_VOID_RET( name, /* Params */ ... ) \
69 libvlc_media_list_view_##name( libvlc_media_list_view_t * p_mlv, \
71 libvlc_exception_t * p_e ) \
73 if( p_mlv->pf_##name ) \
75 p_mlv->pf_##name ARGS(__VA_ARGS__) ; \
78 libvlc_exception_raise( p_e, "No '" #name "' method in this media_list_view" ); \
82 MEDIA_LIST_VIEW_FUNCTION( count, int, 0 )
83 MEDIA_LIST_VIEW_FUNCTION( item_at_index, libvlc_media_descriptor_t *, NULL, int arg1 )
84 MEDIA_LIST_VIEW_FUNCTION( index_of_item, int, -1, libvlc_media_descriptor_t * arg1 )
86 MEDIA_LIST_VIEW_FUNCTION_VOID_RET( insert_at_index, libvlc_media_descriptor_t * arg1, int arg2 )
87 MEDIA_LIST_VIEW_FUNCTION_VOID_RET( remove_at_index, int arg1 )
88 MEDIA_LIST_VIEW_FUNCTION_VOID_RET( add_item, libvlc_media_descriptor_t * arg1 )