<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<title></title>
<style type="text/css">code{white-space: pre;}</style>
</head>
<body>
<p>Hi Marcel,</p>
<p>On 2016-11-26 23:55, Marcel Schnirring wrote:</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> 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 );
+</code></pre>
</blockquote>
<p>Given that the above is the exactly same logic as defined by <code>SORTFN( SORT_ALBUM, ... )</code>, you are far better off invoking this function directly rather than explicitly doing the same thing.</p>
<pre><code>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);
}</code></pre>
<p>See <code>SORTFIN( SORT_ARTIST, ... )</code> for an equivalent example.</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> + 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</code></pre>
</blockquote>
</body>
</html>