[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.16-test6-25-gdb835de

Lennart Poettering gitmailer-noreply at 0pointer.de
Thu Aug 27 08:07:56 PDT 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  35fcb27a81b35ca0ef2b01f19c140271970d87fe (commit)

- Log -----------------------------------------------------------------
db835de Merge commit 'vudentz/master'
8169a6a Handle DisconnectRequested in bluetooth module.
beb180b convert: add sse/sse2 s16 to float32ne conversions
27bfb76 macro: add macro to align variables
5907089 remap: cleanup assembler a little
9d25467 sample-util: avoid stack overrun
509d9f0 remap: add sse optimized mono to stereo
26bd090 sconv: fix indentation
-----------------------------------------------------------------------

Summary of changes:
 src/Makefile.am                            |    3 +-
 src/modules/bluetooth/bluetooth-util.c     |   17 ++
 src/pulsecore/cpu-x86.c                    |    5 +-
 src/pulsecore/cpu-x86.h                    |    3 +
 src/pulsecore/macro.h                      |    6 +
 src/pulsecore/remap_mmx.c                  |   43 +++---
 src/pulsecore/{remap_mmx.c => remap_sse.c} |   82 +++++-----
 src/pulsecore/sample-util.c                |    4 +-
 src/pulsecore/sconv.c                      |    4 +-
 src/pulsecore/sconv_sse.c                  |  235 ++++++++++++++++++++++++++++
 10 files changed, 331 insertions(+), 71 deletions(-)
 copy src/pulsecore/{remap_mmx.c => remap_sse.c} (60%)
 create mode 100644 src/pulsecore/sconv_sse.c

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

commit 26bd0901ac02cff3a40c36f711c65c28e00806dc
Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date:   Mon Aug 24 17:00:23 2009 +0200

    sconv: fix indentation

diff --git a/src/pulsecore/sconv.c b/src/pulsecore/sconv.c
index d06d698..301f08b 100644
--- a/src/pulsecore/sconv.c
+++ b/src/pulsecore/sconv.c
@@ -52,8 +52,8 @@ static void u8_from_float32ne(unsigned n, const float *a, uint8_t *b) {
     for (; n > 0; n--, a++, b++) {
         float v;
         v = (*a * 127.0) + 128.0;
-	v = PA_CLAMP_UNLIKELY (v, 0.0, 255.0);
-	*b = rint (v);
+        v = PA_CLAMP_UNLIKELY (v, 0.0, 255.0);
+        *b = rint (v);
     }
 }
 

commit 509d9f04e56258e8bcb59b0bb42e84053ba6021c
Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date:   Tue Aug 25 12:27:32 2009 +0200

    remap: add sse optimized mono to stereo

diff --git a/src/Makefile.am b/src/Makefile.am
index e65662c..138256d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -832,7 +832,7 @@ libpulsecore_ at PA_MAJORMINORMICRO@_la_SOURCES = \
 		pulsecore/play-memblockq.c pulsecore/play-memblockq.h \
 		pulsecore/play-memchunk.c pulsecore/play-memchunk.h \
 		pulsecore/remap.c pulsecore/remap.h \
-		pulsecore/remap_mmx.c \
+		pulsecore/remap_mmx.c pulsecore/remap_sse.c \
 		pulsecore/resampler.c pulsecore/resampler.h \
 		pulsecore/rtpoll.c pulsecore/rtpoll.h \
 		pulsecore/sample-util.c pulsecore/sample-util.h \
diff --git a/src/pulsecore/cpu-x86.c b/src/pulsecore/cpu-x86.c
index bc093ec..6f0cecc 100644
--- a/src/pulsecore/cpu-x86.c
+++ b/src/pulsecore/cpu-x86.c
@@ -115,8 +115,10 @@ void pa_cpu_init_x86 (void) {
         pa_remap_func_init_mmx (flags);
     }
 
-    if (flags & PA_CPU_X86_SSE)
+    if (flags & PA_CPU_X86_SSE) {
         pa_volume_func_init_sse (flags);
+        pa_remap_func_init_sse (flags);
+    }
 
 #endif /* defined (__i386__) || defined (__amd64__) */
 }
diff --git a/src/pulsecore/cpu-x86.h b/src/pulsecore/cpu-x86.h
index b11ef6e..b67555b 100644
--- a/src/pulsecore/cpu-x86.h
+++ b/src/pulsecore/cpu-x86.h
@@ -64,5 +64,6 @@ void pa_volume_func_init_mmx(pa_cpu_x86_flag_t flags);
 void pa_volume_func_init_sse(pa_cpu_x86_flag_t flags);
 
 void pa_remap_func_init_mmx(pa_cpu_x86_flag_t flags);
+void pa_remap_func_init_sse(pa_cpu_x86_flag_t flags);
 
 #endif /* foocpux86hfoo */
diff --git a/src/pulsecore/remap_sse.c b/src/pulsecore/remap_sse.c
new file mode 100644
index 0000000..e086862
--- /dev/null
+++ b/src/pulsecore/remap_sse.c
@@ -0,0 +1,148 @@
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2004-2006 Lennart Poettering
+  Copyright 2009 Wim Taymans <wim.taymans at collabora.co.uk.com>
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2.1 of the License,
+  or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+
+#include <pulse/sample.h>
+#include <pulsecore/log.h>
+#include <pulsecore/macro.h>
+
+#include "cpu-x86.h"
+#include "remap.h"
+
+#define LOAD_SAMPLES                                   \
+                " movdqu (%1), %%xmm0           \n\t"  \
+                " movdqu 16(%1), %%xmm2         \n\t"  \
+                " movdqu 32(%1), %%xmm4         \n\t"  \
+                " movdqu 48(%1), %%xmm6         \n\t"  \
+                " movdqa %%xmm0, %%xmm1         \n\t"  \
+                " movdqa %%xmm2, %%xmm3         \n\t"  \
+                " movdqa %%xmm4, %%xmm5         \n\t"  \
+                " movdqa %%xmm6, %%xmm7         \n\t"
+
+#define UNPACK_SAMPLES(s)                              \
+                " punpckl"#s" %%xmm0, %%xmm0    \n\t"  \
+                " punpckh"#s" %%xmm1, %%xmm1    \n\t"  \
+                " punpckl"#s" %%xmm2, %%xmm2    \n\t"  \
+                " punpckh"#s" %%xmm3, %%xmm3    \n\t"  \
+                " punpckl"#s" %%xmm4, %%xmm4    \n\t"  \
+                " punpckh"#s" %%xmm5, %%xmm5    \n\t"  \
+                " punpckl"#s" %%xmm6, %%xmm6    \n\t"  \
+                " punpckh"#s" %%xmm7, %%xmm7    \n\t"  \
+
+#define STORE_SAMPLES                                  \
+                " movdqu %%xmm0, (%0)           \n\t"  \
+                " movdqu %%xmm1, 16(%0)         \n\t"  \
+                " movdqu %%xmm2, 32(%0)         \n\t"  \
+                " movdqu %%xmm3, 48(%0)         \n\t"  \
+                " movdqu %%xmm4, 64(%0)         \n\t"  \
+                " movdqu %%xmm5, 80(%0)         \n\t"  \
+                " movdqu %%xmm6, 96(%0)         \n\t"  \
+                " movdqu %%xmm7, 112(%0)        \n\t"  \
+                " add $64, %1                   \n\t"  \
+                " add $128, %0                  \n\t"
+
+#define HANDLE_SINGLE(s)                               \
+                " movd (%1), %%mm0              \n\t"  \
+                " movq %%mm0, %%mm1             \n\t"  \
+                " punpckl"#s" %%mm0, %%mm0      \n\t"  \
+                " movq %%mm0, (%0)              \n\t"  \
+                " add $4, %1                    \n\t"  \
+                " add $8, %0                    \n\t"
+
+#define MONO_TO_STEREO(s)                               \
+                " mov %3, %2                    \n\t"   \
+                " sar $4, %2                    \n\t"   \
+                " cmp $0, %2                    \n\t"   \
+                " je 2f                         \n\t"   \
+                "1:                             \n\t"   \
+                LOAD_SAMPLES                            \
+                UNPACK_SAMPLES(s)                       \
+                STORE_SAMPLES                           \
+                " dec %2                        \n\t"   \
+                " jne 1b                        \n\t"   \
+                "2:                             \n\t"   \
+                " mov %3, %2                    \n\t"   \
+                " and $15, %2                   \n\t"   \
+                " je 4f                         \n\t"   \
+                "3:                             \n\t"   \
+                HANDLE_SINGLE(s)                        \
+                " dec %2                        \n\t"   \
+                " jne 3b                        \n\t"   \
+                "4:                             \n\t"   \
+                " emms                          \n\t"
+
+static void remap_mono_to_stereo_sse (pa_remap_t *m, void *dst, const void *src, unsigned n) {
+    pa_reg_x86 temp;
+
+    switch (*m->format) {
+        case PA_SAMPLE_FLOAT32NE:
+        {
+            __asm__ __volatile__ (
+                MONO_TO_STEREO(dq) /* do doubles to quads */
+                : "+r" (dst), "+r" (src), "=&r" (temp)
+                : "r" ((pa_reg_x86)n)
+                : "cc"
+            );
+            break;
+        }
+        case PA_SAMPLE_S16NE:
+        {
+            __asm__ __volatile__ (
+                MONO_TO_STEREO(wd) /* do words to doubles */
+                : "+r" (dst), "+r" (src), "=&r" (temp)
+                : "r" ((pa_reg_x86)n)
+                : "cc"
+            );
+            break;
+        }
+        default:
+            pa_assert_not_reached();
+    }
+}
+
+/* set the function that will execute the remapping based on the matrices */
+static void init_remap_sse (pa_remap_t *m) {
+    unsigned n_oc, n_ic;
+
+    n_oc = m->o_ss->channels;
+    n_ic = m->i_ss->channels;
+
+    /* find some common channel remappings, fall back to full matrix operation. */
+    if (n_ic == 1 && n_oc == 2 &&
+            m->map_table_f[0][0] >= 1.0 && m->map_table_f[1][0] >= 1.0) {
+        m->do_remap = (pa_do_remap_func_t) remap_mono_to_stereo_sse;
+        pa_log_info("Using SSE mono to stereo remapping");
+    }
+}
+
+void pa_remap_func_init_sse (pa_cpu_x86_flag_t flags) {
+#if defined (__i386__) || defined (__amd64__)
+    pa_log_info("Initialising SSE optimized remappers.");
+
+    pa_set_init_remap_func ((pa_init_remap_func_t) init_remap_sse);
+#endif /* defined (__i386__) || defined (__amd64__) */
+}

commit 9d254679649fe3810ec9885251999a084bb7bacb
Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date:   Tue Aug 25 17:40:44 2009 +0200

    sample-util: avoid stack overrun
    
    The linear volume array needs enough padding when preparing the volumes for
    mixing.

diff --git a/src/pulsecore/sample-util.c b/src/pulsecore/sample-util.c
index 6e97e5a..5fae192 100644
--- a/src/pulsecore/sample-util.c
+++ b/src/pulsecore/sample-util.c
@@ -137,7 +137,7 @@ static void calc_linear_float_volume(float linear[], const pa_cvolume *volume) {
 
 static void calc_linear_integer_stream_volumes(pa_mix_info streams[], unsigned nstreams, const pa_cvolume *volume, const pa_sample_spec *spec) {
     unsigned k, channel;
-    float linear[PA_CHANNELS_MAX];
+    float linear[PA_CHANNELS_MAX + VOLUME_PADDING];
 
     pa_assert(streams);
     pa_assert(spec);
@@ -156,7 +156,7 @@ static void calc_linear_integer_stream_volumes(pa_mix_info streams[], unsigned n
 
 static void calc_linear_float_stream_volumes(pa_mix_info streams[], unsigned nstreams, const pa_cvolume *volume, const pa_sample_spec *spec) {
     unsigned k, channel;
-    float linear[PA_CHANNELS_MAX];
+    float linear[PA_CHANNELS_MAX + VOLUME_PADDING];
 
     pa_assert(streams);
     pa_assert(spec);

commit 59070892ed070d0c42d8d9b91d267a39c5763a9c
Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date:   Wed Aug 26 19:29:21 2009 +0200

    remap: cleanup assembler a little

diff --git a/src/pulsecore/remap_mmx.c b/src/pulsecore/remap_mmx.c
index 00252da..b5fe82e 100644
--- a/src/pulsecore/remap_mmx.c
+++ b/src/pulsecore/remap_mmx.c
@@ -51,7 +51,7 @@
                 " punpckl"#s" %%mm4, %%mm4      \n\t"  \
                 " punpckh"#s" %%mm5, %%mm5      \n\t"  \
                 " punpckl"#s" %%mm6, %%mm6      \n\t"  \
-                " punpckh"#s" %%mm7, %%mm7      \n\t"  \
+                " punpckh"#s" %%mm7, %%mm7      \n\t"
 
 #define STORE_SAMPLES                                  \
                 " movq %%mm0, (%0)              \n\t"  \
@@ -67,32 +67,31 @@
 
 #define HANDLE_SINGLE(s)                               \
                 " movd (%1), %%mm0              \n\t"  \
-                " movq %%mm0, %%mm1             \n\t"  \
                 " punpckl"#s" %%mm0, %%mm0      \n\t"  \
                 " movq %%mm0, (%0)              \n\t"  \
                 " add $4, %1                    \n\t"  \
                 " add $8, %0                    \n\t"
 
-#define MONO_TO_STEREO(s)                               \
-                " mov %3, %2                    \n\t"   \
-                " sar $3, %2                    \n\t"   \
-                " cmp $0, %2                    \n\t"   \
-                " je 2f                         \n\t"   \
-                "1:                             \n\t"   \
-                LOAD_SAMPLES                            \
-                UNPACK_SAMPLES(s)                       \
-                STORE_SAMPLES                           \
-                " dec %2                        \n\t"   \
-                " jne 1b                        \n\t"   \
-                "2:                             \n\t"   \
-                " mov %3, %2                    \n\t"   \
-                " and $7, %2                    \n\t"   \
-                " je 4f                         \n\t"   \
-                "3:                             \n\t"   \
-                HANDLE_SINGLE(s)                        \
-                " dec %2                        \n\t"   \
-                " jne 3b                        \n\t"   \
-                "4:                             \n\t"   \
+#define MONO_TO_STEREO(s)                              \
+                " mov %3, %2                    \n\t"  \
+                " sar $3, %2                    \n\t"  \
+                " cmp $0, %2                    \n\t"  \
+                " je 2f                         \n\t"  \
+                "1:                             \n\t"  \
+                LOAD_SAMPLES                           \
+                UNPACK_SAMPLES(s)                      \
+                STORE_SAMPLES                          \
+                " dec %2                        \n\t"  \
+                " jne 1b                        \n\t"  \
+                "2:                             \n\t"  \
+                " mov %3, %2                    \n\t"  \
+                " and $7, %2                    \n\t"  \
+                " je 4f                         \n\t"  \
+                "3:                             \n\t"  \
+                HANDLE_SINGLE(s)                       \
+                " dec %2                        \n\t"  \
+                " jne 3b                        \n\t"  \
+                "4:                             \n\t"  \
                 " emms                          \n\t"
 
 #if defined (__i386__) || defined (__amd64__)
diff --git a/src/pulsecore/remap_sse.c b/src/pulsecore/remap_sse.c
index e086862..97f2476 100644
--- a/src/pulsecore/remap_sse.c
+++ b/src/pulsecore/remap_sse.c
@@ -51,7 +51,7 @@
                 " punpckl"#s" %%xmm4, %%xmm4    \n\t"  \
                 " punpckh"#s" %%xmm5, %%xmm5    \n\t"  \
                 " punpckl"#s" %%xmm6, %%xmm6    \n\t"  \
-                " punpckh"#s" %%xmm7, %%xmm7    \n\t"  \
+                " punpckh"#s" %%xmm7, %%xmm7    \n\t"
 
 #define STORE_SAMPLES                                  \
                 " movdqu %%xmm0, (%0)           \n\t"  \
@@ -66,10 +66,9 @@
                 " add $128, %0                  \n\t"
 
 #define HANDLE_SINGLE(s)                               \
-                " movd (%1), %%mm0              \n\t"  \
-                " movq %%mm0, %%mm1             \n\t"  \
-                " punpckl"#s" %%mm0, %%mm0      \n\t"  \
-                " movq %%mm0, (%0)              \n\t"  \
+                " movd (%1), %%xmm0             \n\t"  \
+                " punpckl"#s" %%xmm0, %%xmm0    \n\t"  \
+                " movq %%xmm0, (%0)             \n\t"  \
                 " add $4, %1                    \n\t"  \
                 " add $8, %0                    \n\t"
 
@@ -92,8 +91,7 @@
                 HANDLE_SINGLE(s)                        \
                 " dec %2                        \n\t"   \
                 " jne 3b                        \n\t"   \
-                "4:                             \n\t"   \
-                " emms                          \n\t"
+                "4:                             \n\t"
 
 static void remap_mono_to_stereo_sse (pa_remap_t *m, void *dst, const void *src, unsigned n) {
     pa_reg_x86 temp;

commit 27bfb7628c709eb6802c9ec73a6feb995fda8375
Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date:   Wed Aug 26 19:29:56 2009 +0200

    macro: add macro to align variables

diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h
index 87684ad..bffcc26 100644
--- a/src/pulsecore/macro.h
+++ b/src/pulsecore/macro.h
@@ -80,6 +80,12 @@ static inline size_t PA_PAGE_ALIGN(size_t l) {
 
 #define PA_ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))
 
+#if defined(__GNUC__)
+    #define PA_DECLARE_ALIGNED(n,t,v)      t v __attribute__ ((aligned (n)))
+#else
+    #define PA_DECLARE_ALIGNED(n,t,v)      t v
+#endif
+
 /* The users of PA_MIN and PA_MAX, PA_CLAMP, PA_ROUND_UP should be
  * aware that these macros on non-GCC executed code with side effects
  * twice. It is thus considered misuse to use code with side effects

commit beb180b7bc5885313cf14d6faf854bc6b805ae11
Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date:   Wed Aug 26 19:30:37 2009 +0200

    convert: add sse/sse2 s16 to float32ne conversions

diff --git a/src/Makefile.am b/src/Makefile.am
index 138256d..654dc41 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -842,6 +842,7 @@ libpulsecore_ at PA_MAJORMINORMICRO@_la_SOURCES = \
 		pulsecore/svolume_mmx.c pulsecore/svolume_sse.c \
 		pulsecore/sconv-s16be.c pulsecore/sconv-s16be.h \
 		pulsecore/sconv-s16le.c pulsecore/sconv-s16le.h \
+		pulsecore/sconv_sse.c \
 		pulsecore/sconv.c pulsecore/sconv.h \
 		pulsecore/shared.c pulsecore/shared.h \
 		pulsecore/shm.c pulsecore/shm.h \
diff --git a/src/pulsecore/cpu-x86.c b/src/pulsecore/cpu-x86.c
index 6f0cecc..1ba9f1a 100644
--- a/src/pulsecore/cpu-x86.c
+++ b/src/pulsecore/cpu-x86.c
@@ -118,6 +118,7 @@ void pa_cpu_init_x86 (void) {
     if (flags & PA_CPU_X86_SSE) {
         pa_volume_func_init_sse (flags);
         pa_remap_func_init_sse (flags);
+        pa_convert_func_init_sse (flags);
     }
 
 #endif /* defined (__i386__) || defined (__amd64__) */
diff --git a/src/pulsecore/cpu-x86.h b/src/pulsecore/cpu-x86.h
index b67555b..b40eb5c 100644
--- a/src/pulsecore/cpu-x86.h
+++ b/src/pulsecore/cpu-x86.h
@@ -66,4 +66,6 @@ void pa_volume_func_init_sse(pa_cpu_x86_flag_t flags);
 void pa_remap_func_init_mmx(pa_cpu_x86_flag_t flags);
 void pa_remap_func_init_sse(pa_cpu_x86_flag_t flags);
 
+void pa_convert_func_init_sse (pa_cpu_x86_flag_t flags);
+
 #endif /* foocpux86hfoo */
diff --git a/src/pulsecore/sconv_sse.c b/src/pulsecore/sconv_sse.c
new file mode 100644
index 0000000..b213d99
--- /dev/null
+++ b/src/pulsecore/sconv_sse.c
@@ -0,0 +1,235 @@
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2004-2006 Lennart Poettering
+  Copyright 2006 Pierre Ossman <ossman at cendio.se> for Cendio AB
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2.1 of the License,
+  or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <pulsecore/g711.h>
+#include <pulsecore/macro.h>
+
+#include "endianmacros.h"
+
+#include "cpu-x86.h"
+#include "sconv.h"
+
+static pa_convert_func_t func;
+
+#if defined (__i386__) || defined (__amd64__)
+
+static const PA_DECLARE_ALIGNED (16, float, one[4]) = { 1.0, 1.0, 1.0, 1.0 };
+static const PA_DECLARE_ALIGNED (16, float, mone[4]) = { -1.0, -1.0, -1.0, -1.0 };
+static const PA_DECLARE_ALIGNED (16, float, scale[4]) = { 0x7fff, 0x7fff, 0x7fff, 0x7fff };
+
+static void pa_sconv_s16le_from_f32ne_sse(unsigned n, const float *a, int16_t *b) {
+    pa_reg_x86 temp, i;
+
+    __asm__ __volatile__ (
+        " movaps %5, %%xmm5             \n\t"
+        " movaps %6, %%xmm6             \n\t"
+        " movaps %7, %%xmm7             \n\t"
+        " xor %0, %0                    \n\t"
+
+        " mov %4, %1                    \n\t"
+        " sar $3, %1                    \n\t" /* 8 floats at a time */
+        " cmp $0, %1                    \n\t"
+        " je 2f                         \n\t"
+
+        "1:                             \n\t"
+        " movups (%2, %0, 2), %%xmm0    \n\t" /* read 8 floats */
+        " movups 16(%2, %0, 2), %%xmm2  \n\t"
+        " minps  %%xmm5, %%xmm0         \n\t" /* clamp to 1.0 */
+        " minps  %%xmm5, %%xmm2         \n\t"
+        " maxps  %%xmm6, %%xmm0         \n\t" /* clamp to -1.0 */
+        " maxps  %%xmm6, %%xmm2         \n\t"
+        " mulps  %%xmm7, %%xmm0         \n\t" /* *= 0x7fff */
+        " mulps  %%xmm7, %%xmm2         \n\t"
+
+        " cvtps2pi %%xmm0, %%mm0        \n\t" /* low part to int */
+        " cvtps2pi %%xmm2, %%mm2        \n\t"
+        " movhlps  %%xmm0, %%xmm0       \n\t" /* bring high part in position */
+        " movhlps  %%xmm2, %%xmm2       \n\t"
+        " cvtps2pi %%xmm0, %%mm1        \n\t" /* high part to int */
+        " cvtps2pi %%xmm2, %%mm3        \n\t"
+
+        " packssdw %%mm1, %%mm0         \n\t" /* pack parts */
+        " packssdw %%mm3, %%mm2         \n\t"
+        " movq     %%mm0, (%3, %0)      \n\t"
+        " movq    %%mm2, 8(%3, %0)     \n\t"
+
+        " add $16, %0                   \n\t"
+        " dec %1                        \n\t"
+        " jne 1b                        \n\t"
+
+        "2:                             \n\t"
+        " mov %4, %1                    \n\t" /* prepare for leftovers */
+        " and $15, %1                   \n\t"
+        " je 4f                         \n\t"
+
+        "3:                             \n\t"
+        " movss (%2, %0, 2), %%xmm0     \n\t"
+        " minss  %%xmm5, %%xmm0         \n\t"
+        " maxss  %%xmm6, %%xmm0         \n\t"
+        " mulss  %%xmm7, %%xmm0         \n\t"
+        " cvtss2si %%xmm0, %4           \n\t"
+        " movw  %w4, (%3, %0)           \n\t"
+        " add $2, %0                    \n\t"
+        " dec %1                        \n\t"
+        " jne 3b                        \n\t"
+
+        "4:                             \n\t"
+        " emms                          \n\t"
+
+        : "=&r" (i), "=&r" (temp)
+        : "r" (a), "r" (b), "r" ((pa_reg_x86)n), "m" (*one), "m" (*mone), "m" (*scale)
+        : "cc", "memory"
+    );
+}
+
+static void pa_sconv_s16le_from_f32ne_sse2(unsigned n, const float *a, int16_t *b) {
+    pa_reg_x86 temp, i;
+
+    __asm__ __volatile__ (
+        " movaps %5, %%xmm5             \n\t"
+        " movaps %6, %%xmm6             \n\t"
+        " movaps %7, %%xmm7             \n\t"
+        " xor %0, %0                    \n\t"
+
+        " mov %4, %1                    \n\t"
+        " sar $3, %1                    \n\t" /* 8 floats at a time */
+        " cmp $0, %1                    \n\t"
+        " je 2f                         \n\t"
+
+        "1:                             \n\t"
+        " movups (%2, %0, 2), %%xmm0    \n\t" /* read 8 floats */
+        " movups 16(%2, %0, 2), %%xmm2  \n\t"
+        " minps  %%xmm5, %%xmm0         \n\t" /* clamp to 1.0 */
+        " minps  %%xmm5, %%xmm2         \n\t"
+        " maxps  %%xmm6, %%xmm0         \n\t" /* clamp to -1.0 */
+        " maxps  %%xmm6, %%xmm2         \n\t"
+        " mulps  %%xmm7, %%xmm0         \n\t" /* *= 0x7fff */
+        " mulps  %%xmm7, %%xmm2         \n\t"
+
+        " cvtps2dq %%xmm0, %%xmm0       \n\t"
+        " cvtps2dq %%xmm2, %%xmm2       \n\t"
+
+        " packssdw %%xmm2, %%xmm0       \n\t"
+        " movdqu   %%xmm0, (%3, %0)     \n\t"
+
+        " add $16, %0                   \n\t"
+        " dec %1                        \n\t"
+        " jne 1b                        \n\t"
+
+        "2:                             \n\t"
+        " mov %4, %1                    \n\t" /* prepare for leftovers */
+        " and $15, %1                   \n\t"
+        " je 4f                         \n\t"
+
+        "3:                             \n\t"
+        " movss (%2, %0, 2), %%xmm0     \n\t"
+        " minss  %%xmm5, %%xmm0         \n\t"
+        " maxss  %%xmm6, %%xmm0         \n\t"
+        " mulss  %%xmm7, %%xmm0         \n\t"
+        " cvtss2si %%xmm0, %4           \n\t"
+        " movw  %w4, (%3, %0)           \n\t"
+        " add $2, %0                    \n\t"
+        " dec %1                        \n\t"
+        " jne 3b                        \n\t"
+
+        "4:                             \n\t"
+
+        : "=&r" (i), "=&r" (temp)
+        : "r" (a), "r" (b), "r" ((pa_reg_x86)n), "m" (*one), "m" (*mone), "m" (*scale)
+        : "cc", "memory"
+    );
+}
+
+#undef RUN_TEST
+
+#ifdef RUN_TEST
+#define SAMPLES 1019
+#define TIMES 1000
+
+static void run_test (void) {
+    int16_t samples[SAMPLES];
+    int16_t samples_ref[SAMPLES];
+    float floats[SAMPLES];
+    int i;
+    pa_usec_t start, stop;
+
+    printf ("checking SSE %zd\n", sizeof (samples));
+
+    memset (samples_ref, 0, sizeof (samples_ref));
+    memset (samples, 0, sizeof (samples));
+
+    for (i = 0; i < SAMPLES; i++) {
+        floats[i] = (rand()/(RAND_MAX+2.2)) - 1.1;
+    }
+
+    func = pa_get_convert_from_float32ne_function (PA_SAMPLE_S16LE);
+    func (SAMPLES, floats, samples_ref);
+    pa_sconv_s16le_from_f32ne_sse2 (SAMPLES, floats, samples);
+
+    for (i = 0; i < SAMPLES; i++) {
+        if (samples[i] != samples_ref[i]) {
+            printf ("%d: %04x != %04x (%f)\n", i, samples[i], samples_ref[i],
+                      floats[i]);
+        }
+    }
+
+    start = pa_rtclock_now();
+    for (i = 0; i < TIMES; i++) {
+        pa_sconv_s16le_from_f32ne_sse2 (SAMPLES, floats, samples);
+    }
+    stop = pa_rtclock_now();
+    pa_log_info("SSE: %llu usec.", (long long unsigned int)(stop - start));
+
+    start = pa_rtclock_now();
+    for (i = 0; i < TIMES; i++) {
+        func (SAMPLES, floats, samples_ref);
+    }
+    stop = pa_rtclock_now();
+    pa_log_info("ref: %llu usec.", (long long unsigned int)(stop - start));
+}
+#endif
+#endif /* defined (__i386__) || defined (__amd64__) */
+
+
+void pa_convert_func_init_sse (pa_cpu_x86_flag_t flags) {
+#if defined (__i386__) || defined (__amd64__)
+    pa_log_info("Initialising SSE optimized conversions.");
+
+#ifdef RUN_TEST
+    run_test ();
+#endif
+
+    if (flags & PA_CPU_X86_SSE2)
+      pa_set_convert_from_float32ne_function (PA_SAMPLE_S16LE, (pa_convert_func_t) pa_sconv_s16le_from_f32ne_sse2);
+    else
+      pa_set_convert_from_float32ne_function (PA_SAMPLE_S16LE, (pa_convert_func_t) pa_sconv_s16le_from_f32ne_sse);
+
+#endif /* defined (__i386__) || defined (__amd64__) */
+}
+

commit 8169a6a6c921215c1353e8a34fccbdc4e2e20440
Author: Luiz Augusto von Dentz <luiz.dentz at openbossa.org>
Date:   Thu Aug 27 11:29:49 2009 -0300

    Handle DisconnectRequested in bluetooth module.

diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index d0c89aa..f8c5b77 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -662,6 +662,21 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
 
         return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 
+    } else if (dbus_message_is_signal(m, "org.bluez.Device", "DisconnectRequested")) {
+        pa_bluetooth_device *d;
+
+        if ((d = pa_hashmap_get(y->devices, dbus_message_get_path(m)))) {
+            /* Device will disconnect in 2 sec */
+            d->audio_state = PA_BT_AUDIO_STATE_DISCONNECTED;
+            d->audio_sink_state = PA_BT_AUDIO_STATE_DISCONNECTED;
+            d->audio_source_state = PA_BT_AUDIO_STATE_DISCONNECTED;
+            d->headset_state = PA_BT_AUDIO_STATE_DISCONNECTED;
+
+            run_callback(y, d, FALSE);
+        }
+
+        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
     } else if (dbus_message_is_signal(m, "org.freedesktop.DBus", "NameOwnerChanged")) {
         const char *name, *old_owner, *new_owner;
 
@@ -775,6 +790,7 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
                 "type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceRemoved'",
                 "type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceCreated'",
                 "type='signal',sender='org.bluez',interface='org.bluez.Device',member='PropertyChanged'",
+                "type='signal',sender='org.bluez',interface='org.bluez.Device',member='DisconnectRequested'",
                 "type='signal',sender='org.bluez',interface='org.bluez.Audio',member='PropertyChanged'",
                 "type='signal',sender='org.bluez',interface='org.bluez.Headset',member='PropertyChanged'",
                 "type='signal',sender='org.bluez',interface='org.bluez.AudioSink',member='PropertyChanged'",
@@ -828,6 +844,7 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
                                "type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceRemoved'",
                                "type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceCreated'",
                                "type='signal',sender='org.bluez',interface='org.bluez.Device',member='PropertyChanged'",
+                               "type='signal',sender='org.bluez',interface='org.bluez.Device',member='DisconnectRequested'",
                                "type='signal',sender='org.bluez',interface='org.bluez.Audio',member='PropertyChanged'",
                                "type='signal',sender='org.bluez',interface='org.bluez.Headset',member='PropertyChanged'",
                                "type='signal',sender='org.bluez',interface='org.bluez.AudioSink',member='PropertyChanged'",

commit db835deb9814e26b2999f66bdd455a1fd4ff0044
Merge: beb180b 8169a6a
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Aug 27 17:08:15 2009 +0200

    Merge commit 'vudentz/master'


-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list