[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.19-233-g53b046d

Lennart Poettering gitmailer-noreply at 0pointer.de
Wed Nov 4 18:27:34 PST 2009


This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.

The master branch has been updated
      from  83b181f92af6a06ad5f127fea36323d7277ad6cf (commit)

- Log -----------------------------------------------------------------
53b046d alsa: disable timer-based scheduling inside a VM
c079cee daemon: during startup say whether we run in a VM
642c69b core-util: add call to detect if we are called from within a VM
19516d4 alsa: introduce more standard path names
-----------------------------------------------------------------------

Summary of changes:
 src/daemon/main.c              |    3 +-
 src/modules/alsa/alsa-mixer.c  |   24 ++++++----
 src/modules/alsa/alsa-sink.c   |    5 +--
 src/modules/alsa/alsa-source.c |    5 +--
 src/modules/alsa/alsa-util.c   |   24 +++++++++++
 src/modules/alsa/alsa-util.h   |    2 +
 src/pulsecore/core-util.c      |   89 ++++++++++++++++++++++++++++++++++++++++
 src/pulsecore/core-util.h      |    3 +
 8 files changed, 136 insertions(+), 19 deletions(-)

-----------------------------------------------------------------------

commit 19516d4e7f4b6db205681931ad1c4bc1b6bef363
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Nov 5 03:21:10 2009 +0100

    alsa: introduce more standard path names

diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index f3ce681..8b13239 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -1712,7 +1712,9 @@ static int option_verify(pa_alsa_option *o) {
         { "input-boost-on",            N_("Boost") },
         { "input-boost-off",           N_("No Boost") },
         { "output-amplifier-on",       N_("Amplifier") },
-        { "output-amplifier-off",      N_("No Amplifier") }
+        { "output-amplifier-off",      N_("No Amplifier") },
+        { "output-speaker",            N_("Speaker") },
+        { "output-headphones",         N_("Headphones") }
     };
 
     pa_assert(o);
@@ -1770,15 +1772,17 @@ static int element_verify(pa_alsa_element *e) {
 
 static int path_verify(pa_alsa_path *p) {
     static const struct description_map well_known_descriptions[] = {
-        { "analog-input",              N_("Analog Input") },
-        { "analog-input-microphone",   N_("Analog Microphone") },
-        { "analog-input-linein",       N_("Analog Line-In") },
-        { "analog-input-radio",        N_("Analog Radio") },
-        { "analog-input-video",        N_("Analog Video") },
-        { "analog-output",             N_("Analog Output") },
-        { "analog-output-headphones",  N_("Analog Headphones") },
-        { "analog-output-lfe-on-mono", N_("Analog Output (LFE)") },
-        { "analog-output-mono",        N_("Analog Mono Output") }
+        { "analog-input",               N_("Analog Input") },
+        { "analog-input-microphone",    N_("Analog Microphone") },
+        { "analog-input-linein",        N_("Analog Line-In") },
+        { "analog-input-radio",         N_("Analog Radio") },
+        { "analog-input-video",         N_("Analog Video") },
+        { "analog-output",              N_("Analog Output") },
+        { "analog-output-headphones",   N_("Analog Headphones") },
+        { "analog-output-lfe-on-mono",  N_("Analog Output (LFE)") },
+        { "analog-output-mono",         N_("Analog Mono Output") },
+        { "analog-output-headphones-2", N_("Analog Headphones 2") },
+        { "analog-output-speaker",      N_("Analog Speaker") }
     };
 
     pa_alsa_element *e;

commit 642c69bed85ce7c0be57bd08af0cf7243228f08b
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Nov 5 03:22:15 2009 +0100

    core-util: add call to detect if we are called from within a VM

diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 2b0a60a..93ddf30 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -2944,6 +2944,7 @@ int pa_pipe_cloexec(int pipefd[2]) {
 
     if (errno != EINVAL && errno != ENOSYS)
         return r;
+
 #endif
 
     if ((r = pipe(pipefd)) < 0)
@@ -2965,6 +2966,7 @@ int pa_accept_cloexec(int sockfd, struct sockaddr *addr, socklen_t *addrlen) {
 
     if (errno != EINVAL && errno != ENOSYS)
         return fd;
+
 #endif
 
     if ((fd = accept(sockfd, addr, addrlen)) < 0)
@@ -3015,3 +3017,90 @@ void pa_nullify_stdfds(void) {
 #endif
 
 }
+
+char *pa_read_line_from_file(const char *fn) {
+    FILE *f;
+    char ln[256] = "", *r;
+
+    if (!(f = pa_fopen_cloexec(fn, "r")))
+        return NULL;
+
+    r = fgets(ln, sizeof(ln)-1, f);
+    fclose(f);
+
+    if (!r) {
+        errno = EIO;
+        return NULL;
+    }
+
+    pa_strip_nl(ln);
+    return pa_xstrdup(ln);
+}
+
+pa_bool_t pa_running_in_vm(void) {
+
+#if defined(__i386__) || defined(__x86_64__)
+
+    /* Both CPUID and DMI are x86 specific interfaces... */
+
+    uint32_t eax = 0x40000000;
+    union {
+        uint32_t sig32[3];
+        char text[13];
+    } sig;
+
+#ifdef __linux__
+    const char *const dmi_vendors[] = {
+        "/sys/class/dmi/id/sys_vendor",
+        "/sys/class/dmi/id/board_vendor",
+        "/sys/class/dmi/id/bios_vendor"
+    };
+
+    unsigned i;
+
+    for (i = 0; i < PA_ELEMENTSOF(dmi_vendors); i++) {
+        char *s;
+
+        if ((s = pa_read_line_from_file(dmi_vendors[i]))) {
+
+            if (pa_startswith(s, "QEMU") ||
+                /* http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458 */
+                pa_startswith(s, "VMware") ||
+                pa_startswith(s, "VMW") ||
+                pa_startswith(s, "Microsoft Corporation") ||
+                pa_startswith(s, "innotek GmbH") ||
+                pa_startswith(s, "Xen")) {
+
+                pa_xfree(s);
+                return TRUE;
+            }
+
+            pa_xfree(s);
+        }
+    }
+
+#endif
+
+    /* http://lwn.net/Articles/301888/ */
+    pa_zero(sig);
+
+    __asm__ __volatile__ (
+        "  xor %%ebx, %%ebx          \n\t"
+        "  cpuid                     \n\t"
+
+        : "=a" (eax), "=b" (sig.sig32[0]), "=c" (sig.sig32[1]), "=d" (sig.sig32[2])
+        : "0" (eax)
+    );
+
+    if (pa_streq(sig.text, "XenVMMXenVMM") ||
+        pa_streq(sig.text, "KVMKVMKVM") ||
+        /* http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458 */
+        pa_streq(sig.text, "VMwareVMware") ||
+        /* http://msdn.microsoft.com/en-us/library/bb969719.aspx */
+        pa_streq(sig.text, "Microsoft Hv"))
+        return TRUE;
+
+#endif
+
+    return FALSE;
+}
diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
index 9c9cf78..31a83bc 100644
--- a/src/pulsecore/core-util.h
+++ b/src/pulsecore/core-util.h
@@ -267,4 +267,7 @@ FILE* pa_fopen_cloexec(const char *path, const char *mode);
 
 void pa_nullify_stdfds(void);
 
+char *pa_read_line_from_file(const char *fn);
+pa_bool_t pa_running_in_vm(void);
+
 #endif

commit c079ceeba00c77a93c613ecf4a3f2cb516db0753
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Nov 5 03:22:48 2009 +0100

    daemon: during startup say whether we run in a VM

diff --git a/src/daemon/main.c b/src/daemon/main.c
index cc6f24b..4891182 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -648,7 +648,6 @@ int main(int argc, char *argv[]) {
 
     if (conf->daemonize) {
         pid_t child;
-        int tty_fd;
 
         if (pa_stdio_acquire() < 0) {
             pa_log(_("Failed to acquire stdio."));
@@ -781,6 +780,8 @@ int main(int argc, char *argv[]) {
 
     pa_log_debug(_("Running in valgrind mode: %s"), pa_yes_no(pa_in_valgrind()));
 
+    pa_log_debug(_("Running in VM: %s"), pa_yes_no(pa_running_in_vm()));
+
 #ifdef __OPTIMIZE__
     pa_log_debug(_("Optimized build: yes"));
 #else

commit 53b046d5c9593d848270e85017c2999a61256e0e
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Nov 5 03:23:08 2009 +0100

    alsa: disable timer-based scheduling inside a VM
    
    In virtual machines sound card clocks and OS scheduling tend to become
    unreliable, adding various 'uneven' latencies. The adaptive algorithm
    that handles drop-outs does not handle it this well: in contrast to
    drop-outs on real machines that are evenly distributed, small and can
    easily be encountered via the adpative algorithms, drop-outs in VMs tend
    to happen abruptly, and massively, which is not easy to counter.
    
    This patch simply disables timer based scheduling in VMs reverting to
    classic IO based scheduling. This should help make PA perform better in
    VMs.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=532775

diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 37419d9..856adb1 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -1698,10 +1698,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
         goto fail;
     }
 
-    if (use_tsched && !pa_rtclock_hrtimer()) {
-        pa_log_notice("Disabling timer-based scheduling because high-resolution timers are not available from the kernel.");
-        use_tsched = FALSE;
-    }
+    use_tsched = pa_alsa_may_tsched(use_tsched);
 
     u = pa_xnew0(struct userdata, 1);
     u->core = m->core;
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 37dd647..e775b20 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -1541,10 +1541,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
         goto fail;
     }
 
-    if (use_tsched && !pa_rtclock_hrtimer()) {
-        pa_log_notice("Disabling timer-based scheduling because high-resolution timers are not available from the kernel.");
-        use_tsched = FALSE;
-    }
+    use_tsched = pa_alsa_may_tsched(use_tsched);
 
     u = pa_xnew0(struct userdata, 1);
     u->core = m->core;
diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
index 0e22d17..b8d1357 100644
--- a/src/modules/alsa/alsa-util.c
+++ b/src/modules/alsa/alsa-util.c
@@ -43,6 +43,7 @@
 #include <pulsecore/once.h>
 #include <pulsecore/thread.h>
 #include <pulsecore/conf-parser.h>
+#include <pulsecore/core-rtclock.h>
 
 #include "alsa-util.h"
 #include "alsa-mixer.h"
@@ -1308,3 +1309,26 @@ const char* pa_alsa_strerror(int errnum) {
 
     return translated;
 }
+
+pa_bool_t pa_alsa_may_tsched(pa_bool_t want) {
+
+    if (!want)
+        return FALSE;
+
+    if (!pa_rtclock_hrtimer()) {
+        /* We cannot depend on being woken up in time when the timers
+        are inaccurate, so let's fallback to classic IO based playback
+        then. */
+        pa_log_notice("Disabling timer-based scheduling because high-resolution timers are not available from the kernel.");
+        return FALSE; }
+
+    if (pa_running_in_vm()) {
+        /* We cannot depend on being woken up when we ask for in a VM,
+         * so let's fallback to classic IO based playback then. */
+        pa_log_notice("Disabling timer-based scheduling because running inside a VM.");
+        return FALSE;
+    }
+
+
+    return TRUE;
+}
diff --git a/src/modules/alsa/alsa-util.h b/src/modules/alsa/alsa-util.h
index f6206fe..1d1256b 100644
--- a/src/modules/alsa/alsa-util.h
+++ b/src/modules/alsa/alsa-util.h
@@ -142,4 +142,6 @@ pa_bool_t pa_alsa_pcm_is_modem(snd_pcm_t *pcm);
 
 const char* pa_alsa_strerror(int errnum);
 
+pa_bool_t pa_alsa_may_tsched(pa_bool_t want);
+
 #endif

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list