[PATCH] alsa: fix 100% CPU load when idle w/ dmix

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

when using dmix as an ALSA output, the output cannot be polled and
ALSA (snd_pcm_poll_descriptors) returns the event mask set to POLLIN
instead. As this event mask is passed to the main loop, the select()
in main_loop_wait() never waits, because the output file descriptor is
never read. So, qemu/kvm ends up busy looping all the time.

The attached patch simply disables the poll mode, when ALSA returns
POLLIN in the event mask for the ALSA playback pcm handle.

-- 
Jindrich Makovicka
--- alsaaudio.c.orig	2010-10-13 12:55:11.000000000 +0200
+++ alsaaudio.c	2010-10-17 12:18:57.928834276 +0200
@@ -266,8 +266,13 @@
 
     for (i = 0; i < count; ++i) {
         if (pfds[i].events & POLLIN) {
-            err = qemu_set_fd_handler (pfds[i].fd, alsa_poll_handler,
-                                       NULL, hlp);
+            if (mask & POLLIN) {
+                err = qemu_set_fd_handler (pfds[i].fd, alsa_poll_handler,
+                                           NULL, hlp);
+            } else {
+                dolog ("Cannot use poll mode for output\n");
+                err = -1;
+            }
         }
         if (pfds[i].events & POLLOUT) {
             if (conf.verbose) {

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux