media/libsoundtouch/moz-libsoundtouch.patch

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 diff -u /src/cpu_detect_x86.cpp /src/cpu_detect_x86.cpp
michael@0 2 --- /src/cpu_detect_x86.cpp
michael@0 3 +++ /src/cpu_detect_x86.cpp
michael@0 4 @@ -44,9 +44,8 @@
michael@0 5
michael@0 6
michael@0 7 #if defined(SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS)
michael@0 8 -
michael@0 9 - #if defined(__GNUC__) && defined(__i386__)
michael@0 10 - // gcc
michael@0 11 + #if defined(__GNUC__) && defined(HAVE_CPUID_H)
michael@0 12 + // gcc and clang
michael@0 13 #include "cpuid.h"
michael@0 14 #elif defined(_M_IX86)
michael@0 15 // windows non-gcc
michael@0 16 @@ -97,18 +96,7 @@
michael@0 17
michael@0 18 uint res = 0;
michael@0 19
michael@0 20 -#if defined(__GNUC__)
michael@0 21 - // GCC version of cpuid. Requires GCC 4.3.0 or later for __cpuid intrinsic support.
michael@0 22 - uint eax, ebx, ecx, edx; // unsigned int is the standard type. uint is defined by the compiler and not guaranteed to be portable.
michael@0 23 -
michael@0 24 - // Check if no cpuid support.
michael@0 25 - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) return 0; // always disable extensions.
michael@0 26 -
michael@0 27 - if (edx & bit_MMX) res = res | SUPPORT_MMX;
michael@0 28 - if (edx & bit_SSE) res = res | SUPPORT_SSE;
michael@0 29 - if (edx & bit_SSE2) res = res | SUPPORT_SSE2;
michael@0 30 -
michael@0 31 -#else
michael@0 32 +#if !defined(__GNUC__)
michael@0 33 // Window / VS version of cpuid. Notice that Visual Studio 2005 or later required
michael@0 34 // for __cpuid intrinsic support.
michael@0 35 int reg[4] = {-1};
michael@0 36 @@ -121,7 +109,19 @@
michael@0 37 if ((unsigned int)reg[3] & bit_MMX) res = res | SUPPORT_MMX;
michael@0 38 if ((unsigned int)reg[3] & bit_SSE) res = res | SUPPORT_SSE;
michael@0 39 if ((unsigned int)reg[3] & bit_SSE2) res = res | SUPPORT_SSE2;
michael@0 40 +#elif defined(HAVE_CPUID_H)
michael@0 41 + // GCC version of cpuid. Requires GCC 4.3.0 or later for __cpuid intrinsic support.
michael@0 42 + uint eax, ebx, ecx, edx; // unsigned int is the standard type. uint is defined by the compiler and not guaranteed to be portable.
michael@0 43 +
michael@0 44 + // Check if no cpuid support.
michael@0 45 + if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) return 0; // always disable extensions.
michael@0 46
michael@0 47 + if (edx & bit_MMX) res = res | SUPPORT_MMX;
michael@0 48 + if (edx & bit_SSE) res = res | SUPPORT_SSE;
michael@0 49 + if (edx & bit_SSE2) res = res | SUPPORT_SSE2;
michael@0 50 +#else
michael@0 51 + // Compatible with GCC but no cpuid.h.
michael@0 52 + return 0;
michael@0 53 #endif
michael@0 54
michael@0 55 return res & ~_dwDisabledISA;
michael@0 56 diff -u /src/STTypes.h /src/STTypes.h
michael@0 57 --- /src/STTypes.h
michael@0 58 +++ /src/STTypes.h
michael@0 59 @@ -54,12 +54,17 @@
michael@0 60 #define SOUNDTOUCH_ALIGN_POINTER_16(x) ( ( (ulongptr)(x) + 15 ) & ~(ulongptr)15 )
michael@0 61
michael@0 62
michael@0 63 -#if (defined(__GNUC__) && !defined(ANDROID))
michael@0 64 - // In GCC, include soundtouch_config.h made by config scritps.
michael@0 65 - // Skip this in Android compilation that uses GCC but without configure scripts.
michael@0 66 - #include "soundtouch_config.h"
michael@0 67 -#endif
michael@0 68 +#include "soundtouch_config.h"
michael@0 69
michael@0 70 +#ifdef WIN32
michael@0 71 +#ifdef BUILDING_SOUNDTOUCH
michael@0 72 +#define EXPORT __declspec(dllexport)
michael@0 73 +#else
michael@0 74 +#define EXPORT __declspec(dllimport)
michael@0 75 +#endif
michael@0 76 +#else
michael@0 77 +#define EXPORT
michael@0 78 +#endif
michael@0 79
michael@0 80 namespace soundtouch
michael@0 81 {
michael@0 82 @@ -164,7 +169,7 @@
michael@0 83 };
michael@0 84
michael@0 85 // define ST_NO_EXCEPTION_HANDLING switch to disable throwing std exceptions:
michael@0 86 -// #define ST_NO_EXCEPTION_HANDLING 1
michael@0 87 +#define ST_NO_EXCEPTION_HANDLING 1
michael@0 88 #ifdef ST_NO_EXCEPTION_HANDLING
michael@0 89 // Exceptions disabled. Throw asserts instead if enabled.
michael@0 90 #include <assert.h>
michael@0 91 diff -u /src/SoundTouch.h /src/SoundTouch.h
michael@0 92 --- /src/SoundTouch.h
michael@0 93 +++ /src/SoundTouch.h
michael@0 94 @@ -141,7 +141,7 @@
michael@0 95 /// tempo/pitch/rate/samplerate settings.
michael@0 96 #define SETTING_NOMINAL_OUTPUT_SEQUENCE 7
michael@0 97
michael@0 98 -class SoundTouch : public FIFOProcessor
michael@0 99 +class EXPORT SoundTouch : public FIFOProcessor
michael@0 100 {
michael@0 101 private:
michael@0 102 /// Rate transposer class instance
michael@0 103 diff -u /src/FIRFilter.cpp /src/FIRFilter.cpp
michael@0 104 --- /src/FIRFilter.cpp
michael@0 105 +++ /src/FIRFilter.cpp
michael@0 106 @@ -46,6 +46,11 @@
michael@0 107 #include "FIRFilter.h"
michael@0 108 #include "cpu_detect.h"
michael@0 109
michael@0 110 +#ifdef _MSC_VER
michael@0 111 +#include <malloc.h>
michael@0 112 +#define alloca _alloca
michael@0 113 +#endif
michael@0 114 +
michael@0 115 using namespace soundtouch;
michael@0 116
michael@0 117 /*****************************************************************************
michael@0 118 @@ -291,9 +296,11 @@
michael@0 119
michael@0 120 FIRFilter * FIRFilter::newInstance()
michael@0 121 {
michael@0 122 +#if defined(SOUNDTOUCH_ALLOW_MMX) || defined(SOUNDTOUCH_ALLOW_SSE)
michael@0 123 uint uExtensions;
michael@0 124
michael@0 125 uExtensions = detectCPUextensions();
michael@0 126 +#endif
michael@0 127
michael@0 128 // Check if MMX/SSE instruction set extensions supported by CPU
michael@0 129
michael@0 130 diff -u /src/TDStretch.cpp /src/TDStretch.cpp
michael@0 131 --- /src/TDStretch.cpp
michael@0 132 +++ /src/TDStretch.cpp
michael@0 133 @@ -624,9 +624,11 @@
michael@0 134
michael@0 135 TDStretch * TDStretch::newInstance()
michael@0 136 {
michael@0 137 +#if defined(SOUNDTOUCH_ALLOW_MMX) || defined(SOUNDTOUCH_ALLOW_SSE)
michael@0 138 uint uExtensions;
michael@0 139
michael@0 140 uExtensions = detectCPUextensions();
michael@0 141 +#endif
michael@0 142
michael@0 143 // Check if MMX/SSE instruction set extensions supported by CPU
michael@0 144
michael@0 145 diff -u /src/SoundTouch.cpp /src/SoundTouch.cpp
michael@0 146 --- /src/SoundTouch.cpp
michael@0 147 +++ /src/SoundTouch.cpp
michael@0 148 @@ -80,6 +80,11 @@
michael@0 149 #include "RateTransposer.h"
michael@0 150 #include "cpu_detect.h"
michael@0 151
michael@0 152 +#ifdef _MSC_VER
michael@0 153 +#include <malloc.h>
michael@0 154 +#define alloca _alloca
michael@0 155 +#endif
michael@0 156 +
michael@0 157 using namespace soundtouch;
michael@0 158
michael@0 159 /// test if two floating point numbers are equal

mercurial