]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
compute_mood_score(): Add additional mood * parameter.
authorAndre Noll <maan@systemlinux.org>
Tue, 25 Sep 2007 08:59:56 +0000 (10:59 +0200)
committerAndre Noll <maan@systemlinux.org>
Tue, 25 Sep 2007 08:59:56 +0000 (10:59 +0200)
Thid reduces the use of the global current_mood pointer.

mood.c

diff --git a/mood.c b/mood.c
index 1dc401c9d37478d4dd47c440c664c203b096cd3e..6b2dfa07617932edda5319248e06b254fa4eabd4 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -261,25 +261,26 @@ static int add_item_score(const struct osl_row *row, struct mood_item *item, lon
        return 1;
 }
 
-static int compute_mood_score(const struct osl_row *aft_row, long *result)
+static int compute_mood_score(const struct osl_row *aft_row, struct mood *m,
+               long *result)
 {
        struct mood_item *item;
        int match = 0;
        long score_arg_sum = 0, score = 0;
 
-       if (!current_mood)
+       if (!m)
                return -E_NO_MOOD;
        /* reject audio file if it matches any entry in the deny list */
-       list_for_each_entry(item, &current_mood->deny_list, mood_item_node)
+       list_for_each_entry(item, &m->deny_list, mood_item_node)
                if (add_item_score(aft_row, item, &score, &score_arg_sum) > 0)
                        return -E_NOT_ADMISSIBLE;
-       list_for_each_entry(item, &current_mood->accept_list, mood_item_node)
+       list_for_each_entry(item, &m->accept_list, mood_item_node)
                if (add_item_score(aft_row, item, &score, &score_arg_sum) > 0)
                        match = 1;
        /* reject if there is no matching entry in the accept list */
-       if (!match && !list_empty(&current_mood->accept_list))
+       if (!match && !list_empty(&m->accept_list))
                return -E_NOT_ADMISSIBLE;
-       list_for_each_entry(item, &current_mood->score_list, mood_item_node)
+       list_for_each_entry(item, &m->score_list, mood_item_node)
                add_item_score(aft_row, item, &score, &score_arg_sum);
        if (score_arg_sum)
                score /= score_arg_sum;
@@ -684,7 +685,7 @@ static int add_if_admissible(struct osl_row *aft_row, void *private_data)
        long score = 0;
 
        score = 0;
-       ret = compute_mood_score(aft_row, &score);
+       ret = compute_mood_score(aft_row, current_mood, &score);
        if (ret < 0)
                return (ret == -E_NOT_ADMISSIBLE)? 1 : ret;
        if (statistics.num >= aa->size) {
@@ -821,7 +822,7 @@ int mood_update_audio_file(const struct osl_row *aft_row, struct afs_info *old_a
        if (ret < 0)
                return ret;
        was_admissible = ret;
-       ret = compute_mood_score(aft_row, &score);
+       ret = compute_mood_score(aft_row, current_mood, &score);
        is_admissible = (ret > 0);
        if (!was_admissible && !is_admissible)
                return 1;