diff options
author | Miguel GAIO <mgaio35@gmail.com> | 2018-09-27 17:19:36 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2018-10-01 10:49:54 +0200 |
commit | a60f39a4681b369bdcc78a9d1a1067d4a6bb8736 (patch) | |
tree | 6b5682cf2243b07b602c7fbd0322da274e06a9de /hw/usb | |
parent | 3e9191acb797e4298adb853bf6c75cd31af47ef9 (diff) |
ohci: set effectively usb frame rate to 1kHz
USB frame rate is slightly lower than 1kHz: ie. ~950Hz.
Thus usb-audio device is not able to perform a simple audio playback
without underruns on audio backend.
eg. "-device pci-ohci,id=ohci -device usb-audio,bus=ohci.0" vs PulseAudio
backend. more than 50 underruns are observed per second.
Update ohci_sof_time computation, using QEMU_CLOCK_VIRTUAL in
ohci_usb_start(), and increment by usb_frame_time in ohci_sof()
makes USB frame rate close to 1kHz.
This way, no audio underrun are observed during audio playback.
Signed-off-by: Miguel GAIO <mgaio35@gmail.com>
Message-Id: <20180927151936.3647-1-mgaio35@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb')
-rw-r--r-- | hw/usb/hcd-ohci.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 98da5f0f04..66656a1133 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -1253,12 +1253,12 @@ static int ohci_service_ed_list(OHCIState *ohci, uint32_t head, int completion) /* set a timer for EOF */ static void ohci_eof_timer(OHCIState *ohci) { - ohci->sof_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); timer_mod(ohci->eof_timer, ohci->sof_time + usb_frame_time); } /* Set a timer for EOF and generate a SOF event */ static void ohci_sof(OHCIState *ohci) { + ohci->sof_time += usb_frame_time; ohci_eof_timer(ohci); ohci_set_interrupt(ohci, OHCI_INTR_SF); } @@ -1362,6 +1362,7 @@ static int ohci_bus_start(OHCIState *ohci) * can meet some race conditions */ + ohci->sof_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); ohci_eof_timer(ohci); return 1; @@ -1476,6 +1477,9 @@ static uint32_t ohci_get_frame_remaining(OHCIState *ohci) * set already. */ tks = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - ohci->sof_time; + if (tks < 0) { + tks = 0; + } /* avoid muldiv if possible */ if (tks >= usb_frame_time) |