aboutsummaryrefslogtreecommitdiff
path: root/audio/audio.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2018-07-02 18:15:24 +0200
committerGerd Hoffmann <kraxel@redhat.com>2018-07-03 11:46:47 +0200
commit1a961e785f59eba1fa8e06d5b1ebc84927b4b3a3 (patch)
tree61acaa2a2125d04ced8f5f66c0d741b0267f1737 /audio/audio.c
parentcabedbc24eb53c3feee612750929a7e307600e20 (diff)
downloadqemu-1a961e785f59eba1fa8e06d5b1ebc84927b4b3a3.zip
qemu-1a961e785f59eba1fa8e06d5b1ebc84927b4b3a3.tar.gz
qemu-1a961e785f59eba1fa8e06d5b1ebc84927b4b3a3.tar.bz2
audio: add audio timer trace points
Track audio timer starts and stops. Also trace delayed audio timer calls. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-id: 20180702161524.17268-1-kraxel@redhat.com
Diffstat (limited to 'audio/audio.c')
-rw-r--r--audio/audio.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/audio/audio.c b/audio/audio.c
index d6e9190..1ace47f 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -29,6 +29,7 @@
#include "sysemu/sysemu.h"
#include "qemu/cutils.h"
#include "sysemu/replay.h"
+#include "trace.h"
#define AUDIO_CAP "audio"
#include "audio_int.h"
@@ -1129,6 +1130,10 @@ static void audio_pcm_print_info (const char *cap, struct audio_pcm_info *info)
/*
* Timer
*/
+
+static bool audio_timer_running;
+static uint64_t audio_timer_last;
+
static int audio_is_timer_needed (void)
{
HWVoiceIn *hwi = NULL;
@@ -1148,14 +1153,31 @@ static void audio_reset_timer (AudioState *s)
if (audio_is_timer_needed ()) {
timer_mod_anticipate_ns(s->ts,
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + conf.period.ticks);
- }
- else {
- timer_del (s->ts);
+ if (!audio_timer_running) {
+ audio_timer_running = true;
+ audio_timer_last = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
+ trace_audio_timer_start(conf.period.ticks / SCALE_MS);
+ }
+ } else {
+ timer_del(s->ts);
+ if (audio_timer_running) {
+ audio_timer_running = false;
+ trace_audio_timer_stop();
+ }
}
}
static void audio_timer (void *opaque)
{
+ int64_t now, diff;
+
+ now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
+ diff = now - audio_timer_last;
+ if (diff > conf.period.ticks * 3 / 2) {
+ trace_audio_timer_delayed(diff / SCALE_MS);
+ }
+ audio_timer_last = now;
+
audio_run ("timer");
audio_reset_timer (opaque);
}