From: Andre Noll Date: Sat, 29 Sep 2007 11:39:34 +0000 (+0200) Subject: mood.c: Add no_attributes_set mood method. X-Git-Tag: v0.3.0~325 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=a1ba8789e586943643e38979465be3af83840540;p=paraslash.git mood.c: Add no_attributes_set mood method. Also fix a bug in mm_played_rarely_parser(): If no arg was specified in the mood definition, a NULL pointer is passed to that function, so it must not blindly dereference that pointer. --- diff --git a/mood.c b/mood.c index e685fd91..b7ee99eb 100644 --- a/mood.c +++ b/mood.c @@ -164,6 +164,25 @@ static uint64_t int_sqrt(uint64_t x) return res; } +static int mm_no_attributes_set_parser(const char *arg, __a_unused void **ignored) +{ + if (arg && *arg) + PARA_WARNING_LOG("ignored junk at eol: %s\n", arg); + return 1; +} + +static int mm_no_attributes_set_score_function(__a_unused const char *path, + const struct afs_info *afsi, + __a_unused const struct audio_format_info *afhi, + __a_unused const void *data) +{ + if (!strcmp(path, "/home/mp3/checked/dvd_08/cd_52/Sade__Paradise.mp3")) + PARA_NOTICE_LOG("%s: %llu\n", path, afsi->attributes); + if (!afsi->attributes) + return 100; + return -100; +} + static int mm_played_rarely_score_function(__a_unused const char *path, const struct afs_info *afsi, __a_unused const struct audio_format_info *afhi, @@ -182,7 +201,7 @@ static int mm_played_rarely_score_function(__a_unused const char *path, static int mm_played_rarely_parser(const char *arg, __a_unused void **ignored) { - if (*arg) + if (arg && *arg) PARA_WARNING_LOG("ignored junk at eol: %s\n", arg); return 1; } @@ -292,6 +311,11 @@ static int compute_mood_score(const struct osl_row *aft_row, struct mood *m, } static const struct mood_method mood_methods[] = { +{ + .parser = mm_no_attributes_set_parser, + .score_function = mm_no_attributes_set_score_function, + .name = "no_attributes_set" +}, { .parser = mm_played_rarely_parser, .score_function = mm_played_rarely_score_function,