OSDN Git Service

axfer: enable each backend to print own help
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Fri, 7 Dec 2018 09:41:02 +0000 (18:41 +0900)
committerTakashi Iwai <tiwai@suse.de>
Fri, 7 Dec 2018 09:57:44 +0000 (10:57 +0100)
This commit adds an operation for xfer backend to print help text.
In this time, content of the help is not implemented yet.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
axfer/xfer-libasound.c
axfer/xfer-libffado.c
axfer/xfer-options.c
axfer/xfer.c
axfer/xfer.h

index bacd835..c774ced 100644 (file)
@@ -880,6 +880,11 @@ static void xfer_libasound_destroy(struct xfer_context *xfer)
        state->log = NULL;
 }
 
+static void xfer_libasound_help(struct xfer_context *xfer)
+{
+       printf("      (placeholder)\n");
+}
+
 const struct xfer_data xfer_libasound = {
        .s_opts = S_OPTS,
        .l_opts = l_opts,
@@ -893,6 +898,7 @@ const struct xfer_data xfer_libasound = {
                .pause          = xfer_libasound_pause,
                .post_process   = xfer_libasound_post_process,
                .destroy        = xfer_libasound_destroy,
+               .help           = xfer_libasound_help,
        },
        .private_size = sizeof(struct libasound_state),
 };
index 3b52e2c..0052336 100644 (file)
@@ -537,6 +537,11 @@ static void xfer_libffado_destroy(struct xfer_context *xfer)
        state->guid_literal = NULL;
 }
 
+static void xfer_libffado_help(struct xfer_context *xfer)
+{
+       printf("      (placeholder)\n");
+}
+
 const struct xfer_data xfer_libffado = {
        .s_opts = S_OPTS,
        .l_opts = l_opts,
@@ -550,6 +555,7 @@ const struct xfer_data xfer_libffado = {
                .pause          = xfer_libffado_pause,
                .post_process   = xfer_libffado_post_process,
                .destroy        = xfer_libffado_destroy,
+               .help           = xfer_libffado_help,
        },
        .private_size = sizeof(struct libffado_state),
 };
index aaa30d5..b81bcb2 100644 (file)
@@ -373,6 +373,12 @@ int xfer_options_parse_args(struct xfer_context *xfer,
 
        if (xfer->help) {
                print_help();
+               if (xfer->ops->help) {
+                       printf("\n");
+                       printf("    BACKEND-OPTIONS (%s) =\n",
+                              xfer_label_from_type(xfer->type));
+                       xfer->ops->help(xfer);
+               }
                return 0;
        }
 
index fdf6e60..6682b3b 100644 (file)
@@ -30,6 +30,11 @@ enum xfer_type xfer_type_from_label(const char *label)
        return XFER_TYPE_UNSUPPORTED;
 }
 
+const char *xfer_label_from_type(enum xfer_type type)
+{
+       return xfer_type_labels[type];
+}
+
 int xfer_context_init(struct xfer_context *xfer, enum xfer_type type,
                      snd_pcm_stream_t direction, int argc, char *const *argv)
 {
index db2e296..24349cd 100644 (file)
@@ -53,6 +53,7 @@ struct xfer_context {
 };
 
 enum xfer_type xfer_type_from_label(const char *label);
+const char *xfer_label_from_type(enum xfer_type type);
 
 int xfer_context_init(struct xfer_context *xfer, enum xfer_type type,
                      snd_pcm_stream_t direction, int argc, char *const *argv);
@@ -96,6 +97,7 @@ struct xfer_ops {
        void (*post_process)(struct xfer_context *xfer);
        void (*destroy)(struct xfer_context *xfer);
        void (*pause)(struct xfer_context *xfer, bool enable);
+       void (*help)(struct xfer_context *xfer);
 };
 
 struct xfer_data {