lbalhar / rpms / pulseaudio

Forked from rpms/pulseaudio 4 years ago
Clone
Blob Blame History Raw
From 170812755e0ac235ed2b7182ef637eb317d8b2b2 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Wed, 13 Jan 2010 20:31:17 +0100
Subject: [PATCH 14/62] cpu: check for CMOV flag before using this intsruction in assembly

http://pulseaudio.org/ticket/776
---
 src/pulsecore/cpu-x86.c     |    6 +++++-
 src/pulsecore/cpu-x86.h     |    6 +++---
 src/pulsecore/svolume_mmx.c |    2 +-
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/pulsecore/cpu-x86.c b/src/pulsecore/cpu-x86.c
index f194a60..b173072 100644
--- a/src/pulsecore/cpu-x86.c
+++ b/src/pulsecore/cpu-x86.c
@@ -57,6 +57,9 @@ void pa_cpu_init_x86 (void) {
     if (level >= 1) {
         get_cpuid (0x00000001, &eax, &ebx, &ecx, &edx);
 
+        if (edx & (1<<15))
+          flags |= PA_CPU_X86_CMOV;
+
         if (edx & (1<<23))
           flags |= PA_CPU_X86_MMX;
 
@@ -97,7 +100,8 @@ void pa_cpu_init_x86 (void) {
           flags |= PA_CPU_X86_3DNOW;
     }
 
-    pa_log_info ("CPU flags: %s%s%s%s%s%s%s%s%s%s",
+    pa_log_info ("CPU flags: %s%s%s%s%s%s%s%s%s%s%s",
+    (flags & PA_CPU_X86_CMOV) ? "CMOV " : "",
     (flags & PA_CPU_X86_MMX) ? "MMX " : "",
     (flags & PA_CPU_X86_SSE) ? "SSE " : "",
     (flags & PA_CPU_X86_SSE2) ? "SSE2 " : "",
diff --git a/src/pulsecore/cpu-x86.h b/src/pulsecore/cpu-x86.h
index b40eb5c..285c203 100644
--- a/src/pulsecore/cpu-x86.h
+++ b/src/pulsecore/cpu-x86.h
@@ -5,7 +5,7 @@
   This file is part of PulseAudio.
 
   Copyright 2004-2006 Lennart Poettering
-  Copyright 2009 Wim Taymans <wim.taymans@collabora.co.uk> 
+  Copyright 2009 Wim Taymans <wim.taymans@collabora.co.uk>
 
   PulseAudio is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published
@@ -35,12 +35,12 @@ typedef enum pa_cpu_x86_flag {
     PA_CPU_X86_SSE4_1    = (1 << 6),
     PA_CPU_X86_SSE4_2    = (1 << 7),
     PA_CPU_X86_3DNOW     = (1 << 8),
-    PA_CPU_X86_3DNOWEXT  = (1 << 9)
+    PA_CPU_X86_3DNOWEXT  = (1 << 9),
+    PA_CPU_X86_CMOV      = (1 << 10)
 } pa_cpu_x86_flag_t;
 
 void pa_cpu_init_x86 (void);
 
-
 #if defined (__i386__)
 typedef int32_t pa_reg_x86;
 #define PA_REG_a "eax"
diff --git a/src/pulsecore/svolume_mmx.c b/src/pulsecore/svolume_mmx.c
index 46923ed..e50ebee 100644
--- a/src/pulsecore/svolume_mmx.c
+++ b/src/pulsecore/svolume_mmx.c
@@ -305,7 +305,7 @@ void pa_volume_func_init_mmx (pa_cpu_x86_flag_t flags) {
     run_test ();
 #endif
 
-    if (flags & PA_CPU_X86_MMX) {
+    if ((flags & PA_CPU_X86_MMX) && (flags & PA_CPU_X86_CMOV)) {
         pa_log_info("Initialising MMX optimized functions.");
 
         pa_set_volume_func (PA_SAMPLE_S16NE, (pa_do_volume_func_t) pa_volume_s16ne_mmx);
-- 
1.7.0