char *msg;
if (!arg) {
- ret = mood_switch(NULL, &msg);
+ ret = mood_load(NULL, &msg);
mode = PLAY_MODE_MOOD;
} else if (!strncmp(arg, "p/", 2)) {
- ret = playlist_open(arg + 2, &msg);
+ ret = playlist_load(arg + 2, &msg);
mode = PLAY_MODE_PLAYLIST;
} else if (!strncmp(arg, "m/", 2)) {
- ret = mood_switch(arg + 2, &msg);
+ ret = mood_load(arg + 2, &msg);
mode = PLAY_MODE_MOOD;
} else {
ret = -ERRNO_TO_PARA_ERROR(EINVAL);
arg = lls_input(0, aca->lpr);
score_clear();
if (current_play_mode == PLAY_MODE_MOOD)
- close_current_mood();
+ mood_unload();
else
- playlist_close();
+ playlist_unload();
ret = activate_mood_or_playlist(arg, &aca->pbout);
if (ret >= 0)
goto free_lpr;
}
ret = schedule(&s);
sched_shutdown(&s);
- close_current_mood();
+ mood_unload();
out_close:
close_afs_tables();
out:
void free_status_items(void);
/* mood */
-int mood_switch(const char *mood_name, char **msg);
-void close_current_mood(void);
+int mood_load(const char *mood_name, char **msg);
+void mood_unload(void);
int mood_check_callback(struct afs_callback_arg *aca);
/* playlist */
-int playlist_open(const char *name, char **msg);
-void playlist_close(void);
+int playlist_load(const char *name, char **msg);
+void playlist_unload(void);
int playlist_check_callback(struct afs_callback_arg *aca);
/** evaluates to 1 if x < y, to -1 if x > y and to 0 if x == y */
};
/**
- * 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;
}
* function returns true (without looking at the audio file metadata) to
* indicate that the given audio file should be considered admissible.
*
- * \sa \ref mood_switch(), \ref mp_eval_ast().
+ * \sa \ref mood_load(), \ref mp_eval_ast().
*/
bool mp_eval_row(const struct osl_row *aft_row, struct mp_context *ctx)
{
check_playlist));
}
-/**
- * Close the current playlist.
- *
- * \sa \ref playlist_open().
- */
-void playlist_close(void)
+/** Free all resources of the current playlist, if any. */
+void playlist_unload(void)
{
if (!current_playlist.name)
return;
* up in the audio file table. If the path lookup succeeds, a reference to the
* corresponding row of the audio file table is added to the score table.
*
- * \param name The name of the playlist to open.
+ * \param name The name of the playlist to load.
* \param msg Error message or playlist info is returned here.
*
* \return The length of the loaded playlist on success, negative error code
* else. Files which are listed in the playlist, but are not contained in the
* database are ignored. This is not considered an error.
*/
-int playlist_open(const char *name, char **msg)
+int playlist_load(const char *name, char **msg)
{
int ret;
struct playlist_instance *playlist = ¤t_playlist;
*msg = make_message("could not read playlist %s\n", name);
return ret;
}
- playlist_close();
+ playlist_unload();
ret = for_each_line(FELF_READ_ONLY, playlist_def.data,
playlist_def.size, add_playlist_entry, playlist);
osl_close_disk_object(&playlist_def);