Update common_audio

Corresponds to upstream commit 524e9b043e7e86fd72353b987c9d5f6a1ebf83e1

Update notes:

 * Moved src/ to webrtc/ to easily diff against the third_party/webrtc
   in the chromium tree

 * ARM/NEON/MIPS support is not yet hooked up

 * Tests have not been copied
This commit is contained in:
Arun Raghavan
2015-10-13 12:16:16 +05:30
parent 9413986e79
commit c4fb4e38de
230 changed files with 11201 additions and 8656 deletions

View File

@ -0,0 +1,13 @@
noinst_LTLIBRARIES = libsystem_wrappers.la
libsystem_wrappers_la_SOURCES = interface/cpu_features_wrapper.h \
interface/critical_section_wrapper.h \
source/cpu_features.cc \
source/critical_section.cc \
source/critical_section_posix.h \
source/critical_section_windows.h
# This assumes that we want the POSIX implementation -- should eventually be
# converted to a conditional to include Windows support
libsystem_wrappers_la_SOURCES += source/critical_section_posix.cc
libsystem_wrappers_la_CXXFLAGS = $(AM_CXXFLAGS) $(COMMON_CXXFLAGS) \
-I$(srcdir)/interface

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_FEATURES_WRAPPER_H_
#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_FEATURES_WRAPPER_H_
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
#include "webrtc/typedefs.h"
// List of features in x86.
typedef enum {
kSSE2,
kSSE3
} CPUFeature;
// List of features in ARM.
enum {
kCPUFeatureARMv7 = (1 << 0),
kCPUFeatureVFPv3 = (1 << 1),
kCPUFeatureNEON = (1 << 2),
kCPUFeatureLDREXSTREX = (1 << 3)
};
typedef int (*WebRtc_CPUInfo)(CPUFeature feature);
// Returns true if the CPU supports the feature.
extern WebRtc_CPUInfo WebRtc_GetCPUInfo;
// No CPU feature is available => straight C path.
extern WebRtc_CPUInfo WebRtc_GetCPUInfoNoASM;
// Return the features in an ARM device.
// It detects the features in the hardware platform, and returns supported
// values in the above enum definition as a bitmask.
extern uint64_t WebRtc_GetCPUFeaturesARM(void);
#if defined(__cplusplus) || defined(c_plusplus)
} // extern "C"
#endif
#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_FEATURES_WRAPPER_H_

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CRITICAL_SECTION_WRAPPER_H_
#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CRITICAL_SECTION_WRAPPER_H_
// If the critical section is heavily contended it may be beneficial to use
// read/write locks instead.
#include "webrtc/base/thread_annotations.h"
#include "webrtc/common_types.h"
namespace webrtc {
class LOCKABLE CriticalSectionWrapper {
public:
// Factory method, constructor disabled
static CriticalSectionWrapper* CreateCriticalSection();
virtual ~CriticalSectionWrapper() {}
// Tries to grab lock, beginning of a critical section. Will wait for the
// lock to become available if the grab failed.
virtual void Enter() EXCLUSIVE_LOCK_FUNCTION() = 0;
// Returns a grabbed lock, end of critical section.
virtual void Leave() UNLOCK_FUNCTION() = 0;
};
// RAII extension of the critical section. Prevents Enter/Leave mismatches and
// provides more compact critical section syntax.
class SCOPED_LOCKABLE CriticalSectionScoped {
public:
explicit CriticalSectionScoped(CriticalSectionWrapper* critsec)
EXCLUSIVE_LOCK_FUNCTION(critsec)
: ptr_crit_sec_(critsec) {
ptr_crit_sec_->Enter();
}
~CriticalSectionScoped() UNLOCK_FUNCTION() { ptr_crit_sec_->Leave(); }
private:
CriticalSectionWrapper* ptr_crit_sec_;
};
} // namespace webrtc
#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CRITICAL_SECTION_WRAPPER_H_

View File

@ -0,0 +1,74 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
// Parts of this file derived from Chromium's base/cpu.cc.
#include "cpu_features_wrapper.h"
#include "typedefs.h"
#if defined(WEBRTC_ARCH_X86_FAMILY)
#if defined(_MSC_VER)
#include <intrin.h>
#endif
#endif
// No CPU feature is available => straight C path.
int GetCPUInfoNoASM(CPUFeature feature) {
(void)feature;
return 0;
}
#if defined(WEBRTC_ARCH_X86_FAMILY)
#ifndef _MSC_VER
// Intrinsic for "cpuid".
#if defined(__pic__) && defined(__i386__)
static inline void __cpuid(int cpu_info[4], int info_type) {
__asm__ volatile (
"mov %%ebx, %%edi\n"
"cpuid\n"
"xchg %%edi, %%ebx\n"
: "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
: "a"(info_type));
}
#else
static inline void __cpuid(int cpu_info[4], int info_type) {
__asm__ volatile (
"cpuid\n"
: "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
: "a"(info_type));
}
#endif
#endif // _MSC_VER
#endif // WEBRTC_ARCH_X86_FAMILY
#if defined(WEBRTC_ARCH_X86_FAMILY)
// Actual feature detection for x86.
static int GetCPUInfo(CPUFeature feature) {
int cpu_info[4];
__cpuid(cpu_info, 1);
if (feature == kSSE2) {
return 0 != (cpu_info[3] & 0x04000000);
}
if (feature == kSSE3) {
return 0 != (cpu_info[2] & 0x00000001);
}
return 0;
}
#else
// Default to straight C for other platforms.
static int GetCPUInfo(CPUFeature feature) {
(void)feature;
return 0;
}
#endif
WebRtc_CPUInfo WebRtc_GetCPUInfo = GetCPUInfo;
WebRtc_CPUInfo WebRtc_GetCPUInfoNoASM = GetCPUInfoNoASM;

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#if defined(_WIN32)
#include <windows.h>
#include "critical_section_windows.h"
#else
#include "critical_section_posix.h"
#endif
namespace webrtc {
CriticalSectionWrapper* CriticalSectionWrapper::CreateCriticalSection()
{
#ifdef _WIN32
return new CriticalSectionWindows();
#else
return new CriticalSectionPosix();
#endif
}
} // namespace webrtc

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "critical_section_posix.h"
namespace webrtc {
CriticalSectionPosix::CriticalSectionPosix()
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&_mutex, &attr);
}
CriticalSectionPosix::~CriticalSectionPosix()
{
pthread_mutex_destroy(&_mutex);
}
void
CriticalSectionPosix::Enter()
{
pthread_mutex_lock(&_mutex);
}
void
CriticalSectionPosix::Leave()
{
pthread_mutex_unlock(&_mutex);
}
} // namespace webrtc

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_POSIX_H_
#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_POSIX_H_
#include "critical_section_wrapper.h"
#include <pthread.h>
namespace webrtc {
class CriticalSectionPosix : public CriticalSectionWrapper
{
public:
CriticalSectionPosix();
virtual ~CriticalSectionPosix();
virtual void Enter();
virtual void Leave();
private:
pthread_mutex_t _mutex;
friend class ConditionVariablePosix;
};
} // namespace webrtc
#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_POSIX_H_

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "critical_section_windows.h"
namespace webrtc {
CriticalSectionWindows::CriticalSectionWindows()
{
InitializeCriticalSection(&crit);
}
CriticalSectionWindows::~CriticalSectionWindows()
{
DeleteCriticalSection(&crit);
}
void
CriticalSectionWindows::Enter()
{
EnterCriticalSection(&crit);
}
void
CriticalSectionWindows::Leave()
{
LeaveCriticalSection(&crit);
}
} // namespace webrtc

View File

@ -0,0 +1,36 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_WINDOWS_H_
#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_WINDOWS_H_
#include "typedefs.h"
#include "critical_section_wrapper.h"
#include <windows.h>
namespace webrtc {
class CriticalSectionWindows : public CriticalSectionWrapper
{
public:
CriticalSectionWindows();
virtual ~CriticalSectionWindows();
virtual void Enter();
virtual void Leave();
private:
CRITICAL_SECTION crit;
friend class ConditionVariableWindows;
};
} // namespace webrtc
#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_WINDOWS_H_

View File

@ -0,0 +1,169 @@
# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
# TODO: Rename files to use *_linux.cpp etc. names, to automatically include relevant files. Remove conditions section.
{
'includes': [
'../../common_settings.gypi', # Common settings
],
'targets': [
{
'target_name': 'system_wrappers',
'type': '<(library)',
'include_dirs': [
'spreadsortlib',
'../interface',
],
'direct_dependent_settings': {
'include_dirs': [
'../interface',
],
},
'sources': [
'../interface/aligned_malloc.h',
'../interface/atomic32_wrapper.h',
'../interface/condition_variable_wrapper.h',
'../interface/cpu_wrapper.h',
'../interface/cpu_features_wrapper.h',
'../interface/critical_section_wrapper.h',
'../interface/data_log.h',
'../interface/data_log_c.h',
'../interface/data_log_impl.h',
'../interface/event_wrapper.h',
'../interface/file_wrapper.h',
'../interface/fix_interlocked_exchange_pointer_windows.h',
'../interface/list_wrapper.h',
'../interface/map_wrapper.h',
'../interface/ref_count.h',
'../interface/rw_lock_wrapper.h',
'../interface/scoped_ptr.h',
'../interface/scoped_refptr.h',
'../interface/sort.h',
'../interface/thread_wrapper.h',
'../interface/tick_util.h',
'../interface/trace.h',
'aligned_malloc.cc',
'atomic32.cc',
'atomic32_linux.h',
'atomic32_mac.h',
'atomic32_windows.h',
'condition_variable.cc',
'condition_variable_posix.h',
'condition_variable_windows.h',
'cpu.cc',
'cpu_linux.h',
'cpu_mac.h',
'cpu_windows.h',
'cpu_features.cc',
'critical_section.cc',
'critical_section_posix.h',
'critical_section_windows.h',
'data_log_c.cc',
'event.cc',
'event_posix.h',
'event_windows.h',
'file_impl.cc',
'file_impl.h',
'list_no_stl.cc',
'map.cc',
'rw_lock.cc',
'rw_lock_posix.h',
'rw_lock_windows.h',
'sort.cc',
'thread.cc',
'thread_posix.h',
'thread_windows.h',
'thread_windows_set_name.h',
'trace_impl.cc',
'trace_impl.h',
'trace_posix.h',
'trace_windows.h',
],
'conditions': [
['os_posix==1', {
'sources': [
'condition_variable_posix.cc',
'critical_section_posix.cc',
'event_posix.cc',
'rw_lock_posix.cc',
'thread_posix.cc',
'trace_posix.cc',
],
}],
['enable_data_logging==1', {
'sources': [
'data_log.cc',
],
},{
'sources': [
'data_log_dummy.cc',
],
},],
['OS=="linux"', {
'sources': [
'cpu_linux.cc',
],
'link_settings': {
'libraries': [
'-lrt',
],
},
}],
['OS=="mac"', {
'sources': [
'cpu_mac.cc',
],
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/ApplicationServices.framework',
],
},
}],
['OS=="win"', {
'sources': [
'condition_variable_windows.cc',
'cpu_windows.cc',
'critical_section_windows.cc',
'event_windows.cc',
'rw_lock_windows.cc',
'thread_windows.cc',
'trace_windows.cc',
],
'link_settings': {
'libraries': [
'-lwinmm.lib',
],
},
}],
] # conditions
},
], # targets
'conditions': [
['build_with_chromium==0', {
'targets': [
{
'target_name': 'system_wrappersTest',
'type': 'executable',
'dependencies': [
'system_wrappers'
],
'sources': [
'../test/Test.cpp',
],
},
], # targets
}], # build_with_chromium
], # conditions
}
# Local Variables:
# tab-width:2
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=2 shiftwidth=2: