From patchwork Fri Jun 12 12:33:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?UTF-8?B?Wm9sdMOhbiBLxZF2w6Fnw7M=?= X-Patchwork-Id: 483545 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BD590140285 for ; Fri, 12 Jun 2015 22:39:28 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=Fq+Oyr15; dkim-atps=neutral Received: from localhost ([::1]:51080 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z3OF4-0007i3-Oz for incoming@patchwork.ozlabs.org; Fri, 12 Jun 2015 08:39:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z3O96-0007Hu-9h for qemu-devel@nongnu.org; Fri, 12 Jun 2015 08:33:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z3O95-0004F3-1P for qemu-devel@nongnu.org; Fri, 12 Jun 2015 08:33:16 -0400 Received: from mail-wg0-x235.google.com ([2a00:1450:400c:c00::235]:34357) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z3O94-0004Ec-Oh for qemu-devel@nongnu.org; Fri, 12 Jun 2015 08:33:14 -0400 Received: by wgv5 with SMTP id 5so23869603wgv.1 for ; Fri, 12 Jun 2015 05:33:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=Xt7gM09/uKWWaCB7ssl3+07Agx6XIdDDynkzD1lSDPw=; b=Fq+Oyr150LqPB15HMePwIJOPmcKBt0u7oL3XExAfOYy6ku/iAE8+Wkl5xpIvnjJcoK M++GkIAAKl037g7hJQsemoyCB9QvPZIANNRtfkv7mEnLtaBaF2Qt4Ki/93H7E+vU1MHT bk98KwmvD+QVtSgCBs6QeIngWwDQ9LWO+swqaT88OmSBnEwrZOj2jFEr8CTpRw7AHt85 InTs9/y82DweyVF+DnsycV9wAParuzic5QEq5MlbGwqjDriS0tGDmr78NxQy1qLZ1GRd +6mERgJELRp2XDN31TlccUlne9XtpB7hD4Pz0ohj9aQe4GzE9Dsh2w8UtWy+oCWusfAX /7gA== X-Received: by 10.194.176.68 with SMTP id cg4mr17162754wjc.106.1434112394056; Fri, 12 Jun 2015 05:33:14 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (94-21-76-230.pool.digikabel.hu. [94.21.76.230]) by mx.google.com with ESMTPSA id m2sm2569153wiy.7.2015.06.12.05.33.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Jun 2015 05:33:13 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Fri, 12 Jun 2015 14:33:06 +0200 Message-Id: <343960dbc79a10895bdc9ace0ae2df4a67ee2fc7.1434111578.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.4.2 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c00::235 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 05/12] alsaaudio: use trace events instead of verbose X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Kővágó, Zoltán --- audio/alsaaudio.c | 60 +++++++++++++------------------------------------------ trace-events | 12 +++++++++++ 2 files changed, 26 insertions(+), 46 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index d7e181b..b0a451a 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -25,6 +25,7 @@ #include "qemu-common.h" #include "qemu/main-loop.h" #include "audio.h" +#include "trace.h" #if QEMU_GNUC_PREREQ(4, 3) #pragma GCC diagnostic ignored "-Waddress" @@ -49,7 +50,6 @@ typedef struct ALSAConf { int buffer_size_out_overridden; int period_size_out_overridden; - int verbose; } ALSAConf; struct pollhlp { @@ -180,7 +180,6 @@ static void alsa_poll_handler (void *opaque) snd_pcm_state_t state; struct pollhlp *hlp = opaque; unsigned short revents; - ALSAConf *conf = hlp->conf; count = poll (hlp->pfds, hlp->count, 0); if (count < 0) { @@ -202,9 +201,7 @@ static void alsa_poll_handler (void *opaque) } if (!(revents & hlp->mask)) { - if (conf->verbose) { - dolog ("revents = %d\n", revents); - } + trace_alsa_revents(revents); return; } @@ -239,7 +236,6 @@ static int alsa_poll_helper (snd_pcm_t *handle, struct pollhlp *hlp, int mask) { int i, count, err; struct pollfd *pfds; - ALSAConf *conf = hlp->conf; count = snd_pcm_poll_descriptors_count (handle); if (count <= 0) { @@ -268,16 +264,11 @@ static int alsa_poll_helper (snd_pcm_t *handle, struct pollhlp *hlp, int mask) NULL, hlp); } if (pfds[i].events & POLLOUT) { - if (conf->verbose) { - dolog ("POLLOUT %d %d\n", i, pfds[i].fd); - } + trace_alsa_pollout(i, pfds[i].fd); err = qemu_set_fd_handler (pfds[i].fd, NULL, alsa_poll_handler, hlp); } - if (conf->verbose) { - dolog ("Set handler events=%#x index=%d fd=%d err=%d\n", - pfds[i].events, i, pfds[i].fd, err); - } + trace_alsa_set_handler(pfds[i].events, i, pfds[i].fd, err); if (err) { dolog ("Failed to set handler events=%#x index=%d fd=%d err=%d\n", @@ -521,7 +512,7 @@ static int alsa_open (int in, struct alsa_params_req *req, } err = snd_pcm_hw_params_set_format (handle, hw_params, req->fmt); - if (err < 0 && conf->verbose) { + if (err < 0) { alsa_logerr2 (err, typ, "Failed to set format %d\n", req->fmt); } @@ -685,10 +676,9 @@ static int alsa_open (int in, struct alsa_params_req *req, *handlep = handle; - if (conf->verbose && - (obtfmt != req->fmt || + if (obtfmt != req->fmt || obt->nchannels != req->nchannels || - obt->freq != req->freq)) { + obt->freq != req->freq) { dolog ("Audio parameters for %s\n", typ); alsa_dump_info (req, obt, obtfmt); } @@ -728,7 +718,6 @@ static snd_pcm_sframes_t alsa_get_avail (snd_pcm_t *handle) static void alsa_write_pending (ALSAVoiceOut *alsa) { HWVoiceOut *hw = &alsa->hw; - ALSAConf *conf = alsa->pollhlp.conf; while (alsa->pending) { int left_till_end_samples = hw->samples - alsa->wpos; @@ -743,9 +732,7 @@ static void alsa_write_pending (ALSAVoiceOut *alsa) if (written <= 0) { switch (written) { case 0: - if (conf->verbose) { - dolog ("Failed to write %d frames (wrote zero)\n", len); - } + trace_alsa_wrote_zero(len); return; case -EPIPE: @@ -754,9 +741,7 @@ static void alsa_write_pending (ALSAVoiceOut *alsa) len); return; } - if (conf->verbose) { - dolog ("Recovering from playback xrun\n"); - } + trace_alsa_xrun_out(); continue; case -ESTRPIPE: @@ -767,9 +752,7 @@ static void alsa_write_pending (ALSAVoiceOut *alsa) len); return; } - if (conf->verbose) { - dolog ("Resuming suspended output stream\n"); - } + trace_alsa_resume_out(); continue; case -EAGAIN: @@ -1002,7 +985,6 @@ static int alsa_run_in (HWVoiceIn *hw) }; snd_pcm_sframes_t avail; snd_pcm_uframes_t read_samples = 0; - ALSAConf *conf = alsa->pollhlp.conf; if (!dead) { return 0; @@ -1028,14 +1010,10 @@ static int alsa_run_in (HWVoiceIn *hw) dolog ("Failed to resume suspended input stream\n"); return 0; } - if (conf->verbose) { - dolog ("Resuming suspended input stream\n"); - } + trace_alsa_resume_in(); break; default: - if (conf->verbose) { - dolog ("No frames available and ALSA state is %d\n", state); - } + trace_alsa_no_frames(state); return 0; } } @@ -1070,9 +1048,7 @@ static int alsa_run_in (HWVoiceIn *hw) if (nread <= 0) { switch (nread) { case 0: - if (conf->verbose) { - dolog ("Failed to read %ld frames (read zero)\n", len); - } + trace_alsa_read_zero(len); goto exit; case -EPIPE: @@ -1080,9 +1056,7 @@ static int alsa_run_in (HWVoiceIn *hw) alsa_logerr (nread, "Failed to read %ld frames\n", len); goto exit; } - if (conf->verbose) { - dolog ("Recovering from capture xrun\n"); - } + trace_alsa_xrun_in(); continue; case -EAGAIN: @@ -1233,12 +1207,6 @@ static struct audio_option alsa_options[] = { .valp = &glob_conf.pcm_name_in, .descr = "ADC device name" }, - { - .name = "VERBOSE", - .tag = AUD_OPT_BOOL, - .valp = &glob_conf.verbose, - .descr = "Behave in a more verbose way" - }, { /* End of list */ } }; diff --git a/trace-events b/trace-events index 1abca7a..0f372bb 100644 --- a/trace-events +++ b/trace-events @@ -1626,3 +1626,15 @@ cpu_unhalt(int cpu_index) "unhalting cpu %d" # hw/arm/virt-acpi-build.c virt_acpi_setup(void) "No fw cfg or ACPI disabled. Bailing out." + +# audio/alsaaudio.c +alsa_revents(int revents) "revents = %d" +alsa_pollout(int i, int fd) "i = %d fd = %d" +alsa_set_handler(int events, int index, int fd, int err) "events=%#x index=%d fd=%d err=%d" +alsa_wrote_zero(int len) "Failed to write %d frames (wrote zero)" +alsa_read_zero(long len) "Failed to read %ld frames (read zero)" +alsa_xrun_out(void) "Recovering from playback xrun" +alsa_xrun_in(void) "Recovering from capture xrun" +alsa_resume_out(void) "Resuming suspended output stream" +alsa_resume_in(void) "Resuming suspended input stream" +alsa_no_frames(int state) "No frames available and ALSA state is %d"