X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=mood.c;h=b3f007b68fe07c46f500d1aaa7dffdfe9503f451;hb=HEAD;hp=94ec3cd49ee3128348185d829acaa417fdbb5b5c;hpb=bb0aec0963b1b2da617aebda26deca576684436c;p=paraslash.git diff --git a/mood.c b/mood.c index 94ec3cd4..1e15ef0e 100644 --- a/mood.c +++ b/mood.c @@ -134,6 +134,8 @@ static void destroy_mood(struct mood_instance *m) if (!m) return; mp_shutdown(m->parser_context); + if (m->score_table) + score_close(m->score_table); free(m->name); free(m); } @@ -539,12 +541,15 @@ static char *get_statistics(struct mood_instance *m, int64_t sse) "loaded mood %s (%u files)\n" "last_played mean/sigma: %d/%d days\n" "num_played mean/sigma: %" PRId64 "/%" PRIu64 "\n" + "correction factor ratio: %.2lf\n" , m->name? m->name : "(dummy)", n, mean_days, sigma_days, m->stats.num_played_sum / n, - int_sqrt(m->stats.num_played_qd / n) + int_sqrt(m->stats.num_played_qd / n), + 86400.0 * m->stats.last_played_correction / + m->stats.num_played_correction ); } @@ -661,13 +666,11 @@ int mood_load(const char *mood_name, struct mood_instance **result, char **msg) mood_unload(NULL); current_mood = aa.m; } + ret = 1; out: free(aa.array); - if (ret < 0) { - if (aa.m->score_table) - score_close(aa.m->score_table); + if (ret <= 0) /* error, or no admissible files */ destroy_mood(aa.m); - } return ret; }