]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - mood.c
Rename mood_switch(), mood_close(), playlist_{open/close}.
[paraslash.git] / mood.c
diff --git a/mood.c b/mood.c
index 3df8c1dbe27d86085d7b397ab6210955904cef89..50a67793ea6c6ccaeceb4298b0beb028c8926286 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -48,9 +48,9 @@ struct afs_statistics {
 };
 
 /**
- * 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. */
@@ -62,8 +62,8 @@ struct mood_instance {
 };
 
 /*
- * 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.
@@ -164,7 +164,7 @@ static int init_mood_parser(const char *mood_name, struct mood_instance **m,
                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)
@@ -338,7 +338,7 @@ static int del_afs_statistics(const struct osl_row *row)
 }
 
 /*
- * 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
@@ -543,12 +543,8 @@ static char *get_statistics(struct mood_instance *m, int64_t sse)
        );
 }
 
-/**
- * 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;
@@ -573,9 +569,7 @@ static void compute_correction_factors(int64_t sse, struct afs_statistics *s)
 /**
  * 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
@@ -589,7 +583,7 @@ static void compute_correction_factors(int64_t sse, struct afs_statistics *s)
  *
  * \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};
@@ -633,7 +627,7 @@ int mood_switch(const char *mood_name, char **msg)
        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);
@@ -643,7 +637,7 @@ out:
 }
 
 /*
- * 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
@@ -660,8 +654,8 @@ static int reload_current_mood(void)
                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;
 }