From d6af2c473a9f2ae1f582ad44d5ad6eb8bf1ed35a Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 25 Sep 2007 10:59:56 +0200 Subject: [PATCH] compute_mood_score(): Add additional mood * parameter. Thid reduces the use of the global current_mood pointer. --- mood.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/mood.c b/mood.c index 1dc401c9..6b2dfa07 100644 --- 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, ¤t_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, ¤t_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(¤t_mood->accept_list)) + if (!match && !list_empty(&m->accept_list)) return -E_NOT_ADMISSIBLE; - list_for_each_entry(item, ¤t_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; -- 2.39.5