From patchwork Thu Aug 31 13:37:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: keqiao.zhang@intel.com X-Patchwork-Id: 9932199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 886EA602F0 for ; Thu, 31 Aug 2017 13:41:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 797BE2897A for ; Thu, 31 Aug 2017 13:41:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 781EB28982; Thu, 31 Aug 2017 13:41:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9915228992 for ; Thu, 31 Aug 2017 13:41:05 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 08D4B2673D9; Thu, 31 Aug 2017 15:40:48 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8C5232673D5; Thu, 31 Aug 2017 15:40:44 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by alsa0.perex.cz (Postfix) with ESMTP id EAF812673C4 for ; Thu, 31 Aug 2017 15:40:41 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Aug 2017 06:40:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.41,453,1498546800"; d="scan'208"; a="1212993054" Received: from zkq-optiplex-9020.sh.intel.com ([10.239.13.132]) by fmsmga002.fm.intel.com with ESMTP; 31 Aug 2017 06:40:38 -0700 From: Zhang Keqiao To: alsa-devel@alsa-project.org Date: Thu, 31 Aug 2017 21:37:06 +0800 Message-Id: <20170831133709.25537-2-keqiao.zhang@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170831133709.25537-1-keqiao.zhang@intel.com> References: <20170831133709.25537-1-keqiao.zhang@intel.com> Cc: keqiao.zhang@intel.com Subject: [alsa-devel] [PATCH v1 1/4] alsabat: add one option for XRUN injections X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP This patch add a new option '-X' to alsabat, this option allows alsabat to do the xrun injection with given period. eg. '-X 100' means do XRUN injections every 100ms for both playback and capture. '-X 100p/c' means do XRUN injections every 100ms for playback/capture. Signed-off-by: Zhang Keqiao --- bat/bat.c | 9 ++++++++- bat/common.h | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/bat/bat.c b/bat/bat.c index 8645770..bf6873a 100644 --- a/bat/bat.c +++ b/bat/bat.c @@ -328,6 +328,7 @@ _("Usage: alsabat [-options]...\n" " -p total number of periods to play/capture\n" " -B buffer size in frames\n" " -E period size in frames\n" +" -X period of xrun injection, given in millisecond\n" " --log=# file that both stdout and strerr redirecting to\n" " --file=# file for playback\n" " --saveplay=# file that storing playback content, for debug\n" @@ -367,6 +368,9 @@ static void set_defaults(struct bat *bat) bat->buffer_size = 0; bat->period_size = 0; bat->roundtriplatency = false; + bat->xrun_period = 0; + bat->xrun_playback = 0; + bat->xrun_capture = 0; #ifdef HAVE_LIBTINYALSA bat->channels = 2; bat->playback.fct = &playback_tinyalsa; @@ -386,7 +390,7 @@ static void set_defaults(struct bat *bat) static void parse_arguments(struct bat *bat, int argc, char *argv[]) { int c, option_index, err; - static const char short_options[] = "D:P:C:f:n:F:c:r:s:k:p:B:E:lth"; + static const char short_options[] = "D:P:C:f:n:F:c:r:s:k:p:B:E:X:lth"; static const struct option long_options[] = { {"help", 0, 0, 'h'}, {"log", 1, 0, OPT_LOG}, @@ -479,6 +483,9 @@ static void parse_arguments(struct bat *bat, int argc, char *argv[]) bat->period_size = err >= MIN_PERIODSIZE && err < MAX_PERIODSIZE ? err : 0; break; + case 'X': + bat->xarg = optarg; + break; case 'h': default: usage(bat); diff --git a/bat/common.h b/bat/common.h index 1b07fbe..a014f87 100644 --- a/bat/common.h +++ b/bat/common.h @@ -214,6 +214,9 @@ struct bat { enum _bat_pcm_format format; /* PCM format */ int buffer_size; /* buffer size in frames */ int period_size; /* period size in frames */ + int xrun_playback; /* enable xrun injection for playback */ + int xrun_capture; /* enable xrun injection for capture */ + int xrun_period; /* period of XRUN injections, given in milliseconds */ float sigma_k; /* threshold for peak detection */ float snr_thd_db; /* threshold for noise detection (dB) */ @@ -221,6 +224,7 @@ struct bat { int sinus_duration; /* number of frames for playback */ char *narg; /* argument string of duration */ + char *xarg; /* argument string of xrun injection */ char *logarg; /* path name of log file */ char *debugplay; /* path name to store playback signal */ bool standalone; /* enable to bypass analysis */