};
/**
- * Stores an instance of an open mood (parser and statistics).
+ * Stores an instance of a loaded mood (parser and statistics).
*
- * A structure of this type is allocated and initialized at mood open time.
+ * A structure of this type is allocated and initialized when a mood is loaded.
*/
struct mood_instance {
/** NULL means that this is the "dummy" mood. */
};
/*
- * If current_mood is NULL then no mood is currently open. If
- * current_mood->name is NULL, the dummy mood is currently open.
+ * If current_mood is NULL then no mood is currently loaded. If
+ * current_mood->name is NULL, the current mood is the dummy mood.
*
* The statistics are adjusted dynamically through this pointer as files are
* added, removed or played.
return ret;
}
*m = alloc_new_mood(mood_name);
- PARA_INFO_LOG("opening mood %s\n", mood_name);
+ PARA_INFO_LOG("loading mood %s\n", mood_name);
ret = mp_init(mood_def.data, mood_def.size, &(*m)->parser_context, err);
osl_close_disk_object(&mood_def);
if (ret < 0)
}
/*
- * At mood open time we determine the set of admissible files for the given
+ * At mood load time we determine the set of admissible files for the given
* mood where each file is identified by a pointer to a row of the audio file
* table. In the first pass the pointers are added to a temporary array and
* statistics are computed. When all admissible files have been processed in
);
}
-/**
- * Close the current mood.
- *
- * Frees all resources of the current mood.
- */
-void close_current_mood(void)
+/** Free all resources of the current mood, if any. */
+void mood_unload(void)
{
destroy_mood(current_mood);
current_mood = NULL;
/**
* Change the current mood.
*
- * If there is already an open mood, it will be closed first.
- *
- * \param mood_name The name of the mood to open.
+ * \param mood_name The name of the mood to load.
* \param msg Error message or mood info is returned here.
*
* If \a mood_name is \a NULL, load the dummy mood that accepts every audio file
*
* \sa struct \ref afs_info::last_played, \ref mp_eval_row().
*/
-int mood_switch(const char *mood_name, char **msg)
+int mood_load(const char *mood_name, char **msg)
{
int i, ret;
struct admissible_array aa = {.size = 0};
if (msg)
*msg = get_statistics(aa.m, rnow.tv_sec);
ret = aa.m->stats.num;
- close_current_mood();
+ mood_unload();
current_mood = aa.m;
out:
free(aa.array);
}
/*
- * Close and re-open the current mood.
+ * Empty the score table and start over.
*
* This function is called on events which render the current list of
* admissible files useless, for example if an attribute is removed from the
current_mood->name : "(dummy)");
if (current_mood->name)
mood_name = para_strdup(current_mood->name);
- close_current_mood();
- ret = mood_switch(mood_name, NULL);
+ mood_unload();
+ ret = mood_load(mood_name, NULL);
free(mood_name);
return ret;
}