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;
*
* \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.
*
.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 = {
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)