OSDN Git Service

[vorbis] Add more command line options
authorStarg <starg@users.osdn.me>
Tue, 3 Mar 2020 09:29:34 +0000 (18:29 +0900)
committerStarg <starg@users.osdn.me>
Tue, 3 Mar 2020 09:35:26 +0000 (18:35 +0900)
timidity/timidity.c

index 551cad4..db16b61 100644 (file)
@@ -295,6 +295,8 @@ enum {
        TIM_OPT_SPEEX_DTX,
        TIM_OPT_SPEEX_COMPLEXITY,
        TIM_OPT_SPEEX_NFRAMES,
+       TIM_OPT_VORBIS_COMMENT,
+       TIM_OPT_VORBIS_EMBED_LOOP,
        TIM_OPT_OUTPUT_FILE,
        TIM_OPT_PATCH_FILE,
        TIM_OPT_POLYPHONY,
@@ -550,6 +552,12 @@ static const struct option longopts[] = {
        { "speex-complexity",       required_argument, NULL, TIM_OPT_SPEEX_COMPLEXITY },
        { "speex-nframes",          required_argument, NULL, TIM_OPT_SPEEX_NFRAMES },
 #endif /* AU_SPEEX */
+#ifdef AU_VORBIS
+       { "vorbis-comment",         required_argument, NULL, TIM_OPT_VORBIS_COMMENT },
+#ifdef SUPPORT_LOOPEVENT
+       { "vorbis-embed-loop",      no_argument,       NULL, TIM_OPT_VORBIS_EMBED_LOOP },
+#endif /* SUPPORT_LOOPEVENT */
+#endif /* AU_VORBIS */
        { "output-file",            required_argument, NULL, TIM_OPT_OUTPUT_FILE },
        { "patch-file",             required_argument, NULL, TIM_OPT_PATCH_FILE },
        { "polyphony",              required_argument, NULL, TIM_OPT_POLYPHONY },
@@ -568,8 +576,10 @@ static const struct option longopts[] = {
        { "compute-thread-num",     required_argument, NULL, TIM_OPT_COMPUTE_THREAD_NUM },
        { "trace-mode-update-time", required_argument, NULL, TIM_OPT_TRACE_MODE_UPDATE },       
        { "load-all-instrument",    required_argument, NULL, TIM_OPT_LOAD_ALL_INSTRUMENT },     
+#ifdef SUPPORT_LOOPEVENT
        { "loop-repeat",            required_argument, NULL, TIM_OPT_LOOP_REPEAT },
     { "loop-filter",            required_argument, NULL, TIM_OPT_LOOP_FILTER },
+#endif /* SUPPORT_LOOPEVENT */
 
        { "cache-size",             required_argument, NULL, TIM_OPT_CACHE_SIZE },
        { "sampling-freq",          required_argument, NULL, TIM_OPT_SAMPLE_FREQ },
@@ -794,6 +804,12 @@ static inline int parse_opt_speex_dtx(const char *);
 static inline int parse_opt_speex_complexity(const char *);
 static inline int parse_opt_speex_nframes(const char *);
 #endif /* AU_SPEEX */
+#ifdef AU_VORBIS
+static inline int parse_opt_vorbis_comment(const char *);
+#ifdef SUPPORT_LOOPEVENT
+static inline int parse_opt_vorbis_embed_loop(const char*);
+#endif /* SUPPORT_LOOPEVENT */
+#endif /* AU_VORBIS */
 static inline int parse_opt_o(const char *);
 static inline int parse_opt_P(const char *);
 static inline int parse_opt_p(const char *);
@@ -4441,6 +4457,14 @@ MAIN_INTERFACE int set_tim_opt_long(int c, const char *optarg, int index)
        case TIM_OPT_SPEEX_NFRAMES:
                return parse_opt_speex_nframes(arg);
 #endif /* AU_SPEEX */
+#ifdef AU_VORBIS
+       case TIM_OPT_VORBIS_COMMENT:
+               return parse_opt_vorbis_comment(arg);
+#ifdef SUPPORT_LOOPEVENT
+       case TIM_OPT_VORBIS_EMBED_LOOP:
+               return parse_opt_vorbis_embed_loop(arg);
+#endif /* SUPPORT_LOOPEVENT */
+#endif /* AU_VORBIS */
        case TIM_OPT_OUTPUT_FILE:
                return parse_opt_o(arg);
        case TIM_OPT_PATCH_FILE:
@@ -7405,6 +7429,43 @@ static inline int parse_opt_speex_nframes(const char *arg)
 }
 #endif /* AU_SPEEX */
 
+#ifdef AU_VORBIS
+
+extern void vorbis_set_option_vorbis_comment(const char *tag, const char *contents);
+
+static inline int parse_opt_vorbis_comment(const char *arg)
+{
+       if (!arg) return 0;
+
+       const char *eq = strchr(arg, '=');
+       const char *tagend = eq ? eq : arg;
+
+       char tag[64] = {0};
+       char contents[256] = {0};
+       ptr_size_t taglen = tagend - arg < sizeof(tag) ? tagend - arg : sizeof(tag) - 1;
+       strncpy(tag, arg, taglen);
+       tag[taglen] = '\0';
+
+       strncpy(contents, eq ? eq + 1 : arg, sizeof(contents) - 1);
+       contents[sizeof(contents) - 1] = '\0';
+
+       vorbis_set_option_vorbis_comment(tag, contents);
+       return 0;
+}
+
+#ifdef SUPPORT_LOOPEVENT
+
+extern int ogg_vorbis_embed_loop;
+
+static inline int parse_opt_vorbis_embed_loop(const char *arg)
+{
+       ogg_vorbis_embed_loop = 1;
+       return 0;
+}
+
+#endif /* SUPPORT_LOOPEVENT */
+#endif /* AU_VORBIS */
+
 static inline int parse_opt_o(const char *arg)
 {
        if (!arg) return 0;