提交 fbb7ef56 编写于 作者: K Kővágó, Zoltán 提交者: Gerd Hoffmann

alsaaudio: use trace events instead of verbose

Signed-off-by: NKővágó, Zoltán <DirtY.iCE.hu@gmail.com>
Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
上级 6dd35fd8
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "qemu-common.h" #include "qemu-common.h"
#include "qemu/main-loop.h" #include "qemu/main-loop.h"
#include "audio.h" #include "audio.h"
#include "trace.h"
#if QEMU_GNUC_PREREQ(4, 3) #if QEMU_GNUC_PREREQ(4, 3)
#pragma GCC diagnostic ignored "-Waddress" #pragma GCC diagnostic ignored "-Waddress"
...@@ -49,7 +50,6 @@ typedef struct ALSAConf { ...@@ -49,7 +50,6 @@ typedef struct ALSAConf {
int buffer_size_out_overridden; int buffer_size_out_overridden;
int period_size_out_overridden; int period_size_out_overridden;
int verbose;
} ALSAConf; } ALSAConf;
struct pollhlp { struct pollhlp {
...@@ -180,7 +180,6 @@ static void alsa_poll_handler (void *opaque) ...@@ -180,7 +180,6 @@ static void alsa_poll_handler (void *opaque)
snd_pcm_state_t state; snd_pcm_state_t state;
struct pollhlp *hlp = opaque; struct pollhlp *hlp = opaque;
unsigned short revents; unsigned short revents;
ALSAConf *conf = hlp->conf;
count = poll (hlp->pfds, hlp->count, 0); count = poll (hlp->pfds, hlp->count, 0);
if (count < 0) { if (count < 0) {
...@@ -202,9 +201,7 @@ static void alsa_poll_handler (void *opaque) ...@@ -202,9 +201,7 @@ static void alsa_poll_handler (void *opaque)
} }
if (!(revents & hlp->mask)) { if (!(revents & hlp->mask)) {
if (conf->verbose) { trace_alsa_revents(revents);
dolog ("revents = %d\n", revents);
}
return; return;
} }
...@@ -239,7 +236,6 @@ static int alsa_poll_helper (snd_pcm_t *handle, struct pollhlp *hlp, int mask) ...@@ -239,7 +236,6 @@ static int alsa_poll_helper (snd_pcm_t *handle, struct pollhlp *hlp, int mask)
{ {
int i, count, err; int i, count, err;
struct pollfd *pfds; struct pollfd *pfds;
ALSAConf *conf = hlp->conf;
count = snd_pcm_poll_descriptors_count (handle); count = snd_pcm_poll_descriptors_count (handle);
if (count <= 0) { if (count <= 0) {
...@@ -267,15 +263,10 @@ static int alsa_poll_helper (snd_pcm_t *handle, struct pollhlp *hlp, int mask) ...@@ -267,15 +263,10 @@ static int alsa_poll_helper (snd_pcm_t *handle, struct pollhlp *hlp, int mask)
qemu_set_fd_handler (pfds[i].fd, alsa_poll_handler, NULL, hlp); qemu_set_fd_handler (pfds[i].fd, alsa_poll_handler, NULL, hlp);
} }
if (pfds[i].events & POLLOUT) { if (pfds[i].events & POLLOUT) {
if (conf->verbose) { trace_alsa_pollout(i, pfds[i].fd);
dolog ("POLLOUT %d %d\n", i, pfds[i].fd);
}
qemu_set_fd_handler (pfds[i].fd, NULL, alsa_poll_handler, hlp); qemu_set_fd_handler (pfds[i].fd, NULL, alsa_poll_handler, hlp);
} }
if (conf->verbose) { trace_alsa_set_handler(pfds[i].events, i, pfds[i].fd, err);
dolog ("Set handler events=%#x index=%d fd=%d err=%d\n",
pfds[i].events, i, pfds[i].fd, err);
}
} }
hlp->pfds = pfds; hlp->pfds = pfds;
...@@ -509,7 +500,7 @@ static int alsa_open (int in, struct alsa_params_req *req, ...@@ -509,7 +500,7 @@ static int alsa_open (int in, struct alsa_params_req *req,
} }
err = snd_pcm_hw_params_set_format (handle, hw_params, req->fmt); 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); alsa_logerr2 (err, typ, "Failed to set format %d\n", req->fmt);
} }
...@@ -673,10 +664,9 @@ static int alsa_open (int in, struct alsa_params_req *req, ...@@ -673,10 +664,9 @@ static int alsa_open (int in, struct alsa_params_req *req,
*handlep = handle; *handlep = handle;
if (conf->verbose && if (obtfmt != req->fmt ||
(obtfmt != req->fmt ||
obt->nchannels != req->nchannels || obt->nchannels != req->nchannels ||
obt->freq != req->freq)) { obt->freq != req->freq) {
dolog ("Audio parameters for %s\n", typ); dolog ("Audio parameters for %s\n", typ);
alsa_dump_info (req, obt, obtfmt); alsa_dump_info (req, obt, obtfmt);
} }
...@@ -716,7 +706,6 @@ static snd_pcm_sframes_t alsa_get_avail (snd_pcm_t *handle) ...@@ -716,7 +706,6 @@ static snd_pcm_sframes_t alsa_get_avail (snd_pcm_t *handle)
static void alsa_write_pending (ALSAVoiceOut *alsa) static void alsa_write_pending (ALSAVoiceOut *alsa)
{ {
HWVoiceOut *hw = &alsa->hw; HWVoiceOut *hw = &alsa->hw;
ALSAConf *conf = alsa->pollhlp.conf;
while (alsa->pending) { while (alsa->pending) {
int left_till_end_samples = hw->samples - alsa->wpos; int left_till_end_samples = hw->samples - alsa->wpos;
...@@ -731,9 +720,7 @@ static void alsa_write_pending (ALSAVoiceOut *alsa) ...@@ -731,9 +720,7 @@ static void alsa_write_pending (ALSAVoiceOut *alsa)
if (written <= 0) { if (written <= 0) {
switch (written) { switch (written) {
case 0: case 0:
if (conf->verbose) { trace_alsa_wrote_zero(len);
dolog ("Failed to write %d frames (wrote zero)\n", len);
}
return; return;
case -EPIPE: case -EPIPE:
...@@ -742,9 +729,7 @@ static void alsa_write_pending (ALSAVoiceOut *alsa) ...@@ -742,9 +729,7 @@ static void alsa_write_pending (ALSAVoiceOut *alsa)
len); len);
return; return;
} }
if (conf->verbose) { trace_alsa_xrun_out();
dolog ("Recovering from playback xrun\n");
}
continue; continue;
case -ESTRPIPE: case -ESTRPIPE:
...@@ -755,9 +740,7 @@ static void alsa_write_pending (ALSAVoiceOut *alsa) ...@@ -755,9 +740,7 @@ static void alsa_write_pending (ALSAVoiceOut *alsa)
len); len);
return; return;
} }
if (conf->verbose) { trace_alsa_resume_out();
dolog ("Resuming suspended output stream\n");
}
continue; continue;
case -EAGAIN: case -EAGAIN:
...@@ -990,7 +973,6 @@ static int alsa_run_in (HWVoiceIn *hw) ...@@ -990,7 +973,6 @@ static int alsa_run_in (HWVoiceIn *hw)
}; };
snd_pcm_sframes_t avail; snd_pcm_sframes_t avail;
snd_pcm_uframes_t read_samples = 0; snd_pcm_uframes_t read_samples = 0;
ALSAConf *conf = alsa->pollhlp.conf;
if (!dead) { if (!dead) {
return 0; return 0;
...@@ -1016,14 +998,10 @@ static int alsa_run_in (HWVoiceIn *hw) ...@@ -1016,14 +998,10 @@ static int alsa_run_in (HWVoiceIn *hw)
dolog ("Failed to resume suspended input stream\n"); dolog ("Failed to resume suspended input stream\n");
return 0; return 0;
} }
if (conf->verbose) { trace_alsa_resume_in();
dolog ("Resuming suspended input stream\n");
}
break; break;
default: default:
if (conf->verbose) { trace_alsa_no_frames(state);
dolog ("No frames available and ALSA state is %d\n", state);
}
return 0; return 0;
} }
} }
...@@ -1058,9 +1036,7 @@ static int alsa_run_in (HWVoiceIn *hw) ...@@ -1058,9 +1036,7 @@ static int alsa_run_in (HWVoiceIn *hw)
if (nread <= 0) { if (nread <= 0) {
switch (nread) { switch (nread) {
case 0: case 0:
if (conf->verbose) { trace_alsa_read_zero(len);
dolog ("Failed to read %ld frames (read zero)\n", len);
}
goto exit; goto exit;
case -EPIPE: case -EPIPE:
...@@ -1068,9 +1044,7 @@ static int alsa_run_in (HWVoiceIn *hw) ...@@ -1068,9 +1044,7 @@ static int alsa_run_in (HWVoiceIn *hw)
alsa_logerr (nread, "Failed to read %ld frames\n", len); alsa_logerr (nread, "Failed to read %ld frames\n", len);
goto exit; goto exit;
} }
if (conf->verbose) { trace_alsa_xrun_in();
dolog ("Recovering from capture xrun\n");
}
continue; continue;
case -EAGAIN: case -EAGAIN:
...@@ -1221,12 +1195,6 @@ static struct audio_option alsa_options[] = { ...@@ -1221,12 +1195,6 @@ static struct audio_option alsa_options[] = {
.valp = &glob_conf.pcm_name_in, .valp = &glob_conf.pcm_name_in,
.descr = "ADC device name" .descr = "ADC device name"
}, },
{
.name = "VERBOSE",
.tag = AUD_OPT_BOOL,
.valp = &glob_conf.verbose,
.descr = "Behave in a more verbose way"
},
{ /* End of list */ } { /* End of list */ }
}; };
......
...@@ -1632,3 +1632,15 @@ cpu_unhalt(int cpu_index) "unhalting cpu %d" ...@@ -1632,3 +1632,15 @@ cpu_unhalt(int cpu_index) "unhalting cpu %d"
# hw/arm/virt-acpi-build.c # hw/arm/virt-acpi-build.c
virt_acpi_setup(void) "No fw cfg or ACPI disabled. Bailing out." 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"
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册