]> git.tue.mpg.de Git - paraslash.git/commitdiff
play: Convert com_play() to lopsub.
authorAndre Noll <maan@tuebingen.mpg.de>
Mon, 28 Mar 2016 03:49:45 +0000 (03:49 +0000)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 26 Mar 2017 09:02:28 +0000 (11:02 +0200)
Straight forward conversion, slight improvement of the help text.

m4/lls/play_cmd.suite.m4
play.c
play.cmd

index f1434affb61afe0db087fbfb9dc43fa55903cef6..3632b184c1e0ef72990fb646070719cfd5a74358 100644 (file)
@@ -61,3 +61,12 @@ caption = list of commands
                The output contains the playlist position, the path
                and information provided by the audio format handler.
        [/description]
+
+[subcommand play]
+       purpose = start or resume playback
+       non-opts-name = [num]
+       [description]
+               If no argument is given, playback starts at the current
+               position. Otherwise, the corresponding file is loaded
+               and playback is started at the beginning of the file.
+       [/description]
diff --git a/play.c b/play.c
index 1700f9ac467eff2998af7321747360b994698c46..6ca97e6bef58a3bb7c71d3af4137507d0eabb202 100644 (file)
--- a/play.c
+++ b/play.c
@@ -847,16 +847,21 @@ static int com_ls(struct play_task *pt,
 }
 EXPORT_PLAY_CMD_HANDLER(ls);
 
-static int com_play(struct play_task *pt, int argc, char **argv)
+static int com_play(struct play_task *pt, struct lls_parse_result *lpr)
 {
        int32_t x;
        int ret;
-       char state;
+       char state, *errctx;
 
-       if (argc > 2)
-               return -E_PLAY_SYNTAX;
+       ret = lls(lls_check_arg_count(lpr, 0, 1, &errctx));
+       if (ret < 0) {
+               if (errctx)
+                       PARA_ERROR_LOG("%s\n", errctx);
+               free(errctx);
+               return ret;
+       }
        state = get_playback_state(pt);
-       if (argc == 1) {
+       if (lls_num_inputs(lpr) == 0) {
                if (state == 'P')
                        return 0;
                pt->next_file = pt->current_file;
@@ -864,7 +869,7 @@ static int com_play(struct play_task *pt, int argc, char **argv)
                pt->playing = true;
                return 0;
        }
-       ret = para_atoi32(argv[1], &x);
+       ret = para_atoi32(lls_input(0, lpr), &x);
        if (ret < 0)
                return ret;
        if (x < 0 || x >= conf.inputs_num)
@@ -874,6 +879,7 @@ static int com_play(struct play_task *pt, int argc, char **argv)
        pt->rq = CRT_FILE_CHANGE;
        return 0;
 }
+EXPORT_PLAY_CMD_HANDLER(play);
 
 static int com_pause(struct play_task *pt, int argc, __a_unused char **argv)
 {
index 16cec2aaf7123ac131cd20adf0a3ec1dbfacff49..fa6dd58415a1e54d2940fced33fb4a9e338c6fda 100644 (file)
--- a/play.cmd
+++ b/play.cmd
@@ -2,12 +2,6 @@ BN: play
 SF: play.c
 SN: list of commands
 ---
-N: play
-D: Start or resume playing.
-U: play [<num>]
-H: Without <num>, starts playing at the current position. Otherwise, the
-H: corresponding file is loaded and playback is started.
----
 N: pause
 D: Stop playing.
 U: pause