From 8ee99fd28639d1b2aeee1312cc15388565a40280 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 23 Oct 2007 13:41:11 +0200 Subject: [PATCH 1/1] Kill loading of first available mood. It's unused and quite ugly. The dummy mood is good enough as a fallback. --- afs.c | 2 +- mood.c | 47 +++++------------------------------------------ 2 files changed, 6 insertions(+), 43 deletions(-) diff --git a/afs.c b/afs.c index 2e11539c..becff09d 100644 --- a/afs.c +++ b/afs.c @@ -531,7 +531,7 @@ dummy: if (ret < 0) PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret)); PARA_NOTICE_LOG("defaulting to dummy mood\n"); - change_current_mood(""); /* always successful */ + change_current_mood(NULL); /* always successful */ return PLAY_MODE_MOOD; } diff --git a/mood.c b/mood.c index 9074581c..08c2c222 100644 --- a/mood.c +++ b/mood.c @@ -523,35 +523,6 @@ static int load_mood(const struct osl_row *mood_row, struct mood **m) return 1; } -/* - * Calls load_mood() and reverts its error value: It returns -E_MOOD_LOADED - * on _success_, and 1 on errors. This way the loop over all moods stops at the - * first valid mood. - */ -static int load_mood_loop_func(struct osl_row *mood_row, void *data) -{ - struct mood **m = data; - int ret = load_mood(mood_row, m); - if (ret < 0) { - if (ret != -E_DUMMY_ROW) - PARA_NOTICE_LOG("invalid mood (%d), trying next mood\n", ret); - return 1; - } - return -E_MOOD_LOADED; -} - -static int load_first_available_mood(struct mood **m) -{ - int ret = osl_rbtree_loop(moods_table, BLOBCOL_NAME, m, - load_mood_loop_func); - if (ret == -E_MOOD_LOADED) /* success */ - return 1; - if (ret < 0) - return ret; /* error */ - PARA_NOTICE_LOG("no valid mood found\n"); - return -E_NO_MOOD; -} - static int check_mood(struct osl_row *mood_row, void *data) { struct para_buffer *pb = data; @@ -946,10 +917,8 @@ static void log_statistics(void) * * \param mood_name The name of the mood to open. * - * There are two special cases: If \a mood_name is \a NULL, load the - * first available mood. If \a mood_name is the empty string "", load - * the dummy mood that accepts every audio file and uses a scoring method - * based only on the \a last_played information. + * If \a mood_name is \a NULL, load the dummy mood that accepts every audio file + * and uses a scoring method based only on the \a last_played information. * * If there is already an open mood, it will be closed first. * @@ -967,14 +936,7 @@ int change_current_mood(char *mood_name) .array = NULL }; - if (!mood_name) { - struct mood *m; - ret = load_first_available_mood(&m); - if (ret < 0) - return ret; - destroy_mood(current_mood); - current_mood = m; - } else if (*mood_name) { + if (mood_name) { struct mood *m; struct osl_row *row; struct osl_object obj = { @@ -1050,7 +1012,8 @@ int reload_current_mood(void) PARA_NOTICE_LOG("reloading current mood\n"); if (!current_mood) return 1; - mood_name = para_strdup(current_mood->name); + if (current_mood->name) + mood_name = para_strdup(current_mood->name); close_current_mood(); ret = clear_score_table(); if (ret < 0) -- 2.39.2