VLC  2.1.0-git
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Typedefs | Functions | Variables
sort.c File Reference
Include dependency graph for sort.c:

Macros

#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)
static int cmp_a_SORT_ID (const void *l, const void *r)
static int cmp_d_SORT_ID (const void *l, const void *r)
static int cmp_a_SORT_TITLE (const void *l, const void *r)
static int cmp_d_SORT_TITLE (const void *l, const void *r)
static int cmp_a_SORT_TITLE_NODES_FIRST (const void *l, const void *r)
static int cmp_d_SORT_TITLE_NODES_FIRST (const void *l, const void *r)
static int cmp_a_SORT_ARTIST (const void *l, const void *r)
static int cmp_d_SORT_ARTIST (const void *l, const void *r)
static int cmp_a_SORT_GENRE (const void *l, const void *r)
static int cmp_d_SORT_GENRE (const void *l, const void *r)
static int cmp_a_SORT_DURATION (const void *l, const void *r)
static int cmp_d_SORT_DURATION (const void *l, const void *r)
static int cmp_a_SORT_TITLE_NUMERIC (const void *l, const void *r)
static int cmp_d_SORT_TITLE_NUMERIC (const void *l, const void *r)
static int cmp_a_SORT_ALBUM (const void *l, const void *r)
static int cmp_d_SORT_ALBUM (const void *l, const void *r)
static int cmp_a_SORT_TRACK_NUMBER (const void *l, const void *r)
static int cmp_d_SORT_TRACK_NUMBER (const void *l, const void *r)
static int cmp_a_SORT_DESCRIPTION (const void *l, const void *r)
static int cmp_d_SORT_DESCRIPTION (const void *l, const void *r)
static int cmp_a_SORT_RATING (const void *l, const void *r)
static int cmp_d_SORT_RATING (const void *l, const void *r)
static int cmp_a_SORT_URI (const void *l, const void *r)
static int cmp_d_SORT_URI (const void *l, const void *r)

Variables

static const sortfn_t sorting_fns [NUM_SORT_FNS][2]

Macro Definition 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 int cmp_a_SORT_ALBUM ( const void *  l,
const void *  r 
)
static
static int cmp_a_SORT_ARTIST ( const void *  l,
const void *  r 
)
static
static int cmp_a_SORT_DESCRIPTION ( const void *  l,
const void *  r 
)
static
static int cmp_a_SORT_DURATION ( const void *  l,
const void *  r 
)
static
static int cmp_a_SORT_GENRE ( const void *  l,
const void *  r 
)
static
static int cmp_a_SORT_ID ( const void *  l,
const void *  r 
)
static
static int cmp_a_SORT_RATING ( const void *  l,
const void *  r 
)
static
static int cmp_a_SORT_TITLE ( const void *  l,
const void *  r 
)
static
static int cmp_a_SORT_TITLE_NODES_FIRST ( const void *  l,
const void *  r 
)
static
static int cmp_a_SORT_TITLE_NUMERIC ( const void *  l,
const void *  r 
)
static
static int cmp_a_SORT_TRACK_NUMBER ( const void *  l,
const void *  r 
)
static
static int cmp_a_SORT_URI ( const void *  l,
const void *  r 
)
static
static int cmp_d_SORT_ALBUM ( const void *  l,
const void *  r 
)
static
static int cmp_d_SORT_ARTIST ( const void *  l,
const void *  r 
)
static
static int cmp_d_SORT_DESCRIPTION ( const void *  l,
const void *  r 
)
static
static int cmp_d_SORT_DURATION ( const void *  l,
const void *  r 
)
static
static int cmp_d_SORT_GENRE ( const void *  l,
const void *  r 
)
static
static int cmp_d_SORT_ID ( const void *  l,
const void *  r 
)
static
static int cmp_d_SORT_RATING ( const void *  l,
const void *  r 
)
static
static int cmp_d_SORT_TITLE ( const void *  l,
const void *  r 
)
static
static int cmp_d_SORT_TITLE_NODES_FIRST ( const void *  l,
const void *  r 
)
static
static int cmp_d_SORT_TITLE_NUMERIC ( const void *  l,
const void *  r 
)
static
static int cmp_d_SORT_TRACK_NUMBER ( const void *  l,
const void *  r 
)
static
static int cmp_d_SORT_URI ( const void *  l,
const void *  r 
)
static
static sortfn_t find_sorting_fn ( unsigned  i_mode,
unsigned  i_type 
)
inlinestatic

References i_type, 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 
)
inlinestatic

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 
)
inlinestatic

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 
)
inlinestatic

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 
)
inlinestatic
static int proto_SORT_ARTIST ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic
static int proto_SORT_DESCRIPTION ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic
static int proto_SORT_DURATION ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic
static int proto_SORT_GENRE ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic

References meta_sort(), and vlc_meta_Genre.

static int proto_SORT_ID ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic
static int proto_SORT_RATING ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic

References meta_sort(), and vlc_meta_Rating.

static int proto_SORT_TITLE ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic
static int proto_SORT_TITLE_NODES_FIRST ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic
static int proto_SORT_TITLE_NUMERIC ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic
static int proto_SORT_TRACK_NUMBER ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic
static int proto_SORT_URI ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic
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_playlistthe playlist
p_nodethe node to sort
p_sortfnthe sorting function
Returns
VLC_SUCCESS on success

< No error

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

Referenced by playlist_RecursiveNodeSort().

Variable Documentation

static const sortfn_t sorting_fns
static
Initial value:
#define DEF( a )
{ { cmp_a_SORT_ID , cmp_d_SORT_ID }, { cmp_a_SORT_TITLE , cmp_d_SORT_TITLE }, { cmp_a_SORT_TITLE_NODES_FIRST , cmp_d_SORT_TITLE_NODES_FIRST }, { cmp_a_SORT_ARTIST , cmp_d_SORT_ARTIST }, { cmp_a_SORT_GENRE , cmp_d_SORT_GENRE }, { cmp_a_SORT_DURATION , cmp_d_SORT_DURATION }, { cmp_a_SORT_TITLE_NUMERIC , cmp_d_SORT_TITLE_NUMERIC }, { cmp_a_SORT_ALBUM , cmp_d_SORT_ALBUM }, { cmp_a_SORT_TRACK_NUMBER , cmp_d_SORT_TRACK_NUMBER }, { cmp_a_SORT_DESCRIPTION , cmp_d_SORT_DESCRIPTION }, { cmp_a_SORT_RATING , cmp_d_SORT_RATING }, { cmp_a_SORT_URI , cmp_d_SORT_URI }, }

Referenced by find_sorting_fn().