From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49216) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4TV1-0006oy-W8 for qemu-devel@nongnu.org; Mon, 15 Jun 2015 08:28:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z4TUy-00063f-NM for qemu-devel@nongnu.org; Mon, 15 Jun 2015 08:28:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33593) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4TUy-00062Q-8B for qemu-devel@nongnu.org; Mon, 15 Jun 2015 08:28:20 -0400 From: Gerd Hoffmann Date: Mon, 15 Jun 2015 14:28:10 +0200 Message-Id: <1434371291-6994-20-git-send-email-kraxel@redhat.com> In-Reply-To: <1434371291-6994-1-git-send-email-kraxel@redhat.com> References: <1434371291-6994-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 19/20] alsaaudio: use trace events instead of verbose List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= From: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Signed-off-by: Gerd Hoffmann --- 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 4bcf58f..6315b2d 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" =20 #if QEMU_GNUC_PREREQ(4, 3) #pragma GCC diagnostic ignored "-Waddress" @@ -49,7 +50,6 @@ typedef struct ALSAConf { =20 int buffer_size_out_overridden; int period_size_out_overridden; - int verbose; } ALSAConf; =20 struct pollhlp { @@ -180,7 +180,6 @@ static void alsa_poll_handler (void *opaque) snd_pcm_state_t state; struct pollhlp *hlp =3D opaque; unsigned short revents; - ALSAConf *conf =3D hlp->conf; =20 count =3D poll (hlp->pfds, hlp->count, 0); if (count < 0) { @@ -202,9 +201,7 @@ static void alsa_poll_handler (void *opaque) } =20 if (!(revents & hlp->mask)) { - if (conf->verbose) { - dolog ("revents =3D %d\n", revents); - } + trace_alsa_revents(revents); return; } =20 @@ -239,7 +236,6 @@ static int alsa_poll_helper (snd_pcm_t *handle, struc= t pollhlp *hlp, int mask) { int i, count, err; struct pollfd *pfds; - ALSAConf *conf =3D hlp->conf; =20 count =3D snd_pcm_poll_descriptors_count (handle); if (count <=3D 0) { @@ -267,15 +263,10 @@ static int alsa_poll_helper (snd_pcm_t *handle, str= uct pollhlp *hlp, int mask) qemu_set_fd_handler (pfds[i].fd, alsa_poll_handler, NULL, hl= p); } if (pfds[i].events & POLLOUT) { - if (conf->verbose) { - dolog ("POLLOUT %d %d\n", i, pfds[i].fd); - } + trace_alsa_pollout(i, pfds[i].fd); qemu_set_fd_handler (pfds[i].fd, NULL, alsa_poll_handler, hl= p); } - if (conf->verbose) { - dolog ("Set handler events=3D%#x index=3D%d fd=3D%d err=3D%d= \n", - pfds[i].events, i, pfds[i].fd, err); - } + trace_alsa_set_handler(pfds[i].events, i, pfds[i].fd, err); =20 } hlp->pfds =3D pfds; @@ -509,7 +500,7 @@ static int alsa_open (int in, struct alsa_params_req = *req, } =20 err =3D 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); } =20 @@ -673,10 +664,9 @@ static int alsa_open (int in, struct alsa_params_req= *req, =20 *handlep =3D handle; =20 - if (conf->verbose && - (obtfmt !=3D req->fmt || + if (obtfmt !=3D req->fmt || obt->nchannels !=3D req->nchannels || - obt->freq !=3D req->freq)) { + obt->freq !=3D req->freq) { dolog ("Audio parameters for %s\n", typ); alsa_dump_info (req, obt, obtfmt); } @@ -716,7 +706,6 @@ static snd_pcm_sframes_t alsa_get_avail (snd_pcm_t *h= andle) static void alsa_write_pending (ALSAVoiceOut *alsa) { HWVoiceOut *hw =3D &alsa->hw; - ALSAConf *conf =3D alsa->pollhlp.conf; =20 while (alsa->pending) { int left_till_end_samples =3D hw->samples - alsa->wpos; @@ -731,9 +720,7 @@ static void alsa_write_pending (ALSAVoiceOut *alsa) if (written <=3D 0) { switch (written) { case 0: - if (conf->verbose) { - dolog ("Failed to write %d frames (wrote zero)\n= ", len); - } + trace_alsa_wrote_zero(len); return; =20 case -EPIPE: @@ -742,9 +729,7 @@ static void alsa_write_pending (ALSAVoiceOut *alsa) len); return; } - if (conf->verbose) { - dolog ("Recovering from playback xrun\n"); - } + trace_alsa_xrun_out(); continue; =20 case -ESTRPIPE: @@ -755,9 +740,7 @@ static void alsa_write_pending (ALSAVoiceOut *alsa) len); return; } - if (conf->verbose) { - dolog ("Resuming suspended output stream\n"); - } + trace_alsa_resume_out(); continue; =20 case -EAGAIN: @@ -990,7 +973,6 @@ static int alsa_run_in (HWVoiceIn *hw) }; snd_pcm_sframes_t avail; snd_pcm_uframes_t read_samples =3D 0; - ALSAConf *conf =3D alsa->pollhlp.conf; =20 if (!dead) { return 0; @@ -1016,14 +998,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", sta= te); - } + trace_alsa_no_frames(state); return 0; } } @@ -1058,9 +1036,7 @@ static int alsa_run_in (HWVoiceIn *hw) if (nread <=3D 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; =20 case -EPIPE: @@ -1068,9 +1044,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; =20 case -EAGAIN: @@ -1221,12 +1195,6 @@ static struct audio_option alsa_options[] =3D { .valp =3D &glob_conf.pcm_name_in, .descr =3D "ADC device name" }, - { - .name =3D "VERBOSE", - .tag =3D AUD_OPT_BOOL, - .valp =3D &glob_conf.verbose, - .descr =3D "Behave in a more verbose way" - }, { /* End of list */ } }; =20 diff --git a/trace-events b/trace-events index 6060d36..409a64a 100644 --- a/trace-events +++ b/trace-events @@ -1632,3 +1632,15 @@ cpu_unhalt(int cpu_index) "unhalting cpu %d" =20 # 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 =3D %d" +alsa_pollout(int i, int fd) "i =3D %d fd =3D %d" +alsa_set_handler(int events, int index, int fd, int err) "events=3D%#x i= ndex=3D%d fd=3D%d err=3D%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" --=20 1.8.3.1