From cf648324893c2323d6bf50c03b293ffc820acb02 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 28 Mar 2016 03:49:45 +0000 Subject: [PATCH] play: Convert com_play() to lopsub. Straight forward conversion, slight improvement of the help text. --- m4/lls/play_cmd.suite.m4 | 9 +++++++++ play.c | 18 ++++++++++++------ play.cmd | 6 ------ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/m4/lls/play_cmd.suite.m4 b/m4/lls/play_cmd.suite.m4 index f1434aff..3632b184 100644 --- a/m4/lls/play_cmd.suite.m4 +++ b/m4/lls/play_cmd.suite.m4 @@ -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 1700f9ac..6ca97e6b 100644 --- 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) { diff --git a/play.cmd b/play.cmd index 16cec2aa..fa6dd584 100644 --- 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 [] -H: Without , starts playing at the current position. Otherwise, the -H: corresponding file is loaded and playback is started. ---- N: pause D: Stop playing. U: pause -- 2.30.2