Remove AudioDevice::{Microphone,Speaker}IsAvailable.
This was only used for logging, except on Mac, where the methods are now private. BUG=3132 R=henrika@webrtc.org Review URL: https://webrtc-codereview.appspot.com/10959004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5831 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
7549ff4257
commit
c7c432aa9b
webrtc
modules/audio_device
android
audio_device_template.haudio_record_jni.ccaudio_record_jni.haudio_track_jni.ccaudio_track_jni.hopensles_input.ccopensles_input.hopensles_output.ccopensles_output.h
audio_device_generic.haudio_device_impl.ccaudio_device_impl.hdummy
include
ios
linux
audio_device_alsa_linux.ccaudio_device_alsa_linux.haudio_device_pulse_linux.ccaudio_device_pulse_linux.h
mac
test
win
voice_engine
@ -175,11 +175,6 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t SpeakerIsAvailable(
|
||||
bool& available) { // NOLINT
|
||||
return output_.SpeakerIsAvailable(available);
|
||||
}
|
||||
|
||||
int32_t InitSpeaker() {
|
||||
return output_.InitSpeaker();
|
||||
}
|
||||
@ -188,11 +183,6 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
||||
return output_.SpeakerIsInitialized();
|
||||
}
|
||||
|
||||
int32_t MicrophoneIsAvailable(
|
||||
bool& available) { // NOLINT
|
||||
return input_.MicrophoneIsAvailable(available);
|
||||
}
|
||||
|
||||
int32_t InitMicrophone() {
|
||||
return input_.InitMicrophone();
|
||||
}
|
||||
|
@ -608,12 +608,6 @@ int32_t AudioRecordJni::SetAGC(bool enable) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t AudioRecordJni::MicrophoneIsAvailable(bool& available) { // NOLINT
|
||||
// We always assume it's available
|
||||
available = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t AudioRecordJni::InitMicrophone() {
|
||||
CriticalSectionScoped lock(&_critSect);
|
||||
|
||||
|
@ -67,7 +67,6 @@ class AudioRecordJni {
|
||||
bool AGC() const { return _AGC; }
|
||||
|
||||
// Audio mixer initialization
|
||||
int32_t MicrophoneIsAvailable(bool& available); // NOLINT
|
||||
int32_t InitMicrophone();
|
||||
bool MicrophoneIsInitialized() const { return _micIsInitialized; }
|
||||
|
||||
|
@ -597,12 +597,6 @@ int32_t AudioTrackJni::StopPlayout() {
|
||||
|
||||
}
|
||||
|
||||
int32_t AudioTrackJni::SpeakerIsAvailable(bool& available) { // NOLINT
|
||||
// We always assume it's available
|
||||
available = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t AudioTrackJni::InitSpeaker() {
|
||||
CriticalSectionScoped lock(&_critSect);
|
||||
|
||||
|
@ -62,7 +62,6 @@ class AudioTrackJni : public PlayoutDelayProvider {
|
||||
bool Playing() const { return _playing; }
|
||||
|
||||
// Audio mixer initialization
|
||||
int32_t SpeakerIsAvailable(bool& available); // NOLINT
|
||||
int32_t InitSpeaker();
|
||||
bool SpeakerIsInitialized() const { return _speakerIsInitialized; }
|
||||
|
||||
|
@ -180,11 +180,6 @@ int32_t OpenSlesInput::SetAGC(bool enable) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t OpenSlesInput::MicrophoneIsAvailable(bool& available) { // NOLINT
|
||||
available = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t OpenSlesInput::InitMicrophone() {
|
||||
assert(initialized_);
|
||||
assert(!recording_);
|
||||
|
@ -77,7 +77,6 @@ class OpenSlesInput {
|
||||
bool AGC() const { return agc_enabled_; }
|
||||
|
||||
// Audio mixer initialization
|
||||
int32_t MicrophoneIsAvailable(bool& available); // NOLINT
|
||||
int32_t InitMicrophone();
|
||||
bool MicrophoneIsInitialized() const { return mic_initialized_; }
|
||||
|
||||
|
@ -188,11 +188,6 @@ int32_t OpenSlesOutput::StopPlayout() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t OpenSlesOutput::SpeakerIsAvailable(bool& available) { // NOLINT
|
||||
available = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t OpenSlesOutput::InitSpeaker() {
|
||||
assert(!playing_);
|
||||
speaker_initialized_ = true;
|
||||
|
@ -74,7 +74,6 @@ class OpenSlesOutput : public PlayoutDelayProvider {
|
||||
bool Playing() const { return playing_; }
|
||||
|
||||
// Audio mixer initialization
|
||||
int32_t SpeakerIsAvailable(bool& available); // NOLINT
|
||||
int32_t InitSpeaker();
|
||||
bool SpeakerIsInitialized() const { return speaker_initialized_; }
|
||||
|
||||
|
@ -76,10 +76,8 @@ class AudioDeviceGeneric
|
||||
uint16_t& volumeRight) const = 0;
|
||||
|
||||
// Audio mixer initialization
|
||||
virtual int32_t SpeakerIsAvailable(bool& available) = 0;
|
||||
virtual int32_t InitSpeaker() = 0;
|
||||
virtual bool SpeakerIsInitialized() const = 0;
|
||||
virtual int32_t MicrophoneIsAvailable(bool& available) = 0;
|
||||
virtual int32_t InitMicrophone() = 0;
|
||||
virtual bool MicrophoneIsInitialized() const = 0;
|
||||
|
||||
@ -137,7 +135,7 @@ class AudioDeviceGeneric
|
||||
|
||||
// CPU load
|
||||
virtual int32_t CPULoad(uint16_t& load) const = 0;
|
||||
|
||||
|
||||
// Native sample rate controls (samples/sec)
|
||||
virtual int32_t SetRecordingSampleRate(
|
||||
const uint32_t samplesPerSec);
|
||||
@ -147,7 +145,7 @@ class AudioDeviceGeneric
|
||||
// Speaker audio routing (for mobile devices)
|
||||
virtual int32_t SetLoudspeakerStatus(bool enable);
|
||||
virtual int32_t GetLoudspeakerStatus(bool& enable) const;
|
||||
|
||||
|
||||
// Reset Audio Device (for mobile devices)
|
||||
virtual int32_t ResetAudioDevice();
|
||||
|
||||
|
@ -640,27 +640,6 @@ bool AudioDeviceModuleImpl::Initialized() const
|
||||
return (_initialized);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// SpeakerIsAvailable
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int32_t AudioDeviceModuleImpl::SpeakerIsAvailable(bool* available)
|
||||
{
|
||||
CHECK_INITIALIZED();
|
||||
|
||||
bool isAvailable(0);
|
||||
|
||||
if (_ptrAudioDevice->SpeakerIsAvailable(isAvailable) == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
*available = isAvailable;
|
||||
|
||||
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioDevice, _id, "output: available=%d", available);
|
||||
return (0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// InitSpeaker
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -671,27 +650,6 @@ int32_t AudioDeviceModuleImpl::InitSpeaker()
|
||||
return (_ptrAudioDevice->InitSpeaker());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// MicrophoneIsAvailable
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int32_t AudioDeviceModuleImpl::MicrophoneIsAvailable(bool* available)
|
||||
{
|
||||
CHECK_INITIALIZED();
|
||||
|
||||
bool isAvailable(0);
|
||||
|
||||
if (_ptrAudioDevice->MicrophoneIsAvailable(isAvailable) == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
*available = isAvailable;
|
||||
|
||||
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioDevice, _id, "output: available=%d", *available);
|
||||
return (0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// InitMicrophone
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -115,10 +115,8 @@ public:
|
||||
uint16_t* volumeRight) const OVERRIDE;
|
||||
|
||||
// Audio mixer initialization
|
||||
virtual int32_t SpeakerIsAvailable(bool* available) OVERRIDE;
|
||||
virtual int32_t InitSpeaker() OVERRIDE;
|
||||
virtual bool SpeakerIsInitialized() const OVERRIDE;
|
||||
virtual int32_t MicrophoneIsAvailable(bool* available) OVERRIDE;
|
||||
virtual int32_t InitMicrophone() OVERRIDE;
|
||||
virtual bool MicrophoneIsInitialized() const OVERRIDE;
|
||||
|
||||
|
@ -91,14 +91,10 @@ int32_t AudioDeviceDummy::WaveOutVolume(uint16_t& volumeLeft,
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t AudioDeviceDummy::SpeakerIsAvailable(bool& available) { return -1; }
|
||||
|
||||
int32_t AudioDeviceDummy::InitSpeaker() { return -1; }
|
||||
|
||||
bool AudioDeviceDummy::SpeakerIsInitialized() const { return false; }
|
||||
|
||||
int32_t AudioDeviceDummy::MicrophoneIsAvailable(bool& available) { return -1; }
|
||||
|
||||
int32_t AudioDeviceDummy::InitMicrophone() { return -1; }
|
||||
|
||||
bool AudioDeviceDummy::MicrophoneIsInitialized() const { return false; }
|
||||
|
@ -76,10 +76,8 @@ class AudioDeviceDummy : public AudioDeviceGeneric {
|
||||
uint16_t& volumeRight) const OVERRIDE;
|
||||
|
||||
// Audio mixer initialization
|
||||
virtual int32_t SpeakerIsAvailable(bool& available) OVERRIDE;
|
||||
virtual int32_t InitSpeaker() OVERRIDE;
|
||||
virtual bool SpeakerIsInitialized() const OVERRIDE;
|
||||
virtual int32_t MicrophoneIsAvailable(bool& available) OVERRIDE;
|
||||
virtual int32_t InitMicrophone() OVERRIDE;
|
||||
virtual bool MicrophoneIsInitialized() const OVERRIDE;
|
||||
|
||||
|
@ -107,10 +107,8 @@ class AudioDeviceModule : public RefCountedModule {
|
||||
uint16_t* volumeRight) const = 0;
|
||||
|
||||
// Audio mixer initialization
|
||||
virtual int32_t SpeakerIsAvailable(bool* available) = 0;
|
||||
virtual int32_t InitSpeaker() = 0;
|
||||
virtual bool SpeakerIsInitialized() const = 0;
|
||||
virtual int32_t MicrophoneIsAvailable(bool* available) = 0;
|
||||
virtual int32_t InitMicrophone() = 0;
|
||||
virtual bool MicrophoneIsInitialized() const = 0;
|
||||
|
||||
|
@ -25,19 +25,11 @@ class FakeAudioDeviceModule : public AudioDeviceModule {
|
||||
return 0;
|
||||
}
|
||||
virtual int32_t Init() { return 0; }
|
||||
virtual int32_t SpeakerIsAvailable(bool* available) {
|
||||
*available = true;
|
||||
return 0;
|
||||
}
|
||||
virtual int32_t InitSpeaker() { return 0; }
|
||||
virtual int32_t SetPlayoutDevice(uint16_t index) { return 0; }
|
||||
virtual int32_t SetPlayoutDevice(WindowsDeviceType device) { return 0; }
|
||||
virtual int32_t SetStereoPlayout(bool enable) { return 0; }
|
||||
virtual int32_t StopPlayout() { return 0; }
|
||||
virtual int32_t MicrophoneIsAvailable(bool* available) {
|
||||
*available = true;
|
||||
return 0;
|
||||
}
|
||||
virtual int32_t InitMicrophone() { return 0; }
|
||||
virtual int32_t SetRecordingDevice(uint16_t index) { return 0; }
|
||||
virtual int32_t SetRecordingDevice(WindowsDeviceType device) { return 0; }
|
||||
|
@ -175,15 +175,6 @@ bool AudioDeviceIPhone::Initialized() const {
|
||||
return (_initialized);
|
||||
}
|
||||
|
||||
int32_t AudioDeviceIPhone::SpeakerIsAvailable(bool& available) {
|
||||
WEBRTC_TRACE(kTraceModuleCall, kTraceAudioDevice, _id,
|
||||
"%s", __FUNCTION__);
|
||||
|
||||
// speaker is always available in IOS
|
||||
available = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t AudioDeviceIPhone::InitSpeaker() {
|
||||
WEBRTC_TRACE(kTraceModuleCall, kTraceAudioDevice, _id,
|
||||
"%s", __FUNCTION__);
|
||||
@ -214,20 +205,6 @@ int32_t AudioDeviceIPhone::InitSpeaker() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t AudioDeviceIPhone::MicrophoneIsAvailable(bool& available) {
|
||||
WEBRTC_TRACE(kTraceModuleCall, kTraceAudioDevice, _id,
|
||||
"%s", __FUNCTION__);
|
||||
|
||||
// This function has never been implemented correctly (boo!) but
|
||||
// the returned |available| value is ignored (yay?) so for now
|
||||
// just hard-code the previous (more buggily-implemented behavior)
|
||||
// until the entire MicrophoneIsAvailable interface is ripped out
|
||||
// (since it's apparently useless).
|
||||
// https://code.google.com/p/webrtc/issues/detail?id=3132
|
||||
available = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t AudioDeviceIPhone::InitMicrophone() {
|
||||
WEBRTC_TRACE(kTraceModuleCall, kTraceAudioDevice, _id,
|
||||
"%s", __FUNCTION__);
|
||||
|
@ -90,10 +90,8 @@ public:
|
||||
uint16_t& volumeRight) const;
|
||||
|
||||
// Audio mixer initialization
|
||||
virtual int32_t SpeakerIsAvailable(bool& available);
|
||||
virtual int32_t InitSpeaker();
|
||||
virtual bool SpeakerIsInitialized() const;
|
||||
virtual int32_t MicrophoneIsAvailable(bool& available);
|
||||
virtual int32_t InitMicrophone();
|
||||
virtual bool MicrophoneIsInitialized() const;
|
||||
|
||||
|
@ -273,34 +273,6 @@ bool AudioDeviceLinuxALSA::Initialized() const
|
||||
return (_initialized);
|
||||
}
|
||||
|
||||
int32_t AudioDeviceLinuxALSA::SpeakerIsAvailable(bool& available)
|
||||
{
|
||||
|
||||
bool wasInitialized = _mixerManager.SpeakerIsInitialized();
|
||||
|
||||
// Make an attempt to open up the
|
||||
// output mixer corresponding to the currently selected output device.
|
||||
//
|
||||
if (!wasInitialized && InitSpeaker() == -1)
|
||||
{
|
||||
available = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Given that InitSpeaker was successful, we know that a valid speaker
|
||||
// exists
|
||||
available = true;
|
||||
|
||||
// Close the initialized output mixer
|
||||
//
|
||||
if (!wasInitialized)
|
||||
{
|
||||
_mixerManager.CloseSpeaker();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t AudioDeviceLinuxALSA::InitSpeaker()
|
||||
{
|
||||
|
||||
@ -316,34 +288,6 @@ int32_t AudioDeviceLinuxALSA::InitSpeaker()
|
||||
return _mixerManager.OpenSpeaker(devName);
|
||||
}
|
||||
|
||||
int32_t AudioDeviceLinuxALSA::MicrophoneIsAvailable(bool& available)
|
||||
{
|
||||
|
||||
bool wasInitialized = _mixerManager.MicrophoneIsInitialized();
|
||||
|
||||
// Make an attempt to open up the
|
||||
// input mixer corresponding to the currently selected output device.
|
||||
//
|
||||
if (!wasInitialized && InitMicrophone() == -1)
|
||||
{
|
||||
available = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Given that InitMicrophone was successful, we know that a valid
|
||||
// microphone exists
|
||||
available = true;
|
||||
|
||||
// Close the initialized input mixer
|
||||
//
|
||||
if (!wasInitialized)
|
||||
{
|
||||
_mixerManager.CloseMicrophone();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t AudioDeviceLinuxALSA::InitMicrophone()
|
||||
{
|
||||
|
||||
|
@ -90,10 +90,8 @@ public:
|
||||
uint16_t& volumeRight) const OVERRIDE;
|
||||
|
||||
// Audio mixer initialization
|
||||
virtual int32_t SpeakerIsAvailable(bool& available) OVERRIDE;
|
||||
virtual int32_t InitSpeaker() OVERRIDE;
|
||||
virtual bool SpeakerIsInitialized() const OVERRIDE;
|
||||
virtual int32_t MicrophoneIsAvailable(bool& available) OVERRIDE;
|
||||
virtual int32_t InitMicrophone() OVERRIDE;
|
||||
virtual bool MicrophoneIsInitialized() const OVERRIDE;
|
||||
|
||||
|
@ -341,34 +341,6 @@ bool AudioDeviceLinuxPulse::Initialized() const
|
||||
return (_initialized);
|
||||
}
|
||||
|
||||
int32_t AudioDeviceLinuxPulse::SpeakerIsAvailable(bool& available)
|
||||
{
|
||||
|
||||
bool wasInitialized = _mixerManager.SpeakerIsInitialized();
|
||||
|
||||
// Make an attempt to open up the
|
||||
// output mixer corresponding to the currently selected output device.
|
||||
//
|
||||
if (!wasInitialized && InitSpeaker() == -1)
|
||||
{
|
||||
available = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Given that InitSpeaker was successful, we know that a valid speaker exists
|
||||
//
|
||||
available = true;
|
||||
|
||||
// Close the initialized output mixer
|
||||
//
|
||||
if (!wasInitialized)
|
||||
{
|
||||
_mixerManager.CloseSpeaker();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t AudioDeviceLinuxPulse::InitSpeaker()
|
||||
{
|
||||
|
||||
@ -414,34 +386,6 @@ int32_t AudioDeviceLinuxPulse::InitSpeaker()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t AudioDeviceLinuxPulse::MicrophoneIsAvailable(bool& available)
|
||||
{
|
||||
|
||||
bool wasInitialized = _mixerManager.MicrophoneIsInitialized();
|
||||
|
||||
// Make an attempt to open up the
|
||||
// input mixer corresponding to the currently selected output device.
|
||||
//
|
||||
if (!wasInitialized && InitMicrophone() == -1)
|
||||
{
|
||||
available = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Given that InitMicrophone was successful, we know that a valid microphone
|
||||
// exists
|
||||
available = true;
|
||||
|
||||
// Close the initialized input mixer
|
||||
//
|
||||
if (!wasInitialized)
|
||||
{
|
||||
_mixerManager.CloseMicrophone();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t AudioDeviceLinuxPulse::InitMicrophone()
|
||||
{
|
||||
|
||||
|
@ -151,10 +151,8 @@ public:
|
||||
uint16_t& volumeRight) const OVERRIDE;
|
||||
|
||||
// Audio mixer initialization
|
||||
virtual int32_t SpeakerIsAvailable(bool& available) OVERRIDE;
|
||||
virtual int32_t InitSpeaker() OVERRIDE;
|
||||
virtual bool SpeakerIsInitialized() const OVERRIDE;
|
||||
virtual int32_t MicrophoneIsAvailable(bool& available) OVERRIDE;
|
||||
virtual int32_t InitMicrophone() OVERRIDE;
|
||||
virtual bool MicrophoneIsInitialized() const OVERRIDE;
|
||||
|
||||
|
@ -571,7 +571,6 @@ int32_t AudioDeviceMac::MicrophoneIsAvailable(bool& available)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t AudioDeviceMac::InitMicrophone()
|
||||
{
|
||||
|
||||
|
@ -108,10 +108,8 @@ public:
|
||||
uint16_t& volumeRight) const;
|
||||
|
||||
// Audio mixer initialization
|
||||
virtual int32_t SpeakerIsAvailable(bool& available);
|
||||
virtual int32_t InitSpeaker();
|
||||
virtual bool SpeakerIsInitialized() const;
|
||||
virtual int32_t MicrophoneIsAvailable(bool& available);
|
||||
virtual int32_t InitMicrophone();
|
||||
virtual bool MicrophoneIsInitialized() const;
|
||||
|
||||
@ -167,7 +165,6 @@ public:
|
||||
// CPU load
|
||||
virtual int32_t CPULoad(uint16_t& load) const;
|
||||
|
||||
public:
|
||||
virtual bool PlayoutWarning() const;
|
||||
virtual bool PlayoutError() const;
|
||||
virtual bool RecordingWarning() const;
|
||||
@ -177,10 +174,12 @@ public:
|
||||
virtual void ClearRecordingWarning();
|
||||
virtual void ClearRecordingError();
|
||||
|
||||
public:
|
||||
virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer);
|
||||
|
||||
private:
|
||||
virtual int32_t MicrophoneIsAvailable(bool& available);
|
||||
virtual int32_t SpeakerIsAvailable(bool& available);
|
||||
|
||||
void Lock()
|
||||
{
|
||||
_critSect.Enter();
|
||||
@ -236,7 +235,6 @@ private:
|
||||
int32_t
|
||||
HandleProcessorOverload(AudioObjectPropertyAddress propertyAddress);
|
||||
|
||||
private:
|
||||
static OSStatus deviceIOProc(AudioDeviceID device,
|
||||
const AudioTimeStamp *now,
|
||||
const AudioBufferList *inputData,
|
||||
@ -284,10 +282,8 @@ private:
|
||||
bool CaptureWorkerThread();
|
||||
bool RenderWorkerThread();
|
||||
|
||||
private:
|
||||
bool KeyPressed();
|
||||
|
||||
private:
|
||||
AudioDeviceBuffer* _ptrAudioBuffer;
|
||||
|
||||
CriticalSectionWrapper& _critSect;
|
||||
@ -325,7 +321,6 @@ private:
|
||||
|
||||
AudioDeviceModule::BufferType _playBufType;
|
||||
|
||||
private:
|
||||
bool _initialized;
|
||||
bool _isShutDown;
|
||||
bool _recording;
|
||||
@ -361,7 +356,6 @@ private:
|
||||
|
||||
int32_t _renderDelayOffsetSamples;
|
||||
|
||||
private:
|
||||
uint16_t _playBufDelayFixed; // fixed playback delay
|
||||
|
||||
uint16_t _playWarning;
|
||||
@ -378,7 +372,6 @@ private:
|
||||
int _captureBufSizeSamples;
|
||||
int _renderBufSizeSamples;
|
||||
|
||||
private:
|
||||
// Typing detection
|
||||
// 0x5c is key "9", after that comes function keys.
|
||||
bool prev_key_state_[0x5d];
|
||||
|
@ -787,33 +787,6 @@ TEST_F(AudioDeviceAPITest, SetAndGetWaveOutVolume) {
|
||||
}
|
||||
#endif // defined(_WIN32) && !defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
|
||||
|
||||
TEST_F(AudioDeviceAPITest, SpeakerIsAvailable) {
|
||||
bool available;
|
||||
CheckInitialPlayoutStates();
|
||||
|
||||
#ifdef _WIN32
|
||||
// check the kDefaultCommunicationDevice
|
||||
EXPECT_TRUE(audio_device_->SetPlayoutDevice(
|
||||
AudioDeviceModule::kDefaultCommunicationDevice) == 0);
|
||||
EXPECT_EQ(0, audio_device_->SpeakerIsAvailable(&available));
|
||||
// check for availability should not lead to initialization
|
||||
EXPECT_FALSE(audio_device_->SpeakerIsInitialized());
|
||||
#endif
|
||||
|
||||
// check the kDefaultDevice
|
||||
EXPECT_EQ(0, audio_device_->SetPlayoutDevice(MACRO_DEFAULT_DEVICE));
|
||||
EXPECT_EQ(0, audio_device_->SpeakerIsAvailable(&available));
|
||||
EXPECT_FALSE(audio_device_->SpeakerIsInitialized());
|
||||
|
||||
// check all availiable devices
|
||||
int16_t no_devices = audio_device_->PlayoutDevices();
|
||||
for (int i = 0; i < no_devices; i++) {
|
||||
EXPECT_EQ(0, audio_device_->SetPlayoutDevice(i));
|
||||
EXPECT_EQ(0, audio_device_->SpeakerIsAvailable(&available));
|
||||
EXPECT_FALSE(audio_device_->SpeakerIsInitialized());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(AudioDeviceAPITest, InitSpeaker) {
|
||||
// NOTE: By calling Terminate (in TearDown) followed by Init (in SetUp) we
|
||||
// ensure that any existing output mixer handle is set to NULL.
|
||||
@ -824,13 +797,10 @@ TEST_F(AudioDeviceAPITest, InitSpeaker) {
|
||||
// kDefaultCommunicationDevice
|
||||
EXPECT_EQ(0, audio_device_->SetPlayoutDevice(
|
||||
MACRO_DEFAULT_COMMUNICATION_DEVICE));
|
||||
bool available;
|
||||
EXPECT_EQ(0, audio_device_->SpeakerIsAvailable(&available));
|
||||
if (available) {
|
||||
EXPECT_EQ(0, audio_device_->InitSpeaker());
|
||||
}
|
||||
EXPECT_EQ(0, audio_device_->InitSpeaker());
|
||||
|
||||
// fail tests
|
||||
bool available;
|
||||
EXPECT_EQ(0, audio_device_->PlayoutIsAvailable(&available));
|
||||
if (available) {
|
||||
EXPECT_EQ(0, audio_device_->InitPlayout());
|
||||
@ -841,45 +811,13 @@ TEST_F(AudioDeviceAPITest, InitSpeaker) {
|
||||
|
||||
// kDefaultDevice
|
||||
EXPECT_EQ(0, audio_device_->SetPlayoutDevice(MACRO_DEFAULT_DEVICE));
|
||||
EXPECT_EQ(0, audio_device_->SpeakerIsAvailable(&available));
|
||||
if (available) {
|
||||
EXPECT_EQ(0, audio_device_->InitSpeaker());
|
||||
}
|
||||
EXPECT_EQ(0, audio_device_->InitSpeaker());
|
||||
|
||||
// repeat test for all devices
|
||||
int16_t no_devices = audio_device_->PlayoutDevices();
|
||||
for (int i = 0; i < no_devices; i++) {
|
||||
EXPECT_EQ(0, audio_device_->SetPlayoutDevice(i));
|
||||
EXPECT_EQ(0, audio_device_->SpeakerIsAvailable(&available));
|
||||
if (available) {
|
||||
EXPECT_EQ(0, audio_device_->InitSpeaker());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(AudioDeviceAPITest, MicrophoneIsAvailable) {
|
||||
CheckInitialRecordingStates();
|
||||
bool available;
|
||||
#ifdef _WIN32
|
||||
// check the kDefaultCommunicationDevice
|
||||
EXPECT_TRUE(audio_device_->SetRecordingDevice(
|
||||
AudioDeviceModule::kDefaultCommunicationDevice) == 0);
|
||||
EXPECT_EQ(0, audio_device_->MicrophoneIsAvailable(&available));
|
||||
// check for availability should not lead to initialization
|
||||
EXPECT_FALSE(audio_device_->MicrophoneIsInitialized());
|
||||
#endif
|
||||
|
||||
// check the kDefaultDevice
|
||||
EXPECT_EQ(0, audio_device_->SetRecordingDevice(MACRO_DEFAULT_DEVICE));
|
||||
EXPECT_EQ(0, audio_device_->MicrophoneIsAvailable(&available));
|
||||
EXPECT_FALSE(audio_device_->MicrophoneIsInitialized());
|
||||
|
||||
// check all availiable devices
|
||||
int16_t no_devices = audio_device_->RecordingDevices();
|
||||
for (int i = 0; i < no_devices; i++) {
|
||||
EXPECT_EQ(0, audio_device_->SetRecordingDevice(i));
|
||||
EXPECT_EQ(0, audio_device_->MicrophoneIsAvailable(&available));
|
||||
EXPECT_FALSE(audio_device_->MicrophoneIsInitialized());
|
||||
EXPECT_EQ(0, audio_device_->InitSpeaker());
|
||||
}
|
||||
}
|
||||
|
||||
@ -893,13 +831,10 @@ TEST_F(AudioDeviceAPITest, InitMicrophone) {
|
||||
// kDefaultCommunicationDevice
|
||||
EXPECT_EQ(0,
|
||||
audio_device_->SetRecordingDevice(MACRO_DEFAULT_COMMUNICATION_DEVICE));
|
||||
bool available;
|
||||
EXPECT_EQ(0, audio_device_->MicrophoneIsAvailable(&available));
|
||||
if (available) {
|
||||
EXPECT_EQ(0, audio_device_->InitMicrophone());
|
||||
}
|
||||
EXPECT_EQ(0, audio_device_->InitMicrophone());
|
||||
|
||||
// fail tests
|
||||
bool available;
|
||||
EXPECT_EQ(0, audio_device_->RecordingIsAvailable(&available));
|
||||
if (available) {
|
||||
EXPECT_EQ(0, audio_device_->InitRecording());
|
||||
@ -910,19 +845,13 @@ TEST_F(AudioDeviceAPITest, InitMicrophone) {
|
||||
|
||||
// kDefaultDevice
|
||||
EXPECT_EQ(0, audio_device_->SetRecordingDevice(MACRO_DEFAULT_DEVICE));
|
||||
EXPECT_EQ(0, audio_device_->MicrophoneIsAvailable(&available));
|
||||
if (available) {
|
||||
EXPECT_EQ(0, audio_device_->InitMicrophone());
|
||||
}
|
||||
EXPECT_EQ(0, audio_device_->InitMicrophone());
|
||||
|
||||
// repeat test for all devices
|
||||
int16_t no_devices = audio_device_->RecordingDevices();
|
||||
for (int i = 0; i < no_devices; i++) {
|
||||
EXPECT_EQ(0, audio_device_->SetRecordingDevice(i));
|
||||
EXPECT_EQ(0, audio_device_->MicrophoneIsAvailable(&available));
|
||||
if (available) {
|
||||
EXPECT_EQ(0, audio_device_->InitMicrophone());
|
||||
}
|
||||
EXPECT_EQ(0, audio_device_->InitMicrophone());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1013,8 +1013,6 @@ int32_t FuncTestManager::TestDeviceSelection()
|
||||
{
|
||||
PRINT_STR(Stereo Playout, false);
|
||||
}
|
||||
EXPECT_EQ(0, audioDevice->SpeakerIsAvailable(&available));
|
||||
PRINT_STR(Speaker, available);
|
||||
EXPECT_EQ(0, audioDevice->SpeakerVolumeIsAvailable(&available));
|
||||
PRINT_STR(Speaker Volume, available);
|
||||
EXPECT_EQ(0, audioDevice->SpeakerMuteIsAvailable(&available));
|
||||
@ -1033,8 +1031,6 @@ int32_t FuncTestManager::TestDeviceSelection()
|
||||
{
|
||||
PRINT_STR(Stereo Playout, false);
|
||||
}
|
||||
EXPECT_EQ(0, audioDevice->SpeakerIsAvailable(&available));
|
||||
PRINT_STR(Speaker, available);
|
||||
EXPECT_EQ(0, audioDevice->SpeakerVolumeIsAvailable(&available));
|
||||
PRINT_STR(Speaker Volume, available);
|
||||
EXPECT_EQ(0, audioDevice->SpeakerMuteIsAvailable(&available));
|
||||
@ -1060,8 +1056,6 @@ int32_t FuncTestManager::TestDeviceSelection()
|
||||
{
|
||||
PRINT_STR(Stereo Playout, false);
|
||||
}
|
||||
EXPECT_EQ(0, audioDevice->SpeakerIsAvailable(&available));
|
||||
PRINT_STR(Speaker, available);
|
||||
EXPECT_EQ(0, audioDevice->SpeakerVolumeIsAvailable(&available));
|
||||
PRINT_STR(Speaker Volume, available);
|
||||
EXPECT_EQ(0, audioDevice->SpeakerMuteIsAvailable(&available));
|
||||
@ -1091,8 +1085,6 @@ int32_t FuncTestManager::TestDeviceSelection()
|
||||
// special fix to ensure that we don't log 'available' when recording is not OK
|
||||
PRINT_STR(Stereo Recording, false);
|
||||
}
|
||||
EXPECT_EQ(0, audioDevice->MicrophoneIsAvailable(&available));
|
||||
PRINT_STR(Microphone, available);
|
||||
EXPECT_EQ(0, audioDevice->MicrophoneVolumeIsAvailable(&available));
|
||||
PRINT_STR(Microphone Volume, available);
|
||||
EXPECT_EQ(0, audioDevice->MicrophoneMuteIsAvailable(&available));
|
||||
@ -1114,8 +1106,6 @@ int32_t FuncTestManager::TestDeviceSelection()
|
||||
// special fix to ensure that we don't log 'available' when recording is not OK
|
||||
PRINT_STR(Stereo Recording, false);
|
||||
}
|
||||
EXPECT_EQ(0, audioDevice->MicrophoneIsAvailable(&available));
|
||||
PRINT_STR(Microphone, available);
|
||||
EXPECT_EQ(0, audioDevice->MicrophoneVolumeIsAvailable(&available));
|
||||
PRINT_STR(Microphone Volume, available);
|
||||
EXPECT_EQ(0, audioDevice->MicrophoneMuteIsAvailable(&available));
|
||||
@ -1145,8 +1135,6 @@ int32_t FuncTestManager::TestDeviceSelection()
|
||||
// is not OK
|
||||
PRINT_STR(Stereo Recording, false);
|
||||
}
|
||||
EXPECT_EQ(0, audioDevice->MicrophoneIsAvailable(&available));
|
||||
PRINT_STR(Microphone, available);
|
||||
EXPECT_EQ(0, audioDevice->MicrophoneVolumeIsAvailable(&available));
|
||||
PRINT_STR(Microphone Volume, available);
|
||||
EXPECT_EQ(0, audioDevice->MicrophoneMuteIsAvailable(&available));
|
||||
|
@ -750,25 +750,6 @@ bool AudioDeviceWindowsCore::Initialized() const
|
||||
return (_initialized);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// SpeakerIsAvailable
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int32_t AudioDeviceWindowsCore::SpeakerIsAvailable(bool& available)
|
||||
{
|
||||
|
||||
CriticalSectionScoped lock(&_critSect);
|
||||
|
||||
if (_ptrDeviceOut == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
available = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// InitSpeaker
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -851,25 +832,6 @@ int32_t AudioDeviceWindowsCore::InitSpeaker()
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// MicrophoneIsAvailable
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int32_t AudioDeviceWindowsCore::MicrophoneIsAvailable(bool& available)
|
||||
{
|
||||
|
||||
CriticalSectionScoped lock(&_critSect);
|
||||
|
||||
if (_ptrDeviceIn == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
available = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// InitMicrophone
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -138,10 +138,8 @@ public:
|
||||
virtual int32_t WaveOutVolume(uint16_t& volumeLeft, uint16_t& volumeRight) const;
|
||||
|
||||
// Audio mixer initialization
|
||||
virtual int32_t SpeakerIsAvailable(bool& available);
|
||||
virtual int32_t InitSpeaker();
|
||||
virtual bool SpeakerIsInitialized() const;
|
||||
virtual int32_t MicrophoneIsAvailable(bool& available);
|
||||
virtual int32_t InitMicrophone();
|
||||
virtual bool MicrophoneIsInitialized() const;
|
||||
|
||||
|
@ -489,33 +489,6 @@ bool AudioDeviceWindowsWave::Initialized() const
|
||||
return (_initialized);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// SpeakerIsAvailable
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int32_t AudioDeviceWindowsWave::SpeakerIsAvailable(bool& available)
|
||||
{
|
||||
|
||||
// Enumerate all avaliable speakers and make an attempt to open up the
|
||||
// output mixer corresponding to the currently selected output device.
|
||||
//
|
||||
if (InitSpeaker() == -1)
|
||||
{
|
||||
available = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Given that InitSpeaker was successful, we know that a valid speaker exists
|
||||
//
|
||||
available = true;
|
||||
|
||||
// Close the initialized output mixer
|
||||
//
|
||||
_mixerManager.CloseSpeaker();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// InitSpeaker
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -554,33 +527,6 @@ int32_t AudioDeviceWindowsWave::InitSpeaker()
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// MicrophoneIsAvailable
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int32_t AudioDeviceWindowsWave::MicrophoneIsAvailable(bool& available)
|
||||
{
|
||||
|
||||
// Enumerate all avaliable microphones and make an attempt to open up the
|
||||
// input mixer corresponding to the currently selected output device.
|
||||
//
|
||||
if (InitMicrophone() == -1)
|
||||
{
|
||||
available = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Given that InitMicrophone was successful, we know that a valid microphone exists
|
||||
//
|
||||
available = true;
|
||||
|
||||
// Close the initialized input mixer
|
||||
//
|
||||
_mixerManager.CloseMicrophone();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// InitMicrophone
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -94,10 +94,8 @@ public:
|
||||
virtual int32_t WaveOutVolume(uint16_t& volumeLeft, uint16_t& volumeRight) const;
|
||||
|
||||
// Audio mixer initialization
|
||||
virtual int32_t SpeakerIsAvailable(bool& available);
|
||||
virtual int32_t InitSpeaker();
|
||||
virtual bool SpeakerIsInitialized() const;
|
||||
virtual int32_t MicrophoneIsAvailable(bool& available);
|
||||
virtual int32_t InitMicrophone();
|
||||
virtual bool MicrophoneIsInitialized() const;
|
||||
|
||||
|
@ -391,18 +391,6 @@ int VoEBaseImpl::Init(AudioDeviceModule* external_adm,
|
||||
_shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceInfo,
|
||||
"Init() failed to set the default output device");
|
||||
}
|
||||
if (_shared->audio_device()->SpeakerIsAvailable(&available) != 0)
|
||||
{
|
||||
_shared->SetLastError(VE_CANNOT_ACCESS_SPEAKER_VOL, kTraceInfo,
|
||||
"Init() failed to check speaker availability, trying to "
|
||||
"initialize speaker anyway");
|
||||
}
|
||||
else if (!available)
|
||||
{
|
||||
_shared->SetLastError(VE_CANNOT_ACCESS_SPEAKER_VOL, kTraceInfo,
|
||||
"Init() speaker not available, trying to initialize speaker "
|
||||
"anyway");
|
||||
}
|
||||
if (_shared->audio_device()->InitSpeaker() != 0)
|
||||
{
|
||||
_shared->SetLastError(VE_CANNOT_ACCESS_SPEAKER_VOL, kTraceInfo,
|
||||
@ -416,18 +404,6 @@ int VoEBaseImpl::Init(AudioDeviceModule* external_adm,
|
||||
_shared->SetLastError(VE_SOUNDCARD_ERROR, kTraceInfo,
|
||||
"Init() failed to set the default input device");
|
||||
}
|
||||
if (_shared->audio_device()->MicrophoneIsAvailable(&available) != 0)
|
||||
{
|
||||
_shared->SetLastError(VE_CANNOT_ACCESS_MIC_VOL, kTraceInfo,
|
||||
"Init() failed to check microphone availability, trying to "
|
||||
"initialize microphone anyway");
|
||||
}
|
||||
else if (!available)
|
||||
{
|
||||
_shared->SetLastError(VE_CANNOT_ACCESS_MIC_VOL, kTraceInfo,
|
||||
"Init() microphone not available, trying to initialize "
|
||||
"microphone anyway");
|
||||
}
|
||||
if (_shared->audio_device()->InitMicrophone() != 0)
|
||||
{
|
||||
_shared->SetLastError(VE_CANNOT_ACCESS_MIC_VOL, kTraceInfo,
|
||||
|
Loading…
Reference in New Issue
Block a user