Defines | Typedefs | Functions | Variables

sort.c File Reference

Include dependency graph for sort.c:

Defines

#define VLC_INTERNAL_PLAYLIST_SORT_FUNCTIONS
#define SORTFN(SORT, first, second)
#define DEF(s)
#define DEF(a)   { cmp_a_##a, cmp_d_##a },

Typedefs

typedef int(* sortfn_t )(const void *, const void *)
 Return the comparison function appropriate for the SORT_* and ORDER_* arguments given, or NULL for SORT_RANDOM.

Functions

static int meta_strcasecmp_title (const playlist_item_t *first, const playlist_item_t *second)
 Compare two items using their title or name.
static int meta_sort (const playlist_item_t *first, const playlist_item_t *second, vlc_meta_type_t meta, bool b_integer)
 Compare two intems accoring to the given meta type.
static sortfn_t find_sorting_fn (unsigned i_mode, unsigned i_type)
static void playlist_ItemArraySort (unsigned i_items, playlist_item_t **pp_items, sortfn_t p_sortfn)
 Sort an array of items recursively.
static int recursiveNodeSort (playlist_t *p_playlist, playlist_item_t *p_node, sortfn_t p_sortfn)
 Sort a node recursively.
int playlist_RecursiveNodeSort (playlist_t *p_playlist, playlist_item_t *p_node, int i_mode, int i_type)
 Sort a node recursively.
static int proto_SORT_ALBUM (const playlist_item_t *first, const playlist_item_t *second)
static int proto_SORT_ARTIST (const playlist_item_t *first, const playlist_item_t *second)
static int proto_SORT_DESCRIPTION (const playlist_item_t *first, const playlist_item_t *second)
static int proto_SORT_DURATION (const playlist_item_t *first, const playlist_item_t *second)
static int proto_SORT_GENRE (const playlist_item_t *first, const playlist_item_t *second)
static int proto_SORT_ID (const playlist_item_t *first, const playlist_item_t *second)
static int proto_SORT_RATING (const playlist_item_t *first, const playlist_item_t *second)
static int proto_SORT_TITLE (const playlist_item_t *first, const playlist_item_t *second)
static int proto_SORT_TITLE_NODES_FIRST (const playlist_item_t *first, const playlist_item_t *second)
static int proto_SORT_TITLE_NUMERIC (const playlist_item_t *first, const playlist_item_t *second)
static int proto_SORT_TRACK_NUMBER (const playlist_item_t *first, const playlist_item_t *second)
static int proto_SORT_URI (const playlist_item_t *first, const playlist_item_t *second)

Variables

static const sortfn_t sorting_fns [NUM_SORT_FNS][2]

Define Documentation

#define DEF (   s  ) 
Value:
static int cmp_a_##s(const void *l,const void *r) \
    { return proto_##s(*(const playlist_item_t *const *)l, \
                           *(const playlist_item_t *const *)r); } \
    static int cmp_d_##s(const void *l,const void *r) \
    { return -1*proto_##s(*(const playlist_item_t * const *)l, \
                              *(const playlist_item_t * const *)r); }
#define DEF (   a  )     { cmp_a_##a, cmp_d_##a },
#define SORTFN (   SORT,
  first,
  second 
)
Value:
static inline int proto_##SORT \
    ( const playlist_item_t *first, const playlist_item_t *second )
#define VLC_INTERNAL_PLAYLIST_SORT_FUNCTIONS

Typedef Documentation

typedef int(* sortfn_t)(const void *, const void *)

Return the comparison function appropriate for the SORT_* and ORDER_* arguments given, or NULL for SORT_RANDOM.

Parameters:
i_mode,: a SORT_* enum indicating the field to sort on
i_type,: ORDER_NORMAL or ORDER_REVERSE
Returns:
function pointer, or NULL for SORT_RANDOM or invalid input

Function Documentation

static sortfn_t find_sorting_fn ( unsigned  i_mode,
unsigned  i_type 
) [inline, static]

References NUM_SORT_FNS, and sorting_fns.

Referenced by playlist_RecursiveNodeSort().

static int meta_sort ( const playlist_item_t first,
const playlist_item_t second,
vlc_meta_type_t  meta,
bool  b_integer 
) [inline, static]

Compare two intems accoring to the given meta type.

Parameters:
first,: the first item
second,: the second item
meta,: the meta type to use to sort the items
b_integer,: true if the meta are integers
Returns:
-1, 0 or 1 like strcmp

References playlist_item_t::i_children, input_item_GetMeta(), meta_strcasecmp_title(), playlist_item_t::p_input, and strcasecmp().

Referenced by proto_SORT_ALBUM(), proto_SORT_ARTIST(), proto_SORT_DESCRIPTION(), proto_SORT_GENRE(), proto_SORT_RATING(), and proto_SORT_TRACK_NUMBER().

static int meta_strcasecmp_title ( const playlist_item_t first,
const playlist_item_t second 
) [inline, static]

Compare two items using their title or name.

Parameters:
first,: the first item
second,: the second item
Returns:
-1, 0 or 1 like strcmp

References input_item_GetTitleFbName(), playlist_item_t::p_input, and strcasecmp().

Referenced by meta_sort(), proto_SORT_TITLE(), and proto_SORT_TITLE_NODES_FIRST().

static void playlist_ItemArraySort ( unsigned  i_items,
playlist_item_t **  pp_items,
sortfn_t  p_sortfn 
) [inline, static]

Sort an array of items recursively.

Parameters:
i_items,: number of items
pp_items,: the array of items
p_sortfn,: the sorting function
Returns:
nothing

References vlc_mrand48().

Referenced by recursiveNodeSort().

static int proto_SORT_ALBUM ( const playlist_item_t first,
const playlist_item_t second 
) [inline, static]
static int proto_SORT_ARTIST ( const playlist_item_t first,
const playlist_item_t second 
) [inline, static]
static int proto_SORT_DESCRIPTION ( const playlist_item_t first,
const playlist_item_t second 
) [inline, static]
static int proto_SORT_DURATION ( const playlist_item_t first,
const playlist_item_t second 
) [inline, static]
static int proto_SORT_GENRE ( const playlist_item_t first,
const playlist_item_t second 
) [inline, static]

References meta_sort(), and vlc_meta_Genre.

static int proto_SORT_ID ( const playlist_item_t first,
const playlist_item_t second 
) [inline, static]
static int proto_SORT_RATING ( const playlist_item_t first,
const playlist_item_t second 
) [inline, static]

References meta_sort(), and vlc_meta_Rating.

static int proto_SORT_TITLE ( const playlist_item_t first,
const playlist_item_t second 
) [inline, static]
static int proto_SORT_TITLE_NODES_FIRST ( const playlist_item_t first,
const playlist_item_t second 
) [inline, static]
static int proto_SORT_TITLE_NUMERIC ( const playlist_item_t first,
const playlist_item_t second 
) [inline, static]
static int proto_SORT_TRACK_NUMBER ( const playlist_item_t first,
const playlist_item_t second 
) [inline, static]
static int proto_SORT_URI ( const playlist_item_t first,
const playlist_item_t second 
) [inline, static]
static int recursiveNodeSort ( playlist_t p_playlist,
playlist_item_t p_node,
sortfn_t  p_sortfn 
) [static]

Sort a node recursively.

This function must be entered with the playlist lock !

Parameters:
p_playlist the playlist
p_node the node to sort
p_sortfn the sorting function
Returns:
VLC_SUCCESS on success

References playlist_item_t::i_children, playlist_ItemArraySort(), and playlist_item_t::pp_children.

Referenced by playlist_RecursiveNodeSort().


Variable Documentation

static VLC_DEFINE_SORT_FUNCTIONS const sortfn_t sorting_fns [static]
Initial value:
#define DEF( a ) 
{ VLC_DEFINE_SORT_FUNCTIONS }

Referenced by find_sorting_fn().

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines