[vlc-devel] [PATCH 1/2] core: added sort by date (prepare for playlist fix)
Filip Roséen
filip at atch.se
Sun Nov 27 21:59:32 CET 2016
Hi Marcel,
On 2016-11-26 23:55, Marcel Schnirring wrote:
> Re-asking for review after a week has passed...
> ---
> include/vlc_playlist.h | 3 ++-
> src/playlist/sort.c | 14 +++++++++++++-
> 2 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
> index 5fef490..742372c 100644
> --- a/include/vlc_playlist.h
> +++ b/include/vlc_playlist.h
> @@ -186,7 +186,8 @@ struct playlist_t
> DEF( SORT_DESCRIPTION )\
> DEF( SORT_RATING )\
> DEF( SORT_URI )\
> - DEF( SORT_DISC_NUMBER )
> + DEF( SORT_DISC_NUMBER )\
> + DEF( SORT_DATE )
>
> #define DEF( s ) s,
> enum
> diff --git a/src/playlist/sort.c b/src/playlist/sort.c
> index 588bd35..68c15a5 100644
> --- a/src/playlist/sort.c
> +++ b/src/playlist/sort.c
> @@ -226,6 +226,19 @@ SORTFN( SORT_ALBUM, first, second )
> return i_ret;
> }
>
> +SORTFN( SORT_DATE, first, second )
> +{
> + int i_ret = meta_sort( first, second, vlc_meta_Date, true );
> + /* Items came from the same date: compare the albums */
> + if( i_ret == 0 )
> + i_ret = meta_sort( first, second, vlc_meta_Album, false );
> + /* Items came from the same album: compare the track numbers */
> + if( i_ret == 0 )
> + i_ret = meta_sort( first, second, vlc_meta_TrackNumber, true );
> +
Given that the above is the exactly same logic as defined by `SORTFN(
SORT_ALBUM, ... )`, you are far better off invoking this function
directly rather than explicitly doing the same thing.
SORTFN( SORT_DATE, first, second )
{
int i_ret = meta_sort( first, second, vlc_meta_Date, true );
if( i_ret == 0 )
return proto_SORT_ALBUM( first, second);
}
See `SORTFIN( SORT_ARTIST, ... )` for an equivalent example.
> + return i_ret;
> +}
> +
> SORTFN( SORT_ARTIST, first, second )
> {
> int i_ret = meta_sort( first, second, vlc_meta_Artist, false );
> @@ -361,4 +374,3 @@ static const sortfn_t sorting_fns[NUM_SORT_FNS][2] =
> #define DEF( a ) { cmp_a_##a, cmp_d_##a },
> { VLC_DEFINE_SORT_FUNCTIONS };
> #undef DEF
> -
> --
> 2.7.4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20161127/1f29c7fb/attachment.html>
More information about the vlc-devel
mailing list