i9e: Fix typo: s/ie9/i9e.
[paraslash.git] / play.c
diff --git a/play.c b/play.c
index 86edc4d4e4f47bc1bd38197ed5982e97df9f72cf..14fac42fd7b6e92566815d4c56b1f4b6b23c88e2 100644 (file)
--- a/play.c
+++ b/play.c
@@ -109,10 +109,6 @@ typedef int (*play_cmd_handler_t)(struct lls_parse_result *lpr);
 struct play_command_info {
        play_cmd_handler_t handler;
 };
-#define EXPORT_PLAY_CMD_HANDLER(_cmd) \
-       const struct play_command_info lsg_play_cmd_com_ ## _cmd ## _user_data = { \
-               .handler = com_ ## _cmd \
-       };
 
 static int loglevel = LL_WARNING;
 
@@ -219,7 +215,6 @@ static long unsigned get_play_time(void)
        return result;
 }
 
-
 static void wipe_receiver_node(void)
 {
        PARA_NOTICE_LOG("cleaning up receiver node\n");
@@ -434,6 +429,15 @@ static int next_valid_file(void)
        int i, j = pt->current_file;
        unsigned num_inputs = lls_num_inputs(play_lpr);
 
+       if (j == num_inputs - 1) {
+               switch (OPT_UINT32_VAL(END_OF_PLAYLIST)) {
+               case EOP_LOOP: break;
+               case EOP_STOP:
+                       pt->playing = false;
+                       return 0;
+               case EOP_QUIT: return -E_EOP;
+               }
+       }
        for (i = 0; i < num_inputs; i++) {
                j = (j + 1) % num_inputs;
                if (!pt->invalid[j])
@@ -705,6 +709,11 @@ static void detach_stdout(void)
        btr_remove_node(&pt->btrn);
 }
 
+#define EXPORT_PLAY_CMD_HANDLER(_cmd) \
+       const struct play_command_info lsg_play_cmd_com_ ## _cmd ## _user_data = { \
+               .handler = com_ ## _cmd \
+       };
+
 static int com_quit(__a_unused struct lls_parse_result *lpr)
 {
        pt->rq = CRT_TERM_RQ;
@@ -1043,9 +1052,16 @@ static void session_open(void)
                history_file = para_strdup(OPT_STRING_VAL(HISTORY_FILE));
        else {
                char *home = para_homedir();
-               history_file = make_message("%s/.paraslash/play.history",
-                       home);
+               char *dot_para = make_message("%s/.paraslash", home);
+
                free(home);
+               ret = para_mkdir(dot_para, 0777);
+               /* warn, but otherwise ignore mkdir error */
+               if (ret < 0 && ret != -ERRNO_TO_PARA_ERROR(EEXIST))
+                       PARA_WARNING_LOG("Can not create %s: %s\n", dot_para,
+                               para_strerror(-ret));
+               history_file = make_message("%s/play.history", dot_para);
+               free(dot_para);
        }
        ici.history_file = history_file;
        ici.loglevel = loglevel;
@@ -1086,7 +1102,7 @@ static void session_update_time_string(char *str, unsigned len)
                if (btr_get_input_queue_size(pt->btrn) > 0)
                        return;
        }
-       ie9_print_status_bar(str, len);
+       i9e_print_status_bar(str, len);
 }
 
 /*
@@ -1245,7 +1261,6 @@ int main(int argc, char *argv[])
        init_shuffle_map();
        pt->invalid = para_calloc(sizeof(*pt->invalid) * num_inputs);
        pt->rq = CRT_FILE_CHANGE;
-       pt->current_file = num_inputs - 1;
        pt->playing = true;
        pt->task = task_register(&(struct task_info){
                .name = "play",