VLC  4.0.0-dev
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. More...
 

Functions

static int meta_strcasecmp_title (const playlist_item_t *first, const playlist_item_t *second)
 Compare two items using their title or name. More...
 
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 according to the given meta type. More...
 
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. More...
 
static int recursiveNodeSort (playlist_t *p_playlist, playlist_item_t *p_node, sortfn_t p_sortfn)
 Sort a node recursively. More...
 
int playlist_RecursiveNodeSort (playlist_t *p_playlist, playlist_item_t *p_node, int i_mode, int i_type)
 Sort a node recursively. More...
 
static int proto_SORT_TRACK_NUMBER (const playlist_item_t *first, const playlist_item_t *second)
 
static int proto_SORT_DISC_NUMBER (const playlist_item_t *first, const playlist_item_t *second)
 
static int proto_SORT_ALBUM (const playlist_item_t *first, const playlist_item_t *second)
 
static int proto_SORT_DATE (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_URI (const playlist_item_t *first, const playlist_item_t *second)
 

Variables

static const sortfn_t sorting_fns [NUM_SORT_FNS][2]
 

Macro Definition Documentation

◆ DEF [1/2]

#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); }
playlist item / node
Definition: vlc_playlist_legacy.h:122

◆ DEF [2/2]

#define DEF (   a)    { cmp_a_##a, cmp_d_##a },

◆ SORTFN

#define SORTFN (   SORT,
  first,
  second 
)
Value:
static inline int proto_##SORT \
( const playlist_item_t *first, const playlist_item_t *second )
playlist item / node
Definition: vlc_playlist_legacy.h:122

◆ VLC_INTERNAL_PLAYLIST_SORT_FUNCTIONS

#define VLC_INTERNAL_PLAYLIST_SORT_FUNCTIONS

Typedef Documentation

◆ sortfn_t

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_modea SORT_* enum indicating the field to sort on
i_typeORDER_NORMAL or ORDER_REVERSE
Returns
function pointer, or NULL for SORT_RANDOM or invalid input

Function Documentation

◆ find_sorting_fn()

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().

◆ meta_sort()

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 according to the given meta type.

Parameters
firstthe first item
secondthe second item
metathe meta type to use to sort the items
b_integertrue 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_DATE(), proto_SORT_DESCRIPTION(), proto_SORT_DISC_NUMBER(), proto_SORT_GENRE(), proto_SORT_RATING(), and proto_SORT_TRACK_NUMBER().

◆ meta_strcasecmp_title()

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
firstthe first item
secondthe 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().

◆ playlist_ItemArraySort()

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_itemsnumber of items
pp_itemsthe array of items
p_sortfnthe sorting function
Returns
nothing

References vlc_mrand48().

Referenced by recursiveNodeSort().

◆ proto_SORT_ALBUM()

static int proto_SORT_ALBUM ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic

◆ proto_SORT_ARTIST()

static int proto_SORT_ARTIST ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic

◆ proto_SORT_DATE()

static int proto_SORT_DATE ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic

◆ proto_SORT_DESCRIPTION()

static int proto_SORT_DESCRIPTION ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic

◆ proto_SORT_DISC_NUMBER()

static int proto_SORT_DISC_NUMBER ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic

◆ proto_SORT_DURATION()

static int proto_SORT_DURATION ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic

◆ proto_SORT_GENRE()

static int proto_SORT_GENRE ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic

References meta_sort(), and vlc_meta_Genre.

◆ proto_SORT_ID()

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

◆ proto_SORT_RATING()

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

References meta_sort(), and vlc_meta_Rating.

◆ proto_SORT_TITLE()

static int proto_SORT_TITLE ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic

◆ proto_SORT_TITLE_NODES_FIRST()

static int proto_SORT_TITLE_NODES_FIRST ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic

◆ proto_SORT_TITLE_NUMERIC()

static int proto_SORT_TITLE_NUMERIC ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic

◆ proto_SORT_TRACK_NUMBER()

static int proto_SORT_TRACK_NUMBER ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic

◆ proto_SORT_URI()

static int proto_SORT_URI ( const playlist_item_t first,
const playlist_item_t second 
)
inlinestatic

◆ recursiveNodeSort()

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

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

Referenced by playlist_RecursiveNodeSort().

Variable Documentation

◆ sorting_fns

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().