Remove AudioDeviceUtility.
The class doesn't do anything in almost all cases except for grabbing and releasing locks + allocate memory. There are a couple of methods there such as WaitForKey and GetTimeInMs that are used, but those methods aren't specific to audio and we have implementations of these elsewhere. The third method, StringCompare isn't used anywhere (and also isn't specific to audio). BUG= R=henrika@webrtc.org Review URL: https://webrtc-codereview.appspot.com/50009004 Cr-Commit-Position: refs/heads/master@{#9220}
This commit is contained in:
@@ -24,15 +24,11 @@ source_set("audio_device") {
|
||||
"audio_device_buffer.h",
|
||||
"audio_device_generic.cc",
|
||||
"audio_device_generic.h",
|
||||
"audio_device_utility.cc",
|
||||
"audio_device_utility.h",
|
||||
"audio_device_impl.cc",
|
||||
"audio_device_impl.h",
|
||||
"audio_device_config.h",
|
||||
"dummy/audio_device_dummy.cc",
|
||||
"dummy/audio_device_dummy.h",
|
||||
"dummy/audio_device_utility_dummy.cc",
|
||||
"dummy/audio_device_utility_dummy.h",
|
||||
"dummy/file_audio_device.cc",
|
||||
"dummy/file_audio_device.h",
|
||||
]
|
||||
@@ -56,8 +52,6 @@ source_set("audio_device") {
|
||||
if (rtc_include_internal_audio_device) {
|
||||
sources += [
|
||||
"android/audio_device_template.h",
|
||||
"android/audio_device_utility_android.cc",
|
||||
"android/audio_device_utility_android.h",
|
||||
"android/audio_manager.cc",
|
||||
"android/audio_manager.h",
|
||||
"android/audio_record_jni.cc",
|
||||
@@ -72,22 +66,16 @@ source_set("audio_device") {
|
||||
"android/opensles_player.h",
|
||||
"ios/audio_device_ios.h",
|
||||
"ios/audio_device_ios.mm",
|
||||
"ios/audio_device_utility_ios.cc",
|
||||
"ios/audio_device_utility_ios.h",
|
||||
"linux/alsasymboltable_linux.cc",
|
||||
"linux/alsasymboltable_linux.h",
|
||||
"linux/audio_device_alsa_linux.cc",
|
||||
"linux/audio_device_alsa_linux.h",
|
||||
"linux/audio_device_utility_linux.cc",
|
||||
"linux/audio_device_utility_linux.h",
|
||||
"linux/audio_mixer_manager_alsa_linux.cc",
|
||||
"linux/audio_mixer_manager_alsa_linux.h",
|
||||
"linux/latebindingsymboltable_linux.cc",
|
||||
"linux/latebindingsymboltable_linux.h",
|
||||
"mac/audio_device_mac.cc",
|
||||
"mac/audio_device_mac.h",
|
||||
"mac/audio_device_utility_mac.cc",
|
||||
"mac/audio_device_utility_mac.h",
|
||||
"mac/audio_mixer_manager_mac.cc",
|
||||
"mac/audio_mixer_manager_mac.h",
|
||||
"mac/portaudio/pa_memorybarrier.h",
|
||||
@@ -95,8 +83,6 @@ source_set("audio_device") {
|
||||
"mac/portaudio/pa_ringbuffer.h",
|
||||
"win/audio_device_core_win.cc",
|
||||
"win/audio_device_core_win.h",
|
||||
"win/audio_device_utility_win.cc",
|
||||
"win/audio_device_utility_win.h",
|
||||
"win/audio_device_wave_win.cc",
|
||||
"win/audio_device_wave_win.h",
|
||||
"win/audio_mixer_manager_win.cc",
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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 "webrtc/modules/audio_device/android/audio_device_utility_android.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
AudioDeviceUtilityAndroid::AudioDeviceUtilityAndroid(const int32_t id) {}
|
||||
|
||||
AudioDeviceUtilityAndroid::~AudioDeviceUtilityAndroid() {}
|
||||
|
||||
int32_t AudioDeviceUtilityAndroid::Init() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Android audio device utility interface
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_ANDROID_H
|
||||
#define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_ANDROID_H
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/audio_device/audio_device_utility.h"
|
||||
#include "webrtc/modules/audio_device/include/audio_device.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// TODO(henrika): this utility class is not used but I would like to keep this
|
||||
// file for the other helper methods which are unique for Android.
|
||||
class AudioDeviceUtilityAndroid: public AudioDeviceUtility {
|
||||
public:
|
||||
AudioDeviceUtilityAndroid(const int32_t id);
|
||||
~AudioDeviceUtilityAndroid();
|
||||
|
||||
virtual int32_t Init();
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_ANDROID_H
|
||||
@@ -38,15 +38,11 @@
|
||||
'audio_device_buffer.h',
|
||||
'audio_device_generic.cc',
|
||||
'audio_device_generic.h',
|
||||
'audio_device_utility.cc',
|
||||
'audio_device_utility.h',
|
||||
'audio_device_impl.cc',
|
||||
'audio_device_impl.h',
|
||||
'audio_device_config.h',
|
||||
'dummy/audio_device_dummy.cc',
|
||||
'dummy/audio_device_dummy.h',
|
||||
'dummy/audio_device_utility_dummy.cc',
|
||||
'dummy/audio_device_utility_dummy.h',
|
||||
'dummy/file_audio_device.cc',
|
||||
'dummy/file_audio_device.h',
|
||||
],
|
||||
@@ -91,8 +87,6 @@
|
||||
['include_internal_audio_device==1', {
|
||||
'sources': [
|
||||
'android/audio_device_template.h',
|
||||
'android/audio_device_utility_android.cc',
|
||||
'android/audio_device_utility_android.h',
|
||||
'android/audio_manager.cc',
|
||||
'android/audio_manager.h',
|
||||
'android/audio_record_jni.cc',
|
||||
@@ -109,22 +103,16 @@
|
||||
'android/opensles_player.h',
|
||||
'ios/audio_device_ios.h',
|
||||
'ios/audio_device_ios.mm',
|
||||
'ios/audio_device_utility_ios.cc',
|
||||
'ios/audio_device_utility_ios.h',
|
||||
'linux/alsasymboltable_linux.cc',
|
||||
'linux/alsasymboltable_linux.h',
|
||||
'linux/audio_device_alsa_linux.cc',
|
||||
'linux/audio_device_alsa_linux.h',
|
||||
'linux/audio_device_utility_linux.cc',
|
||||
'linux/audio_device_utility_linux.h',
|
||||
'linux/audio_mixer_manager_alsa_linux.cc',
|
||||
'linux/audio_mixer_manager_alsa_linux.h',
|
||||
'linux/latebindingsymboltable_linux.cc',
|
||||
'linux/latebindingsymboltable_linux.h',
|
||||
'mac/audio_device_mac.cc',
|
||||
'mac/audio_device_mac.h',
|
||||
'mac/audio_device_utility_mac.cc',
|
||||
'mac/audio_device_utility_mac.h',
|
||||
'mac/audio_mixer_manager_mac.cc',
|
||||
'mac/audio_mixer_manager_mac.h',
|
||||
'mac/portaudio/pa_memorybarrier.h',
|
||||
@@ -132,8 +120,6 @@
|
||||
'mac/portaudio/pa_ringbuffer.h',
|
||||
'win/audio_device_core_win.cc',
|
||||
'win/audio_device_core_win.h',
|
||||
'win/audio_device_utility_win.cc',
|
||||
'win/audio_device_utility_win.h',
|
||||
'win/audio_device_wave_win.cc',
|
||||
'win/audio_device_wave_win.h',
|
||||
'win/audio_mixer_manager_win.cc',
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/modules/audio_device/audio_device_config.h"
|
||||
#include "webrtc/modules/audio_device/audio_device_utility.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/logging.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
@@ -12,37 +12,33 @@
|
||||
#include "webrtc/modules/audio_device/audio_device_config.h"
|
||||
#include "webrtc/modules/audio_device/audio_device_impl.h"
|
||||
#include "webrtc/system_wrappers/interface/ref_count.h"
|
||||
#include "webrtc/system_wrappers/interface/tick_util.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include "audio_device_utility_win.h"
|
||||
#include "audio_device_wave_win.h"
|
||||
#if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
|
||||
#include "audio_device_core_win.h"
|
||||
#endif
|
||||
#elif defined(WEBRTC_ANDROID)
|
||||
#include <stdlib.h>
|
||||
#include "audio_device_utility_android.h"
|
||||
#include "webrtc/modules/audio_device/android/audio_device_template.h"
|
||||
#include "webrtc/modules/audio_device/android/audio_manager.h"
|
||||
#include "webrtc/modules/audio_device/android/audio_record_jni.h"
|
||||
#include "webrtc/modules/audio_device/android/audio_track_jni.h"
|
||||
#include "webrtc/modules/audio_device/android/opensles_player.h"
|
||||
#elif defined(WEBRTC_LINUX)
|
||||
#include "audio_device_utility_linux.h"
|
||||
#if defined(LINUX_ALSA)
|
||||
#include "audio_device_alsa_linux.h"
|
||||
#endif
|
||||
#if defined(LINUX_PULSE)
|
||||
#if defined(LINUX_PULSE)
|
||||
#include "audio_device_pulse_linux.h"
|
||||
#endif
|
||||
#endif
|
||||
#elif defined(WEBRTC_IOS)
|
||||
#include "audio_device_utility_ios.h"
|
||||
#include "audio_device_ios.h"
|
||||
#elif defined(WEBRTC_MAC)
|
||||
#include "audio_device_utility_mac.h"
|
||||
#include "audio_device_mac.h"
|
||||
#endif
|
||||
|
||||
@@ -51,7 +47,6 @@
|
||||
#endif
|
||||
|
||||
#include "webrtc/modules/audio_device/dummy/audio_device_dummy.h"
|
||||
#include "webrtc/modules/audio_device/dummy/audio_device_utility_dummy.h"
|
||||
#include "webrtc/modules/audio_device/dummy/file_audio_device.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
@@ -78,7 +73,6 @@ AudioDeviceModule* CreateAudioDeviceModule(
|
||||
return AudioDeviceModuleImpl::Create(id, audioLayer);
|
||||
}
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// Static methods
|
||||
// ============================================================================
|
||||
@@ -134,11 +128,10 @@ AudioDeviceModuleImpl::AudioDeviceModuleImpl(const int32_t id, const AudioLayer
|
||||
_critSectEventCb(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_critSectAudioCb(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_ptrCbAudioDeviceObserver(NULL),
|
||||
_ptrAudioDeviceUtility(NULL),
|
||||
_ptrAudioDevice(NULL),
|
||||
_id(id),
|
||||
_platformAudioLayer(audioLayer),
|
||||
_lastProcessTime(AudioDeviceUtility::GetTimeInMS()),
|
||||
_lastProcessTime(TickTime::MillisecondTimestamp()),
|
||||
_platformType(kPlatformNotSupported),
|
||||
_initialized(false),
|
||||
_lastError(kAdmErrNone)
|
||||
@@ -198,24 +191,14 @@ int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects()
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__);
|
||||
|
||||
AudioDeviceGeneric* ptrAudioDevice(NULL);
|
||||
AudioDeviceUtility* ptrAudioDeviceUtility(NULL);
|
||||
|
||||
#if defined(WEBRTC_DUMMY_AUDIO_BUILD)
|
||||
ptrAudioDevice = new AudioDeviceDummy(Id());
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Dummy Audio APIs will be utilized");
|
||||
|
||||
if (ptrAudioDevice != NULL)
|
||||
{
|
||||
ptrAudioDeviceUtility = new AudioDeviceUtilityDummy(Id());
|
||||
}
|
||||
#elif defined(WEBRTC_DUMMY_FILE_DEVICES)
|
||||
ptrAudioDevice = FileAudioDeviceFactory::CreateFileAudioDevice(Id());
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
||||
"Will use file-playing dummy device.");
|
||||
if (ptrAudioDevice != NULL)
|
||||
{
|
||||
ptrAudioDeviceUtility = new AudioDeviceUtilityDummy(Id());
|
||||
}
|
||||
#else
|
||||
AudioLayer audioLayer(PlatformAudioLayer());
|
||||
|
||||
@@ -259,14 +242,6 @@ int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects()
|
||||
}
|
||||
}
|
||||
#endif // defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
|
||||
if (ptrAudioDevice != NULL)
|
||||
{
|
||||
// Create the Windows implementation of the Device Utility.
|
||||
// This class is independent of the selected audio layer
|
||||
// for Windows.
|
||||
//
|
||||
ptrAudioDeviceUtility = new AudioDeviceUtilityWindows(Id());
|
||||
}
|
||||
#endif // #if defined(_WIN32)
|
||||
|
||||
#if defined(WEBRTC_ANDROID)
|
||||
@@ -299,11 +274,6 @@ int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects()
|
||||
// Invalid audio layer.
|
||||
ptrAudioDevice = NULL;
|
||||
}
|
||||
|
||||
if (ptrAudioDevice != NULL) {
|
||||
// Create the Android implementation of the Device Utility.
|
||||
ptrAudioDeviceUtility = new AudioDeviceUtilityAndroid(Id());
|
||||
}
|
||||
// END #if defined(WEBRTC_ANDROID)
|
||||
|
||||
// Create the *Linux* implementation of the Audio Device
|
||||
@@ -347,15 +317,6 @@ int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects()
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Linux ALSA APIs will be utilized");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (ptrAudioDevice != NULL)
|
||||
{
|
||||
// Create the Linux implementation of the Device Utility.
|
||||
// This class is independent of the selected audio layer
|
||||
// for Linux.
|
||||
//
|
||||
ptrAudioDeviceUtility = new AudioDeviceUtilityLinux(Id());
|
||||
}
|
||||
#endif // #if defined(WEBRTC_LINUX)
|
||||
|
||||
// Create the *iPhone* implementation of the Audio Device
|
||||
@@ -367,12 +328,6 @@ int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects()
|
||||
ptrAudioDevice = new AudioDeviceIOS(Id());
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "iPhone Audio APIs will be utilized");
|
||||
}
|
||||
|
||||
if (ptrAudioDevice != NULL)
|
||||
{
|
||||
// Create iOS Device Utility implementation.
|
||||
ptrAudioDeviceUtility = new AudioDeviceUtilityIOS(Id());
|
||||
}
|
||||
// END #if defined(WEBRTC_IOS)
|
||||
|
||||
// Create the *Mac* implementation of the Audio Device
|
||||
@@ -384,12 +339,6 @@ int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects()
|
||||
ptrAudioDevice = new AudioDeviceMac(Id());
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Mac OS X Audio APIs will be utilized");
|
||||
}
|
||||
|
||||
if (ptrAudioDevice != NULL)
|
||||
{
|
||||
// Create the Mac implementation of the Device Utility.
|
||||
ptrAudioDeviceUtility = new AudioDeviceUtilityMac(Id());
|
||||
}
|
||||
#endif // WEBRTC_MAC
|
||||
|
||||
// Create the *Dummy* implementation of the Audio Device
|
||||
@@ -401,11 +350,6 @@ int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects()
|
||||
assert(!ptrAudioDevice);
|
||||
ptrAudioDevice = new AudioDeviceDummy(Id());
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Dummy Audio APIs will be utilized");
|
||||
|
||||
if (ptrAudioDevice != NULL)
|
||||
{
|
||||
ptrAudioDeviceUtility = new AudioDeviceUtilityDummy(Id());
|
||||
}
|
||||
}
|
||||
#endif // if defined(WEBRTC_DUMMY_AUDIO_BUILD)
|
||||
|
||||
@@ -415,16 +359,9 @@ int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects()
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ptrAudioDeviceUtility == NULL)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id, "unable to create the platform specific audio device utility");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Store valid output pointers
|
||||
//
|
||||
_ptrAudioDevice = ptrAudioDevice;
|
||||
_ptrAudioDeviceUtility = ptrAudioDeviceUtility;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -460,12 +397,6 @@ AudioDeviceModuleImpl::~AudioDeviceModuleImpl()
|
||||
_ptrAudioDevice = NULL;
|
||||
}
|
||||
|
||||
if (_ptrAudioDeviceUtility)
|
||||
{
|
||||
delete _ptrAudioDeviceUtility;
|
||||
_ptrAudioDeviceUtility = NULL;
|
||||
}
|
||||
|
||||
delete &_critSect;
|
||||
delete &_critSectEventCb;
|
||||
delete &_critSectAudioCb;
|
||||
@@ -484,9 +415,9 @@ AudioDeviceModuleImpl::~AudioDeviceModuleImpl()
|
||||
|
||||
int64_t AudioDeviceModuleImpl::TimeUntilNextProcess()
|
||||
{
|
||||
uint32_t now = AudioDeviceUtility::GetTimeInMS();
|
||||
int32_t deltaProcess = kAdmMaxIdleTimeProcess - (now - _lastProcessTime);
|
||||
return (deltaProcess);
|
||||
int64_t now = TickTime::MillisecondTimestamp();
|
||||
int64_t deltaProcess = kAdmMaxIdleTimeProcess - (now - _lastProcessTime);
|
||||
return deltaProcess;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -499,7 +430,7 @@ int64_t AudioDeviceModuleImpl::TimeUntilNextProcess()
|
||||
int32_t AudioDeviceModuleImpl::Process()
|
||||
{
|
||||
|
||||
_lastProcessTime = AudioDeviceUtility::GetTimeInMS();
|
||||
_lastProcessTime = TickTime::MillisecondTimestamp();
|
||||
|
||||
// kPlayoutWarning
|
||||
if (_ptrAudioDevice->PlayoutWarning())
|
||||
@@ -588,14 +519,9 @@ int32_t AudioDeviceModuleImpl::Init()
|
||||
if (_initialized)
|
||||
return 0;
|
||||
|
||||
if (!_ptrAudioDeviceUtility)
|
||||
return -1;
|
||||
|
||||
if (!_ptrAudioDevice)
|
||||
return -1;
|
||||
|
||||
_ptrAudioDeviceUtility->Init();
|
||||
|
||||
if (_ptrAudioDevice->Init() == -1)
|
||||
{
|
||||
return -1;
|
||||
|
||||
@@ -20,7 +20,6 @@ namespace webrtc
|
||||
{
|
||||
|
||||
class AudioDeviceGeneric;
|
||||
class AudioDeviceUtility;
|
||||
class AudioManager;
|
||||
class CriticalSectionWrapper;
|
||||
|
||||
@@ -216,7 +215,6 @@ private:
|
||||
|
||||
AudioDeviceObserver* _ptrCbAudioDeviceObserver;
|
||||
|
||||
AudioDeviceUtility* _ptrAudioDeviceUtility;
|
||||
AudioDeviceGeneric* _ptrAudioDevice;
|
||||
|
||||
AudioDeviceBuffer _audioDeviceBuffer;
|
||||
@@ -225,7 +223,7 @@ private:
|
||||
#endif
|
||||
int32_t _id;
|
||||
AudioLayer _platformAudioLayer;
|
||||
uint32_t _lastProcessTime;
|
||||
int64_t _lastProcessTime;
|
||||
PlatformType _platformType;
|
||||
bool _initialized;
|
||||
mutable ErrorCode _lastError;
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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 <assert.h>
|
||||
|
||||
#include "webrtc/modules/audio_device/audio_device_utility.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
// ============================================================================
|
||||
// Windows
|
||||
// ============================================================================
|
||||
|
||||
#include <windows.h>
|
||||
#include <conio.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <mmsystem.h>
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
|
||||
void AudioDeviceUtility::WaitForKey()
|
||||
{
|
||||
_getch();
|
||||
}
|
||||
|
||||
uint32_t AudioDeviceUtility::GetTimeInMS()
|
||||
{
|
||||
return timeGetTime();
|
||||
}
|
||||
|
||||
bool AudioDeviceUtility::StringCompare(
|
||||
const char* str1 , const char* str2,
|
||||
const uint32_t length)
|
||||
{
|
||||
return ((_strnicmp(str1, str2, length) == 0) ? true : false);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC)
|
||||
|
||||
// ============================================================================
|
||||
// Linux & Mac
|
||||
// ============================================================================
|
||||
|
||||
#include <stdio.h> // getchar
|
||||
#include <string.h> // strncasecmp
|
||||
#include <sys/time.h> // gettimeofday
|
||||
#include <termios.h> // tcgetattr
|
||||
#include <time.h> // gettimeofday
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
|
||||
void AudioDeviceUtility::WaitForKey()
|
||||
{
|
||||
|
||||
struct termios oldt, newt;
|
||||
|
||||
tcgetattr( STDIN_FILENO, &oldt );
|
||||
|
||||
// we don't want getchar to echo!
|
||||
|
||||
newt = oldt;
|
||||
newt.c_lflag &= ~( ICANON | ECHO );
|
||||
tcsetattr( STDIN_FILENO, TCSANOW, &newt );
|
||||
|
||||
// catch any newline that's hanging around...
|
||||
|
||||
// you'll have to hit enter twice if you
|
||||
|
||||
// choose enter out of all available keys
|
||||
|
||||
if (getc(stdin) == '\n')
|
||||
{
|
||||
getc(stdin);
|
||||
}
|
||||
|
||||
tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
|
||||
}
|
||||
|
||||
uint32_t AudioDeviceUtility::GetTimeInMS()
|
||||
{
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
uint32_t val;
|
||||
|
||||
gettimeofday(&tv, &tz);
|
||||
val = (uint32_t)(tv.tv_sec*1000 + tv.tv_usec/1000);
|
||||
return val;
|
||||
}
|
||||
|
||||
bool AudioDeviceUtility::StringCompare(
|
||||
const char* str1 , const char* str2, const uint32_t length)
|
||||
{
|
||||
return (strncasecmp(str1, str2, length) == 0)?true: false;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // defined(WEBRTC_LINUX) || defined(WEBRTC_MAC)
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_H
|
||||
#define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_H
|
||||
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
|
||||
class AudioDeviceUtility
|
||||
{
|
||||
public:
|
||||
static uint32_t GetTimeInMS();
|
||||
static void WaitForKey();
|
||||
static bool StringCompare(const char* str1,
|
||||
const char* str2,
|
||||
const uint32_t length);
|
||||
virtual int32_t Init() = 0;
|
||||
|
||||
virtual ~AudioDeviceUtility() {}
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_H
|
||||
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 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 "webrtc/modules/audio_device/dummy/audio_device_utility_dummy.h"
|
||||
|
||||
namespace webrtc {
|
||||
int32_t AudioDeviceUtilityDummy::Init() { return 0; }
|
||||
} // namespace webrtc
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_DUMMY_H
|
||||
#define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_DUMMY_H
|
||||
|
||||
#include "webrtc/modules/audio_device/audio_device_utility.h"
|
||||
#include "webrtc/modules/audio_device/include/audio_device.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
class CriticalSectionWrapper;
|
||||
|
||||
class AudioDeviceUtilityDummy: public AudioDeviceUtility
|
||||
{
|
||||
public:
|
||||
AudioDeviceUtilityDummy(const int32_t id) {}
|
||||
virtual ~AudioDeviceUtilityDummy() {}
|
||||
|
||||
int32_t Init() override;
|
||||
};
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_AUDIO_DEVICE_MAIN_SOURCE_LINUX_AUDIO_DEVICE_UTILITY_DUMMY_H_
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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 "webrtc/modules/audio_device/audio_device_config.h"
|
||||
#include "webrtc/modules/audio_device/ios/audio_device_utility_ios.h"
|
||||
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
namespace webrtc {
|
||||
AudioDeviceUtilityIOS::AudioDeviceUtilityIOS(const int32_t id)
|
||||
:
|
||||
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_id(id),
|
||||
_lastError(AudioDeviceModule::kAdmErrNone) {
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id,
|
||||
"%s created", __FUNCTION__);
|
||||
}
|
||||
|
||||
AudioDeviceUtilityIOS::~AudioDeviceUtilityIOS() {
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id,
|
||||
"%s destroyed", __FUNCTION__);
|
||||
{
|
||||
CriticalSectionScoped lock(&_critSect);
|
||||
}
|
||||
delete &_critSect;
|
||||
}
|
||||
|
||||
int32_t AudioDeviceUtilityIOS::Init() {
|
||||
WEBRTC_TRACE(kTraceModuleCall, kTraceAudioDevice, _id,
|
||||
"%s", __FUNCTION__);
|
||||
|
||||
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioDevice, _id,
|
||||
" OS info: %s", "iOS");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_IOS_H
|
||||
#define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_IOS_H
|
||||
|
||||
#include "webrtc/modules/audio_device/audio_device_utility.h"
|
||||
#include "webrtc/modules/audio_device/include/audio_device.h"
|
||||
|
||||
namespace webrtc {
|
||||
class CriticalSectionWrapper;
|
||||
|
||||
class AudioDeviceUtilityIOS: public AudioDeviceUtility {
|
||||
public:
|
||||
AudioDeviceUtilityIOS(const int32_t id);
|
||||
AudioDeviceUtilityIOS();
|
||||
virtual ~AudioDeviceUtilityIOS();
|
||||
|
||||
virtual int32_t Init();
|
||||
|
||||
private:
|
||||
CriticalSectionWrapper& _critSect;
|
||||
int32_t _id;
|
||||
AudioDeviceModule::ErrorCode _lastError;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_IOS_H
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "webrtc/modules/audio_device/audio_device_config.h"
|
||||
#include "webrtc/modules/audio_device/audio_device_utility.h"
|
||||
#include "webrtc/modules/audio_device/linux/audio_device_alsa_linux.h"
|
||||
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "webrtc/modules/audio_device/audio_device_config.h"
|
||||
#include "webrtc/modules/audio_device/audio_device_utility.h"
|
||||
#include "webrtc/modules/audio_device/linux/audio_device_pulse_linux.h"
|
||||
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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 "webrtc/modules/audio_device/linux/audio_device_utility_linux.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
|
||||
AudioDeviceUtilityLinux::AudioDeviceUtilityLinux(const int32_t id) :
|
||||
_critSect(*CriticalSectionWrapper::CreateCriticalSection()), _id(id)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id,
|
||||
"%s created", __FUNCTION__);
|
||||
}
|
||||
|
||||
AudioDeviceUtilityLinux::~AudioDeviceUtilityLinux()
|
||||
{
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id,
|
||||
"%s destroyed", __FUNCTION__);
|
||||
{
|
||||
CriticalSectionScoped lock(&_critSect);
|
||||
|
||||
// free stuff here...
|
||||
}
|
||||
|
||||
delete &_critSect;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// API
|
||||
// ============================================================================
|
||||
|
||||
|
||||
int32_t AudioDeviceUtilityLinux::Init()
|
||||
{
|
||||
|
||||
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioDevice, _id,
|
||||
" OS info: %s", "Linux");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
} // namespace webrtc
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* 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_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_LINUX_H
|
||||
#define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_LINUX_H
|
||||
|
||||
#include "webrtc/modules/audio_device/audio_device_utility.h"
|
||||
#include "webrtc/modules/audio_device/include/audio_device.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
class CriticalSectionWrapper;
|
||||
|
||||
class AudioDeviceUtilityLinux: public AudioDeviceUtility
|
||||
{
|
||||
public:
|
||||
AudioDeviceUtilityLinux(const int32_t id);
|
||||
virtual ~AudioDeviceUtilityLinux();
|
||||
|
||||
int32_t Init() override;
|
||||
|
||||
private:
|
||||
CriticalSectionWrapper& _critSect;
|
||||
int32_t _id;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_AUDIO_DEVICE_MAIN_SOURCE_LINUX_AUDIO_DEVICE_UTILITY_LINUX_H_
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/audio_device/audio_device_config.h"
|
||||
#include "webrtc/modules/audio_device/audio_device_utility.h"
|
||||
#include "webrtc/modules/audio_device/mac/audio_device_mac.h"
|
||||
#include "webrtc/modules/audio_device/mac/portaudio/pa_ringbuffer.h"
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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 "webrtc/modules/audio_device/mac/audio_device_utility_mac.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
|
||||
AudioDeviceUtilityMac::AudioDeviceUtilityMac(const int32_t id) :
|
||||
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_id(id)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id,
|
||||
"%s created", __FUNCTION__);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// AudioDeviceUtilityMac() - dtor
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
AudioDeviceUtilityMac::~AudioDeviceUtilityMac()
|
||||
{
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id,
|
||||
"%s destroyed", __FUNCTION__);
|
||||
{
|
||||
CriticalSectionScoped lock(&_critSect);
|
||||
|
||||
// free stuff here...
|
||||
}
|
||||
|
||||
delete &_critSect;
|
||||
}
|
||||
|
||||
int32_t AudioDeviceUtilityMac::Init()
|
||||
{
|
||||
|
||||
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioDevice, _id,
|
||||
" OS info: %s", "OS X");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_MAC_H
|
||||
#define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_MAC_H
|
||||
|
||||
#include "webrtc/modules/audio_device/audio_device_utility.h"
|
||||
#include "webrtc/modules/audio_device/include/audio_device.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
class CriticalSectionWrapper;
|
||||
|
||||
class AudioDeviceUtilityMac: public AudioDeviceUtility
|
||||
{
|
||||
public:
|
||||
AudioDeviceUtilityMac(const int32_t id);
|
||||
~AudioDeviceUtilityMac();
|
||||
|
||||
virtual int32_t Init();
|
||||
|
||||
private:
|
||||
CriticalSectionWrapper& _critSect;
|
||||
int32_t _id;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_AUDIO_DEVICE_MAIN_SOURCE_MAC_AUDIO_DEVICE_UTILITY_MAC_H_
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
#include "webrtc/modules/audio_device/audio_device_config.h"
|
||||
#include "webrtc/modules/audio_device/audio_device_impl.h"
|
||||
#include "webrtc/modules/audio_device/audio_device_utility.h"
|
||||
#include "webrtc/system_wrappers/interface/sleep.h"
|
||||
|
||||
// Helper functions
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <conio.h>
|
||||
#elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC)
|
||||
#include <termios.h> // tcgetattr
|
||||
#endif
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/modules/audio_device/test/func_test_manager.h"
|
||||
#include "webrtc/system_wrappers/interface/sleep.h"
|
||||
@@ -37,6 +43,21 @@ const char* RecordedMicrophoneBoostFile =
|
||||
const char* RecordedMicrophoneAGCFile = "recorded_microphone_AGC_mono_48.pcm";
|
||||
const char* RecordedSpeakerFile = "recorded_speaker_48.pcm";
|
||||
|
||||
#if defined(WEBRTC_IOS) || defined(ANDROID)
|
||||
#define USE_SLEEP_AS_PAUSE
|
||||
#else
|
||||
//#define USE_SLEEP_AS_PAUSE
|
||||
#endif
|
||||
|
||||
// Sets the default pause time if using sleep as pause
|
||||
#define DEFAULT_PAUSE_TIME 5000
|
||||
|
||||
#if defined(USE_SLEEP_AS_PAUSE)
|
||||
#define PAUSE(a) SleepMs(a);
|
||||
#else
|
||||
#define PAUSE(a) WaitForKey();
|
||||
#endif
|
||||
|
||||
// Helper functions
|
||||
#if !defined(WEBRTC_IOS)
|
||||
char* GetFilename(char* filename)
|
||||
@@ -57,6 +78,35 @@ const char* GetResource(const char* resource)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(USE_SLEEP_AS_PAUSE)
|
||||
static void WaitForKey() {
|
||||
#if defined(_WIN32)
|
||||
_getch();
|
||||
#elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC)
|
||||
struct termios oldt, newt;
|
||||
|
||||
tcgetattr( STDIN_FILENO, &oldt );
|
||||
|
||||
// we don't want getchar to echo!
|
||||
|
||||
newt = oldt;
|
||||
newt.c_lflag &= ~( ICANON | ECHO );
|
||||
tcsetattr( STDIN_FILENO, TCSANOW, &newt );
|
||||
|
||||
// catch any newline that's hanging around...
|
||||
// you'll have to hit enter twice if you
|
||||
// choose enter out of all available keys
|
||||
|
||||
if (getc(stdin) == '\n')
|
||||
{
|
||||
getc(stdin);
|
||||
}
|
||||
|
||||
tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
|
||||
#endif // defined(_WIN32)
|
||||
}
|
||||
#endif // !defined(USE_SLEEP_AS_PAUSE)
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
#ifndef WEBRTC_AUDIO_DEVICE_FUNC_TEST_MANAGER_H
|
||||
#define WEBRTC_AUDIO_DEVICE_FUNC_TEST_MANAGER_H
|
||||
|
||||
#include "webrtc/modules/audio_device/audio_device_utility.h"
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
@@ -22,20 +20,6 @@
|
||||
#include "webrtc/system_wrappers/interface/file_wrapper.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
#if defined(WEBRTC_IOS) || defined(ANDROID)
|
||||
#define USE_SLEEP_AS_PAUSE
|
||||
#else
|
||||
//#define USE_SLEEP_AS_PAUSE
|
||||
#endif
|
||||
|
||||
// Sets the default pause time if using sleep as pause
|
||||
#define DEFAULT_PAUSE_TIME 5000
|
||||
|
||||
#if defined(USE_SLEEP_AS_PAUSE)
|
||||
#define PAUSE(a) SleepMs(a);
|
||||
#else
|
||||
#define PAUSE(a) AudioDeviceUtility::WaitForKey();
|
||||
#endif
|
||||
|
||||
#define ADM_AUDIO_LAYER AudioDeviceModule::kPlatformDefaultAudio
|
||||
//#define ADM_AUDIO_LAYER AudioDeviceModule::kLinuxPulseAudio
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include <uuids.h>
|
||||
|
||||
#include "webrtc/base/platform_thread.h"
|
||||
#include "webrtc/modules/audio_device/audio_device_utility.h"
|
||||
#include "webrtc/system_wrappers/interface/sleep.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
|
||||
@@ -1,229 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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 "webrtc/modules/audio_device/win/audio_device_utility_win.h"
|
||||
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <strsafe.h>
|
||||
|
||||
#define STRING_MAX_SIZE 256
|
||||
|
||||
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
|
||||
typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD);
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
|
||||
// ============================================================================
|
||||
// Construction & Destruction
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// AudioDeviceUtilityWindows() - ctor
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
AudioDeviceUtilityWindows::AudioDeviceUtilityWindows(const int32_t id) :
|
||||
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_id(id),
|
||||
_lastError(AudioDeviceModule::kAdmErrNone)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id, "%s created", __FUNCTION__);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// AudioDeviceUtilityWindows() - dtor
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
AudioDeviceUtilityWindows::~AudioDeviceUtilityWindows()
|
||||
{
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s destroyed", __FUNCTION__);
|
||||
{
|
||||
CriticalSectionScoped lock(&_critSect);
|
||||
|
||||
// free stuff here...
|
||||
}
|
||||
|
||||
delete &_critSect;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// API
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Init()
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int32_t AudioDeviceUtilityWindows::Init()
|
||||
{
|
||||
|
||||
TCHAR szOS[STRING_MAX_SIZE];
|
||||
|
||||
if (GetOSDisplayString(szOS))
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
char os[STRING_MAX_SIZE];
|
||||
if (WideCharToMultiByte(CP_UTF8, 0, szOS, -1, os, STRING_MAX_SIZE, NULL, NULL) == 0)
|
||||
{
|
||||
strncpy(os, "Could not get OS info", STRING_MAX_SIZE);
|
||||
}
|
||||
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioDevice, _id, " OS info: %s", os);
|
||||
#else
|
||||
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioDevice, _id, " OS info: %s", szOS);
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Private Methods
|
||||
// ============================================================================
|
||||
|
||||
BOOL AudioDeviceUtilityWindows::GetOSDisplayString(LPTSTR pszOS)
|
||||
{
|
||||
OSVERSIONINFOEX osvi;
|
||||
SYSTEM_INFO si;
|
||||
PGNSI pGNSI;
|
||||
BOOL bOsVersionInfoEx;
|
||||
|
||||
ZeroMemory(&si, sizeof(SYSTEM_INFO));
|
||||
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
|
||||
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||
|
||||
// Retrieve information about the current operating system
|
||||
//
|
||||
bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *) &osvi);
|
||||
if (!bOsVersionInfoEx)
|
||||
return FALSE;
|
||||
|
||||
// Parse our OS version string
|
||||
//
|
||||
if (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId && osvi.dwMajorVersion > 4)
|
||||
{
|
||||
StringCchCopy(pszOS, STRING_MAX_SIZE, TEXT("Microsoft "));
|
||||
|
||||
// Test for the specific product
|
||||
//
|
||||
// Operating system Version number
|
||||
// --------------------------------------
|
||||
// Windows 7 6.1
|
||||
// Windows Server 2008 R2 6.1
|
||||
// Windows Server 2008 6.0
|
||||
// Windows Vista 6.0
|
||||
// - - - - - - - - - - - - - - - - - - -
|
||||
// Windows Server 2003 R2 5.2
|
||||
// Windows Server 2003 5.2
|
||||
// Windows XP 5.1
|
||||
// Windows 2000 5.0
|
||||
//
|
||||
// see http://msdn.microsoft.com/en-us/library/ms724832(VS.85).aspx for details
|
||||
//
|
||||
if (osvi.dwMajorVersion == 6)
|
||||
{
|
||||
if (osvi.dwMinorVersion == 0)
|
||||
{
|
||||
// Windows Vista or Server 2008
|
||||
if (osvi.wProductType == VER_NT_WORKSTATION)
|
||||
StringCchCat(pszOS, STRING_MAX_SIZE, TEXT("Windows Vista "));
|
||||
else
|
||||
StringCchCat(pszOS, STRING_MAX_SIZE, TEXT("Windows Server 2008 " ));
|
||||
}
|
||||
|
||||
if (osvi.dwMinorVersion == 1)
|
||||
{
|
||||
// Windows 7 or Server 2008 R2
|
||||
if (osvi.wProductType == VER_NT_WORKSTATION)
|
||||
StringCchCat(pszOS, STRING_MAX_SIZE, TEXT("Windows 7 "));
|
||||
else
|
||||
StringCchCat(pszOS, STRING_MAX_SIZE, TEXT("Windows Server 2008 R2 " ));
|
||||
}
|
||||
}
|
||||
|
||||
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2)
|
||||
{
|
||||
StringCchCat(pszOS, STRING_MAX_SIZE, TEXT("Windows Server 2003"));
|
||||
}
|
||||
|
||||
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1)
|
||||
{
|
||||
StringCchCat(pszOS, STRING_MAX_SIZE, TEXT("Windows XP "));
|
||||
if (osvi.wSuiteMask & VER_SUITE_PERSONAL)
|
||||
StringCchCat(pszOS, STRING_MAX_SIZE, TEXT( "Home Edition" ));
|
||||
else
|
||||
StringCchCat(pszOS, STRING_MAX_SIZE, TEXT( "Professional" ));
|
||||
}
|
||||
|
||||
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0)
|
||||
{
|
||||
StringCchCat(pszOS, STRING_MAX_SIZE, TEXT("Windows 2000 "));
|
||||
|
||||
if (osvi.wProductType == VER_NT_WORKSTATION )
|
||||
{
|
||||
StringCchCat(pszOS, STRING_MAX_SIZE, TEXT( "Professional" ));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
|
||||
StringCchCat(pszOS, STRING_MAX_SIZE, TEXT( "Datacenter Server" ));
|
||||
else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
|
||||
StringCchCat(pszOS, STRING_MAX_SIZE, TEXT( "Advanced Server" ));
|
||||
else StringCchCat(pszOS, STRING_MAX_SIZE, TEXT( "Server" ));
|
||||
}
|
||||
}
|
||||
|
||||
// Include service pack (if any)
|
||||
//
|
||||
if (_tcslen(osvi.szCSDVersion) > 0)
|
||||
{
|
||||
StringCchCat(pszOS, STRING_MAX_SIZE, TEXT(" "));
|
||||
StringCchCat(pszOS, STRING_MAX_SIZE, osvi.szCSDVersion);
|
||||
}
|
||||
|
||||
TCHAR buf[80];
|
||||
|
||||
// Include build number
|
||||
//
|
||||
StringCchPrintf( buf, 80, TEXT(" (build %d)"), osvi.dwBuildNumber);
|
||||
StringCchCat(pszOS, STRING_MAX_SIZE, buf);
|
||||
|
||||
// Call GetNativeSystemInfo if supported or GetSystemInfo otherwise
|
||||
//
|
||||
pGNSI = (PGNSI) GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo");
|
||||
if (NULL != pGNSI)
|
||||
pGNSI(&si);
|
||||
else
|
||||
GetSystemInfo(&si);
|
||||
|
||||
// Add 64-bit or 32-bit for OS versions "later than" Vista
|
||||
//
|
||||
if (osvi.dwMajorVersion >= 6)
|
||||
{
|
||||
if ((si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) ||
|
||||
(si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64))
|
||||
StringCchCat(pszOS, STRING_MAX_SIZE, TEXT( ", 64-bit" ));
|
||||
else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL )
|
||||
StringCchCat(pszOS, STRING_MAX_SIZE, TEXT(", 32-bit"));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* 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_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_WIN_H
|
||||
#define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_WIN_H
|
||||
|
||||
#include "webrtc/modules/audio_device/audio_device_utility.h"
|
||||
#include "webrtc/modules/audio_device/include/audio_device.h"
|
||||
#include <windows.h>
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
class CriticalSectionWrapper;
|
||||
|
||||
class AudioDeviceUtilityWindows : public AudioDeviceUtility
|
||||
{
|
||||
public:
|
||||
AudioDeviceUtilityWindows(const int32_t id);
|
||||
~AudioDeviceUtilityWindows();
|
||||
|
||||
virtual int32_t Init();
|
||||
|
||||
private:
|
||||
BOOL GetOSDisplayString(LPTSTR pszOS);
|
||||
|
||||
private:
|
||||
CriticalSectionWrapper& _critSect;
|
||||
int32_t _id;
|
||||
AudioDeviceModule::ErrorCode _lastError;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_UTILITY_WIN_H
|
||||
@@ -9,10 +9,10 @@
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/audio_device/audio_device_config.h"
|
||||
#include "webrtc/modules/audio_device/audio_device_utility.h"
|
||||
#include "webrtc/modules/audio_device/win/audio_device_wave_win.h"
|
||||
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/tick_util.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
#include <windows.h>
|
||||
@@ -206,7 +206,7 @@ int32_t AudioDeviceWindowsWave::Init()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const uint32_t nowTime(AudioDeviceUtility::GetTimeInMS());
|
||||
const uint32_t nowTime(TickTime::MillisecondTimestamp());
|
||||
|
||||
_recordedBytes = 0;
|
||||
_prevRecByteCheckTime = nowTime;
|
||||
@@ -3052,7 +3052,7 @@ bool AudioDeviceWindowsWave::ThreadProcess()
|
||||
return true;
|
||||
}
|
||||
|
||||
time = AudioDeviceUtility::GetTimeInMS();
|
||||
time = TickTime::MillisecondTimestamp();
|
||||
|
||||
if (_startPlay)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user