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:
andrew@webrtc.org 2014-04-02 16:49:26 +00:00
parent 7549ff4257
commit c7c432aa9b
31 changed files with 13 additions and 463 deletions

View File

@ -175,11 +175,6 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
return -1; return -1;
} }
int32_t SpeakerIsAvailable(
bool& available) { // NOLINT
return output_.SpeakerIsAvailable(available);
}
int32_t InitSpeaker() { int32_t InitSpeaker() {
return output_.InitSpeaker(); return output_.InitSpeaker();
} }
@ -188,11 +183,6 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
return output_.SpeakerIsInitialized(); return output_.SpeakerIsInitialized();
} }
int32_t MicrophoneIsAvailable(
bool& available) { // NOLINT
return input_.MicrophoneIsAvailable(available);
}
int32_t InitMicrophone() { int32_t InitMicrophone() {
return input_.InitMicrophone(); return input_.InitMicrophone();
} }

View File

@ -608,12 +608,6 @@ int32_t AudioRecordJni::SetAGC(bool enable) {
return 0; return 0;
} }
int32_t AudioRecordJni::MicrophoneIsAvailable(bool& available) { // NOLINT
// We always assume it's available
available = true;
return 0;
}
int32_t AudioRecordJni::InitMicrophone() { int32_t AudioRecordJni::InitMicrophone() {
CriticalSectionScoped lock(&_critSect); CriticalSectionScoped lock(&_critSect);

View File

@ -67,7 +67,6 @@ class AudioRecordJni {
bool AGC() const { return _AGC; } bool AGC() const { return _AGC; }
// Audio mixer initialization // Audio mixer initialization
int32_t MicrophoneIsAvailable(bool& available); // NOLINT
int32_t InitMicrophone(); int32_t InitMicrophone();
bool MicrophoneIsInitialized() const { return _micIsInitialized; } bool MicrophoneIsInitialized() const { return _micIsInitialized; }

View File

@ -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() { int32_t AudioTrackJni::InitSpeaker() {
CriticalSectionScoped lock(&_critSect); CriticalSectionScoped lock(&_critSect);

View File

@ -62,7 +62,6 @@ class AudioTrackJni : public PlayoutDelayProvider {
bool Playing() const { return _playing; } bool Playing() const { return _playing; }
// Audio mixer initialization // Audio mixer initialization
int32_t SpeakerIsAvailable(bool& available); // NOLINT
int32_t InitSpeaker(); int32_t InitSpeaker();
bool SpeakerIsInitialized() const { return _speakerIsInitialized; } bool SpeakerIsInitialized() const { return _speakerIsInitialized; }

View File

@ -180,11 +180,6 @@ int32_t OpenSlesInput::SetAGC(bool enable) {
return 0; return 0;
} }
int32_t OpenSlesInput::MicrophoneIsAvailable(bool& available) { // NOLINT
available = true;
return 0;
}
int32_t OpenSlesInput::InitMicrophone() { int32_t OpenSlesInput::InitMicrophone() {
assert(initialized_); assert(initialized_);
assert(!recording_); assert(!recording_);

View File

@ -77,7 +77,6 @@ class OpenSlesInput {
bool AGC() const { return agc_enabled_; } bool AGC() const { return agc_enabled_; }
// Audio mixer initialization // Audio mixer initialization
int32_t MicrophoneIsAvailable(bool& available); // NOLINT
int32_t InitMicrophone(); int32_t InitMicrophone();
bool MicrophoneIsInitialized() const { return mic_initialized_; } bool MicrophoneIsInitialized() const { return mic_initialized_; }

View File

@ -188,11 +188,6 @@ int32_t OpenSlesOutput::StopPlayout() {
return 0; return 0;
} }
int32_t OpenSlesOutput::SpeakerIsAvailable(bool& available) { // NOLINT
available = true;
return 0;
}
int32_t OpenSlesOutput::InitSpeaker() { int32_t OpenSlesOutput::InitSpeaker() {
assert(!playing_); assert(!playing_);
speaker_initialized_ = true; speaker_initialized_ = true;

View File

@ -74,7 +74,6 @@ class OpenSlesOutput : public PlayoutDelayProvider {
bool Playing() const { return playing_; } bool Playing() const { return playing_; }
// Audio mixer initialization // Audio mixer initialization
int32_t SpeakerIsAvailable(bool& available); // NOLINT
int32_t InitSpeaker(); int32_t InitSpeaker();
bool SpeakerIsInitialized() const { return speaker_initialized_; } bool SpeakerIsInitialized() const { return speaker_initialized_; }

View File

@ -76,10 +76,8 @@ class AudioDeviceGeneric
uint16_t& volumeRight) const = 0; uint16_t& volumeRight) const = 0;
// Audio mixer initialization // Audio mixer initialization
virtual int32_t SpeakerIsAvailable(bool& available) = 0;
virtual int32_t InitSpeaker() = 0; virtual int32_t InitSpeaker() = 0;
virtual bool SpeakerIsInitialized() const = 0; virtual bool SpeakerIsInitialized() const = 0;
virtual int32_t MicrophoneIsAvailable(bool& available) = 0;
virtual int32_t InitMicrophone() = 0; virtual int32_t InitMicrophone() = 0;
virtual bool MicrophoneIsInitialized() const = 0; virtual bool MicrophoneIsInitialized() const = 0;
@ -137,7 +135,7 @@ class AudioDeviceGeneric
// CPU load // CPU load
virtual int32_t CPULoad(uint16_t& load) const = 0; virtual int32_t CPULoad(uint16_t& load) const = 0;
// Native sample rate controls (samples/sec) // Native sample rate controls (samples/sec)
virtual int32_t SetRecordingSampleRate( virtual int32_t SetRecordingSampleRate(
const uint32_t samplesPerSec); const uint32_t samplesPerSec);
@ -147,7 +145,7 @@ class AudioDeviceGeneric
// Speaker audio routing (for mobile devices) // Speaker audio routing (for mobile devices)
virtual int32_t SetLoudspeakerStatus(bool enable); virtual int32_t SetLoudspeakerStatus(bool enable);
virtual int32_t GetLoudspeakerStatus(bool& enable) const; virtual int32_t GetLoudspeakerStatus(bool& enable) const;
// Reset Audio Device (for mobile devices) // Reset Audio Device (for mobile devices)
virtual int32_t ResetAudioDevice(); virtual int32_t ResetAudioDevice();

View File

@ -640,27 +640,6 @@ bool AudioDeviceModuleImpl::Initialized() const
return (_initialized); 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 // InitSpeaker
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -671,27 +650,6 @@ int32_t AudioDeviceModuleImpl::InitSpeaker()
return (_ptrAudioDevice->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 // InitMicrophone
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -115,10 +115,8 @@ public:
uint16_t* volumeRight) const OVERRIDE; uint16_t* volumeRight) const OVERRIDE;
// Audio mixer initialization // Audio mixer initialization
virtual int32_t SpeakerIsAvailable(bool* available) OVERRIDE;
virtual int32_t InitSpeaker() OVERRIDE; virtual int32_t InitSpeaker() OVERRIDE;
virtual bool SpeakerIsInitialized() const OVERRIDE; virtual bool SpeakerIsInitialized() const OVERRIDE;
virtual int32_t MicrophoneIsAvailable(bool* available) OVERRIDE;
virtual int32_t InitMicrophone() OVERRIDE; virtual int32_t InitMicrophone() OVERRIDE;
virtual bool MicrophoneIsInitialized() const OVERRIDE; virtual bool MicrophoneIsInitialized() const OVERRIDE;

View File

@ -91,14 +91,10 @@ int32_t AudioDeviceDummy::WaveOutVolume(uint16_t& volumeLeft,
return -1; return -1;
} }
int32_t AudioDeviceDummy::SpeakerIsAvailable(bool& available) { return -1; }
int32_t AudioDeviceDummy::InitSpeaker() { return -1; } int32_t AudioDeviceDummy::InitSpeaker() { return -1; }
bool AudioDeviceDummy::SpeakerIsInitialized() const { return false; } bool AudioDeviceDummy::SpeakerIsInitialized() const { return false; }
int32_t AudioDeviceDummy::MicrophoneIsAvailable(bool& available) { return -1; }
int32_t AudioDeviceDummy::InitMicrophone() { return -1; } int32_t AudioDeviceDummy::InitMicrophone() { return -1; }
bool AudioDeviceDummy::MicrophoneIsInitialized() const { return false; } bool AudioDeviceDummy::MicrophoneIsInitialized() const { return false; }

View File

@ -76,10 +76,8 @@ class AudioDeviceDummy : public AudioDeviceGeneric {
uint16_t& volumeRight) const OVERRIDE; uint16_t& volumeRight) const OVERRIDE;
// Audio mixer initialization // Audio mixer initialization
virtual int32_t SpeakerIsAvailable(bool& available) OVERRIDE;
virtual int32_t InitSpeaker() OVERRIDE; virtual int32_t InitSpeaker() OVERRIDE;
virtual bool SpeakerIsInitialized() const OVERRIDE; virtual bool SpeakerIsInitialized() const OVERRIDE;
virtual int32_t MicrophoneIsAvailable(bool& available) OVERRIDE;
virtual int32_t InitMicrophone() OVERRIDE; virtual int32_t InitMicrophone() OVERRIDE;
virtual bool MicrophoneIsInitialized() const OVERRIDE; virtual bool MicrophoneIsInitialized() const OVERRIDE;

View File

@ -107,10 +107,8 @@ class AudioDeviceModule : public RefCountedModule {
uint16_t* volumeRight) const = 0; uint16_t* volumeRight) const = 0;
// Audio mixer initialization // Audio mixer initialization
virtual int32_t SpeakerIsAvailable(bool* available) = 0;
virtual int32_t InitSpeaker() = 0; virtual int32_t InitSpeaker() = 0;
virtual bool SpeakerIsInitialized() const = 0; virtual bool SpeakerIsInitialized() const = 0;
virtual int32_t MicrophoneIsAvailable(bool* available) = 0;
virtual int32_t InitMicrophone() = 0; virtual int32_t InitMicrophone() = 0;
virtual bool MicrophoneIsInitialized() const = 0; virtual bool MicrophoneIsInitialized() const = 0;

View File

@ -25,19 +25,11 @@ class FakeAudioDeviceModule : public AudioDeviceModule {
return 0; return 0;
} }
virtual int32_t Init() { 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 InitSpeaker() { return 0; }
virtual int32_t SetPlayoutDevice(uint16_t index) { return 0; } virtual int32_t SetPlayoutDevice(uint16_t index) { return 0; }
virtual int32_t SetPlayoutDevice(WindowsDeviceType device) { return 0; } virtual int32_t SetPlayoutDevice(WindowsDeviceType device) { return 0; }
virtual int32_t SetStereoPlayout(bool enable) { return 0; } virtual int32_t SetStereoPlayout(bool enable) { return 0; }
virtual int32_t StopPlayout() { 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 InitMicrophone() { return 0; }
virtual int32_t SetRecordingDevice(uint16_t index) { return 0; } virtual int32_t SetRecordingDevice(uint16_t index) { return 0; }
virtual int32_t SetRecordingDevice(WindowsDeviceType device) { return 0; } virtual int32_t SetRecordingDevice(WindowsDeviceType device) { return 0; }

View File

@ -175,15 +175,6 @@ bool AudioDeviceIPhone::Initialized() const {
return (_initialized); 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() { int32_t AudioDeviceIPhone::InitSpeaker() {
WEBRTC_TRACE(kTraceModuleCall, kTraceAudioDevice, _id, WEBRTC_TRACE(kTraceModuleCall, kTraceAudioDevice, _id,
"%s", __FUNCTION__); "%s", __FUNCTION__);
@ -214,20 +205,6 @@ int32_t AudioDeviceIPhone::InitSpeaker() {
return 0; 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() { int32_t AudioDeviceIPhone::InitMicrophone() {
WEBRTC_TRACE(kTraceModuleCall, kTraceAudioDevice, _id, WEBRTC_TRACE(kTraceModuleCall, kTraceAudioDevice, _id,
"%s", __FUNCTION__); "%s", __FUNCTION__);

View File

@ -90,10 +90,8 @@ public:
uint16_t& volumeRight) const; uint16_t& volumeRight) const;
// Audio mixer initialization // Audio mixer initialization
virtual int32_t SpeakerIsAvailable(bool& available);
virtual int32_t InitSpeaker(); virtual int32_t InitSpeaker();
virtual bool SpeakerIsInitialized() const; virtual bool SpeakerIsInitialized() const;
virtual int32_t MicrophoneIsAvailable(bool& available);
virtual int32_t InitMicrophone(); virtual int32_t InitMicrophone();
virtual bool MicrophoneIsInitialized() const; virtual bool MicrophoneIsInitialized() const;

View File

@ -273,34 +273,6 @@ bool AudioDeviceLinuxALSA::Initialized() const
return (_initialized); 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() int32_t AudioDeviceLinuxALSA::InitSpeaker()
{ {
@ -316,34 +288,6 @@ int32_t AudioDeviceLinuxALSA::InitSpeaker()
return _mixerManager.OpenSpeaker(devName); 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() int32_t AudioDeviceLinuxALSA::InitMicrophone()
{ {

View File

@ -90,10 +90,8 @@ public:
uint16_t& volumeRight) const OVERRIDE; uint16_t& volumeRight) const OVERRIDE;
// Audio mixer initialization // Audio mixer initialization
virtual int32_t SpeakerIsAvailable(bool& available) OVERRIDE;
virtual int32_t InitSpeaker() OVERRIDE; virtual int32_t InitSpeaker() OVERRIDE;
virtual bool SpeakerIsInitialized() const OVERRIDE; virtual bool SpeakerIsInitialized() const OVERRIDE;
virtual int32_t MicrophoneIsAvailable(bool& available) OVERRIDE;
virtual int32_t InitMicrophone() OVERRIDE; virtual int32_t InitMicrophone() OVERRIDE;
virtual bool MicrophoneIsInitialized() const OVERRIDE; virtual bool MicrophoneIsInitialized() const OVERRIDE;

View File

@ -341,34 +341,6 @@ bool AudioDeviceLinuxPulse::Initialized() const
return (_initialized); 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() int32_t AudioDeviceLinuxPulse::InitSpeaker()
{ {
@ -414,34 +386,6 @@ int32_t AudioDeviceLinuxPulse::InitSpeaker()
return 0; 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() int32_t AudioDeviceLinuxPulse::InitMicrophone()
{ {

View File

@ -151,10 +151,8 @@ public:
uint16_t& volumeRight) const OVERRIDE; uint16_t& volumeRight) const OVERRIDE;
// Audio mixer initialization // Audio mixer initialization
virtual int32_t SpeakerIsAvailable(bool& available) OVERRIDE;
virtual int32_t InitSpeaker() OVERRIDE; virtual int32_t InitSpeaker() OVERRIDE;
virtual bool SpeakerIsInitialized() const OVERRIDE; virtual bool SpeakerIsInitialized() const OVERRIDE;
virtual int32_t MicrophoneIsAvailable(bool& available) OVERRIDE;
virtual int32_t InitMicrophone() OVERRIDE; virtual int32_t InitMicrophone() OVERRIDE;
virtual bool MicrophoneIsInitialized() const OVERRIDE; virtual bool MicrophoneIsInitialized() const OVERRIDE;

View File

@ -571,7 +571,6 @@ int32_t AudioDeviceMac::MicrophoneIsAvailable(bool& available)
return 0; return 0;
} }
int32_t AudioDeviceMac::InitMicrophone() int32_t AudioDeviceMac::InitMicrophone()
{ {

View File

@ -108,10 +108,8 @@ public:
uint16_t& volumeRight) const; uint16_t& volumeRight) const;
// Audio mixer initialization // Audio mixer initialization
virtual int32_t SpeakerIsAvailable(bool& available);
virtual int32_t InitSpeaker(); virtual int32_t InitSpeaker();
virtual bool SpeakerIsInitialized() const; virtual bool SpeakerIsInitialized() const;
virtual int32_t MicrophoneIsAvailable(bool& available);
virtual int32_t InitMicrophone(); virtual int32_t InitMicrophone();
virtual bool MicrophoneIsInitialized() const; virtual bool MicrophoneIsInitialized() const;
@ -167,7 +165,6 @@ public:
// CPU load // CPU load
virtual int32_t CPULoad(uint16_t& load) const; virtual int32_t CPULoad(uint16_t& load) const;
public:
virtual bool PlayoutWarning() const; virtual bool PlayoutWarning() const;
virtual bool PlayoutError() const; virtual bool PlayoutError() const;
virtual bool RecordingWarning() const; virtual bool RecordingWarning() const;
@ -177,10 +174,12 @@ public:
virtual void ClearRecordingWarning(); virtual void ClearRecordingWarning();
virtual void ClearRecordingError(); virtual void ClearRecordingError();
public:
virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer); virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer);
private: private:
virtual int32_t MicrophoneIsAvailable(bool& available);
virtual int32_t SpeakerIsAvailable(bool& available);
void Lock() void Lock()
{ {
_critSect.Enter(); _critSect.Enter();
@ -236,7 +235,6 @@ private:
int32_t int32_t
HandleProcessorOverload(AudioObjectPropertyAddress propertyAddress); HandleProcessorOverload(AudioObjectPropertyAddress propertyAddress);
private:
static OSStatus deviceIOProc(AudioDeviceID device, static OSStatus deviceIOProc(AudioDeviceID device,
const AudioTimeStamp *now, const AudioTimeStamp *now,
const AudioBufferList *inputData, const AudioBufferList *inputData,
@ -284,10 +282,8 @@ private:
bool CaptureWorkerThread(); bool CaptureWorkerThread();
bool RenderWorkerThread(); bool RenderWorkerThread();
private:
bool KeyPressed(); bool KeyPressed();
private:
AudioDeviceBuffer* _ptrAudioBuffer; AudioDeviceBuffer* _ptrAudioBuffer;
CriticalSectionWrapper& _critSect; CriticalSectionWrapper& _critSect;
@ -325,7 +321,6 @@ private:
AudioDeviceModule::BufferType _playBufType; AudioDeviceModule::BufferType _playBufType;
private:
bool _initialized; bool _initialized;
bool _isShutDown; bool _isShutDown;
bool _recording; bool _recording;
@ -361,7 +356,6 @@ private:
int32_t _renderDelayOffsetSamples; int32_t _renderDelayOffsetSamples;
private:
uint16_t _playBufDelayFixed; // fixed playback delay uint16_t _playBufDelayFixed; // fixed playback delay
uint16_t _playWarning; uint16_t _playWarning;
@ -378,7 +372,6 @@ private:
int _captureBufSizeSamples; int _captureBufSizeSamples;
int _renderBufSizeSamples; int _renderBufSizeSamples;
private:
// Typing detection // Typing detection
// 0x5c is key "9", after that comes function keys. // 0x5c is key "9", after that comes function keys.
bool prev_key_state_[0x5d]; bool prev_key_state_[0x5d];

View File

@ -787,33 +787,6 @@ TEST_F(AudioDeviceAPITest, SetAndGetWaveOutVolume) {
} }
#endif // defined(_WIN32) && !defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD) #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) { TEST_F(AudioDeviceAPITest, InitSpeaker) {
// NOTE: By calling Terminate (in TearDown) followed by Init (in SetUp) we // NOTE: By calling Terminate (in TearDown) followed by Init (in SetUp) we
// ensure that any existing output mixer handle is set to NULL. // ensure that any existing output mixer handle is set to NULL.
@ -824,13 +797,10 @@ TEST_F(AudioDeviceAPITest, InitSpeaker) {
// kDefaultCommunicationDevice // kDefaultCommunicationDevice
EXPECT_EQ(0, audio_device_->SetPlayoutDevice( EXPECT_EQ(0, audio_device_->SetPlayoutDevice(
MACRO_DEFAULT_COMMUNICATION_DEVICE)); MACRO_DEFAULT_COMMUNICATION_DEVICE));
bool available; EXPECT_EQ(0, audio_device_->InitSpeaker());
EXPECT_EQ(0, audio_device_->SpeakerIsAvailable(&available));
if (available) {
EXPECT_EQ(0, audio_device_->InitSpeaker());
}
// fail tests // fail tests
bool available;
EXPECT_EQ(0, audio_device_->PlayoutIsAvailable(&available)); EXPECT_EQ(0, audio_device_->PlayoutIsAvailable(&available));
if (available) { if (available) {
EXPECT_EQ(0, audio_device_->InitPlayout()); EXPECT_EQ(0, audio_device_->InitPlayout());
@ -841,45 +811,13 @@ TEST_F(AudioDeviceAPITest, InitSpeaker) {
// kDefaultDevice // kDefaultDevice
EXPECT_EQ(0, audio_device_->SetPlayoutDevice(MACRO_DEFAULT_DEVICE)); EXPECT_EQ(0, audio_device_->SetPlayoutDevice(MACRO_DEFAULT_DEVICE));
EXPECT_EQ(0, audio_device_->SpeakerIsAvailable(&available)); EXPECT_EQ(0, audio_device_->InitSpeaker());
if (available) {
EXPECT_EQ(0, audio_device_->InitSpeaker());
}
// repeat test for all devices // repeat test for all devices
int16_t no_devices = audio_device_->PlayoutDevices(); int16_t no_devices = audio_device_->PlayoutDevices();
for (int i = 0; i < no_devices; i++) { for (int i = 0; i < no_devices; i++) {
EXPECT_EQ(0, audio_device_->SetPlayoutDevice(i)); EXPECT_EQ(0, audio_device_->SetPlayoutDevice(i));
EXPECT_EQ(0, audio_device_->SpeakerIsAvailable(&available)); EXPECT_EQ(0, audio_device_->InitSpeaker());
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());
} }
} }
@ -893,13 +831,10 @@ TEST_F(AudioDeviceAPITest, InitMicrophone) {
// kDefaultCommunicationDevice // kDefaultCommunicationDevice
EXPECT_EQ(0, EXPECT_EQ(0,
audio_device_->SetRecordingDevice(MACRO_DEFAULT_COMMUNICATION_DEVICE)); audio_device_->SetRecordingDevice(MACRO_DEFAULT_COMMUNICATION_DEVICE));
bool available; EXPECT_EQ(0, audio_device_->InitMicrophone());
EXPECT_EQ(0, audio_device_->MicrophoneIsAvailable(&available));
if (available) {
EXPECT_EQ(0, audio_device_->InitMicrophone());
}
// fail tests // fail tests
bool available;
EXPECT_EQ(0, audio_device_->RecordingIsAvailable(&available)); EXPECT_EQ(0, audio_device_->RecordingIsAvailable(&available));
if (available) { if (available) {
EXPECT_EQ(0, audio_device_->InitRecording()); EXPECT_EQ(0, audio_device_->InitRecording());
@ -910,19 +845,13 @@ TEST_F(AudioDeviceAPITest, InitMicrophone) {
// kDefaultDevice // kDefaultDevice
EXPECT_EQ(0, audio_device_->SetRecordingDevice(MACRO_DEFAULT_DEVICE)); EXPECT_EQ(0, audio_device_->SetRecordingDevice(MACRO_DEFAULT_DEVICE));
EXPECT_EQ(0, audio_device_->MicrophoneIsAvailable(&available)); EXPECT_EQ(0, audio_device_->InitMicrophone());
if (available) {
EXPECT_EQ(0, audio_device_->InitMicrophone());
}
// repeat test for all devices // repeat test for all devices
int16_t no_devices = audio_device_->RecordingDevices(); int16_t no_devices = audio_device_->RecordingDevices();
for (int i = 0; i < no_devices; i++) { for (int i = 0; i < no_devices; i++) {
EXPECT_EQ(0, audio_device_->SetRecordingDevice(i)); EXPECT_EQ(0, audio_device_->SetRecordingDevice(i));
EXPECT_EQ(0, audio_device_->MicrophoneIsAvailable(&available)); EXPECT_EQ(0, audio_device_->InitMicrophone());
if (available) {
EXPECT_EQ(0, audio_device_->InitMicrophone());
}
} }
} }

View File

@ -1013,8 +1013,6 @@ int32_t FuncTestManager::TestDeviceSelection()
{ {
PRINT_STR(Stereo Playout, false); PRINT_STR(Stereo Playout, false);
} }
EXPECT_EQ(0, audioDevice->SpeakerIsAvailable(&available));
PRINT_STR(Speaker, available);
EXPECT_EQ(0, audioDevice->SpeakerVolumeIsAvailable(&available)); EXPECT_EQ(0, audioDevice->SpeakerVolumeIsAvailable(&available));
PRINT_STR(Speaker Volume, available); PRINT_STR(Speaker Volume, available);
EXPECT_EQ(0, audioDevice->SpeakerMuteIsAvailable(&available)); EXPECT_EQ(0, audioDevice->SpeakerMuteIsAvailable(&available));
@ -1033,8 +1031,6 @@ int32_t FuncTestManager::TestDeviceSelection()
{ {
PRINT_STR(Stereo Playout, false); PRINT_STR(Stereo Playout, false);
} }
EXPECT_EQ(0, audioDevice->SpeakerIsAvailable(&available));
PRINT_STR(Speaker, available);
EXPECT_EQ(0, audioDevice->SpeakerVolumeIsAvailable(&available)); EXPECT_EQ(0, audioDevice->SpeakerVolumeIsAvailable(&available));
PRINT_STR(Speaker Volume, available); PRINT_STR(Speaker Volume, available);
EXPECT_EQ(0, audioDevice->SpeakerMuteIsAvailable(&available)); EXPECT_EQ(0, audioDevice->SpeakerMuteIsAvailable(&available));
@ -1060,8 +1056,6 @@ int32_t FuncTestManager::TestDeviceSelection()
{ {
PRINT_STR(Stereo Playout, false); PRINT_STR(Stereo Playout, false);
} }
EXPECT_EQ(0, audioDevice->SpeakerIsAvailable(&available));
PRINT_STR(Speaker, available);
EXPECT_EQ(0, audioDevice->SpeakerVolumeIsAvailable(&available)); EXPECT_EQ(0, audioDevice->SpeakerVolumeIsAvailable(&available));
PRINT_STR(Speaker Volume, available); PRINT_STR(Speaker Volume, available);
EXPECT_EQ(0, audioDevice->SpeakerMuteIsAvailable(&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 // special fix to ensure that we don't log 'available' when recording is not OK
PRINT_STR(Stereo Recording, false); PRINT_STR(Stereo Recording, false);
} }
EXPECT_EQ(0, audioDevice->MicrophoneIsAvailable(&available));
PRINT_STR(Microphone, available);
EXPECT_EQ(0, audioDevice->MicrophoneVolumeIsAvailable(&available)); EXPECT_EQ(0, audioDevice->MicrophoneVolumeIsAvailable(&available));
PRINT_STR(Microphone Volume, available); PRINT_STR(Microphone Volume, available);
EXPECT_EQ(0, audioDevice->MicrophoneMuteIsAvailable(&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 // special fix to ensure that we don't log 'available' when recording is not OK
PRINT_STR(Stereo Recording, false); PRINT_STR(Stereo Recording, false);
} }
EXPECT_EQ(0, audioDevice->MicrophoneIsAvailable(&available));
PRINT_STR(Microphone, available);
EXPECT_EQ(0, audioDevice->MicrophoneVolumeIsAvailable(&available)); EXPECT_EQ(0, audioDevice->MicrophoneVolumeIsAvailable(&available));
PRINT_STR(Microphone Volume, available); PRINT_STR(Microphone Volume, available);
EXPECT_EQ(0, audioDevice->MicrophoneMuteIsAvailable(&available)); EXPECT_EQ(0, audioDevice->MicrophoneMuteIsAvailable(&available));
@ -1145,8 +1135,6 @@ int32_t FuncTestManager::TestDeviceSelection()
// is not OK // is not OK
PRINT_STR(Stereo Recording, false); PRINT_STR(Stereo Recording, false);
} }
EXPECT_EQ(0, audioDevice->MicrophoneIsAvailable(&available));
PRINT_STR(Microphone, available);
EXPECT_EQ(0, audioDevice->MicrophoneVolumeIsAvailable(&available)); EXPECT_EQ(0, audioDevice->MicrophoneVolumeIsAvailable(&available));
PRINT_STR(Microphone Volume, available); PRINT_STR(Microphone Volume, available);
EXPECT_EQ(0, audioDevice->MicrophoneMuteIsAvailable(&available)); EXPECT_EQ(0, audioDevice->MicrophoneMuteIsAvailable(&available));

View File

@ -750,25 +750,6 @@ bool AudioDeviceWindowsCore::Initialized() const
return (_initialized); return (_initialized);
} }
// ----------------------------------------------------------------------------
// SpeakerIsAvailable
// ----------------------------------------------------------------------------
int32_t AudioDeviceWindowsCore::SpeakerIsAvailable(bool& available)
{
CriticalSectionScoped lock(&_critSect);
if (_ptrDeviceOut == NULL)
{
return -1;
}
available = true;
return 0;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// InitSpeaker // InitSpeaker
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -851,25 +832,6 @@ int32_t AudioDeviceWindowsCore::InitSpeaker()
return 0; return 0;
} }
// ----------------------------------------------------------------------------
// MicrophoneIsAvailable
// ----------------------------------------------------------------------------
int32_t AudioDeviceWindowsCore::MicrophoneIsAvailable(bool& available)
{
CriticalSectionScoped lock(&_critSect);
if (_ptrDeviceIn == NULL)
{
return -1;
}
available = true;
return 0;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// InitMicrophone // InitMicrophone
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -138,10 +138,8 @@ public:
virtual int32_t WaveOutVolume(uint16_t& volumeLeft, uint16_t& volumeRight) const; virtual int32_t WaveOutVolume(uint16_t& volumeLeft, uint16_t& volumeRight) const;
// Audio mixer initialization // Audio mixer initialization
virtual int32_t SpeakerIsAvailable(bool& available);
virtual int32_t InitSpeaker(); virtual int32_t InitSpeaker();
virtual bool SpeakerIsInitialized() const; virtual bool SpeakerIsInitialized() const;
virtual int32_t MicrophoneIsAvailable(bool& available);
virtual int32_t InitMicrophone(); virtual int32_t InitMicrophone();
virtual bool MicrophoneIsInitialized() const; virtual bool MicrophoneIsInitialized() const;

View File

@ -489,33 +489,6 @@ bool AudioDeviceWindowsWave::Initialized() const
return (_initialized); 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 // InitSpeaker
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -554,33 +527,6 @@ int32_t AudioDeviceWindowsWave::InitSpeaker()
return 0; 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 // InitMicrophone
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -94,10 +94,8 @@ public:
virtual int32_t WaveOutVolume(uint16_t& volumeLeft, uint16_t& volumeRight) const; virtual int32_t WaveOutVolume(uint16_t& volumeLeft, uint16_t& volumeRight) const;
// Audio mixer initialization // Audio mixer initialization
virtual int32_t SpeakerIsAvailable(bool& available);
virtual int32_t InitSpeaker(); virtual int32_t InitSpeaker();
virtual bool SpeakerIsInitialized() const; virtual bool SpeakerIsInitialized() const;
virtual int32_t MicrophoneIsAvailable(bool& available);
virtual int32_t InitMicrophone(); virtual int32_t InitMicrophone();
virtual bool MicrophoneIsInitialized() const; virtual bool MicrophoneIsInitialized() const;

View File

@ -391,18 +391,6 @@ int VoEBaseImpl::Init(AudioDeviceModule* external_adm,
_shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceInfo, _shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceInfo,
"Init() failed to set the default output device"); "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) if (_shared->audio_device()->InitSpeaker() != 0)
{ {
_shared->SetLastError(VE_CANNOT_ACCESS_SPEAKER_VOL, kTraceInfo, _shared->SetLastError(VE_CANNOT_ACCESS_SPEAKER_VOL, kTraceInfo,
@ -416,18 +404,6 @@ int VoEBaseImpl::Init(AudioDeviceModule* external_adm,
_shared->SetLastError(VE_SOUNDCARD_ERROR, kTraceInfo, _shared->SetLastError(VE_SOUNDCARD_ERROR, kTraceInfo,
"Init() failed to set the default input device"); "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) if (_shared->audio_device()->InitMicrophone() != 0)
{ {
_shared->SetLastError(VE_CANNOT_ACCESS_MIC_VOL, kTraceInfo, _shared->SetLastError(VE_CANNOT_ACCESS_MIC_VOL, kTraceInfo,