void print_filter_helps(bool detailed);
int filter_setup(const char *fa, void **conf, struct lls_parse_result **lprp);
#define FILTER_CMD(_num) (lls_cmd(_num, filter_cmd_suite))
+#define FILTER_CMD_OPT(_cmd, _opt) (lls_opt( \
+ LSG_FILTER_CMD_ ## _cmd ## _OPT_ ## _opt, \
+ FILTER_CMD(LSG_FILTER_CMD_CMD_ ## _cmd)))
#define FILTER_CMD_OPT_RESULT(_cmd, _opt, _lpr) \
(lls_opt_result(LSG_FILTER_CMD_ ## _cmd ## _OPT_ ## _opt, _lpr))
#define FILTER_CMD_OPT_GIVEN(_cmd, _opt, _lpr) \
static int resample_init(struct filter_node *fn)
{
- int ret, converter = *(int *)fn->conf;
+ int ret;
+ const uint32_t trafo[] = {
+ [RCT_BEST] = SRC_SINC_BEST_QUALITY,
+ [RCT_MEDIUM] = SRC_SINC_MEDIUM_QUALITY,
+ [RCT_FASTEST] = SRC_SINC_FASTEST,
+ [RCT_ZERO_ORDER_HOLD] = SRC_ZERO_ORDER_HOLD,
+ [RCT_LINEAR] = SRC_LINEAR
+ };
struct resample_context *ctx = fn->private_data;
+ const struct lls_option *o_c = FILTER_CMD_OPT(RESAMPLE, CONVERTER);
+ uint32_t converter = U32_OPTVAL(CONVERTER, fn->lpr);
+ PARA_INFO_LOG("converter type: %s\n",
+ lls_enum_string_val(converter, o_c));
ret = resample_set_params(fn);
if (ret < 0)
return ret;
- ctx->src_state = src_new(converter, U32_OPTVAL(CHANNELS, fn->lpr), &ret);
+ ctx->src_state = src_new(trafo[converter],
+ U32_OPTVAL(CHANNELS, fn->lpr), &ret);
if (!ctx->src_state) {
PARA_ERROR_LOG("%s\n", src_strerror(ret));
return -E_LIBSAMPLERATE;
static void *resample_setup(const struct lls_parse_result *lpr)
{
- int given, *converter;
- const char *converter_arg;
+ int given;
uint32_t u32;
/* sanity checks */
PARA_EMERG_LOG("fatal: destination sample rate can not be 0\n");
exit(EXIT_FAILURE);
}
- converter = para_malloc(sizeof(int));
- converter_arg = FILTER_CMD_OPT_STRING_VAL(RESAMPLE, CONVERTER, lpr);
- if (!strcmp(converter_arg, "best"))
- *converter = SRC_SINC_BEST_QUALITY;
- else if (!strcmp(converter_arg, "medium"))
- *converter = SRC_SINC_MEDIUM_QUALITY;
- else if (!strcmp(converter_arg, "fastest"))
- *converter = SRC_SINC_FASTEST;
- else if (!strcmp(converter_arg, "zero_order_hold"))
- *converter = SRC_ZERO_ORDER_HOLD;
- else if (!strcmp(converter_arg, "linear"))
- *converter = SRC_LINEAR;
- else {
- PARA_EMERG_LOG("invalid converter type: %s\n", converter_arg);
- exit(EXIT_FAILURE);
- }
- return converter;
+ return NULL;
}
static void resample_teardown(__a_unused const struct lls_parse_result *lpr,