From a4d88ae13bc60e3f6269334d633495668af0c640 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Fri, 8 Sep 2017 11:13:49 +0300 Subject: [PATCH] osmo-gapk: fix I/O combinations check Previously both ALSA source and sink were out of attention. --- src/app_osmo_gapk.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/app_osmo_gapk.c b/src/app_osmo_gapk.c index 16a614d..720e08b 100644 --- a/src/app_osmo_gapk.c +++ b/src/app_osmo_gapk.c @@ -332,15 +332,27 @@ check_options(struct gapk_state *gs) } } - /* Input combinations */ - if (gs->opts.fname_in && gs->opts.rtp_in.port) { - LOGP(DAPP, LOGL_ERROR, "You have to decide on either file or RTP input\n"); - return -EINVAL; - } + /* Check I/O combinations */ + int src_count = 0; + int sink_count = 0; - /* Output combinations */ - if (gs->opts.fname_out && gs->opts.rtp_out.port) { - LOGP(DAPP, LOGL_ERROR, "You have to decide on either file or RTP output\n"); + if (gs->opts.fname_in) + src_count++; + if (gs->opts.rtp_in.port) + src_count++; + if (gs->opts.alsa_in) + src_count++; + + if (gs->opts.fname_out) + sink_count++; + if (gs->opts.rtp_out.port) + sink_count++; + if (gs->opts.alsa_out) + sink_count++; + + if (src_count != 1 || sink_count != 1) { + LOGP(DAPP, LOGL_ERROR, "You have to decide on " + "a single input and a single output\n"); return -EINVAL; }