Remove 44.1 kHz workaround from AudioDevice on WASAPI.
We currently inform VoE that 44.1 kHz audio is 44 kHz. We now have arbitrary resampling in VoE, allowing us to pass in the native 44.1 kHz. BUG=webrtc:1395 TESTED=Set capture device to 44.1 and render device to 48 and vice versa and observed good AEC. The quality is considerably worse before this change. Using 44.1 for capture and render in loopback, ran through all codec channel/rate combinations. Quality is good. R=xians@webrtc.org Review URL: https://webrtc-codereview.appspot.com/1383004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3954 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
bd4a2feddb
commit
7cb766b016
@ -430,8 +430,6 @@ AudioDeviceWindowsCore::AudioDeviceWindowsCore(const int32_t id) :
|
||||
_playChannels(2),
|
||||
_sndCardPlayDelay(0),
|
||||
_sndCardRecDelay(0),
|
||||
_sampleDriftAt48kHz(0),
|
||||
_driftAccumulator(0),
|
||||
_writtenSamples(0),
|
||||
_readSamples(0),
|
||||
_playAcc(0),
|
||||
@ -2319,11 +2317,6 @@ int32_t AudioDeviceWindowsCore::InitPlayout()
|
||||
_playSampleRate = Wfx.nSamplesPerSec;
|
||||
_devicePlaySampleRate = Wfx.nSamplesPerSec; // The device itself continues to run at 44.1 kHz.
|
||||
_devicePlayBlockSize = Wfx.nSamplesPerSec/100;
|
||||
if (_playBlockSize == 441)
|
||||
{
|
||||
_playSampleRate = 44000; // we are actually running at 44000 Hz and *not* 44100 Hz
|
||||
_playBlockSize = 440; // adjust to size we can handle
|
||||
}
|
||||
_playChannels = Wfx.nChannels;
|
||||
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "VoE selected this rendering format:");
|
||||
@ -2340,8 +2333,6 @@ int32_t AudioDeviceWindowsCore::InitPlayout()
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "_playChannels : %d", _playChannels);
|
||||
}
|
||||
|
||||
_Get44kHzDrift();
|
||||
|
||||
// Create a rendering stream.
|
||||
//
|
||||
// ****************************************************************************
|
||||
@ -2659,11 +2650,6 @@ int32_t AudioDeviceWindowsCore::InitRecording()
|
||||
_recSampleRate = Wfx.nSamplesPerSec;
|
||||
_recBlockSize = Wfx.nSamplesPerSec/100;
|
||||
_recChannels = Wfx.nChannels;
|
||||
if (_recBlockSize == 441)
|
||||
{
|
||||
_recSampleRate = 44000; // we are actually using 44000 Hz and *not* 44100 Hz
|
||||
_recBlockSize = 440; // adjust to size we can handle
|
||||
}
|
||||
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "VoE selected this capturing format:");
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "wFormatTag : 0x%X (%u)", Wfx.wFormatTag, Wfx.wFormatTag);
|
||||
@ -2679,8 +2665,6 @@ int32_t AudioDeviceWindowsCore::InitRecording()
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "_recChannels : %d", _recChannels);
|
||||
}
|
||||
|
||||
_Get44kHzDrift();
|
||||
|
||||
// Create a capturing stream.
|
||||
hr = _ptrClientIn->Initialize(
|
||||
AUDCLNT_SHAREMODE_SHARED, // share Audio Engine with other applications
|
||||
@ -4104,15 +4088,9 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread()
|
||||
if (_ptrAudioBuffer)
|
||||
{
|
||||
_ptrAudioBuffer->SetRecordedBuffer((const int8_t*)syncBuffer, _recBlockSize);
|
||||
|
||||
_driftAccumulator += _sampleDriftAt48kHz;
|
||||
const int32_t clockDrift =
|
||||
static_cast<int32_t>(_driftAccumulator);
|
||||
_driftAccumulator -= clockDrift;
|
||||
|
||||
_ptrAudioBuffer->SetVQEData(sndCardPlayDelay,
|
||||
sndCardRecDelay,
|
||||
clockDrift);
|
||||
0);
|
||||
|
||||
QueryPerformanceCounter(&t1); // measure time: START
|
||||
|
||||
@ -5145,29 +5123,6 @@ void AudioDeviceWindowsCore::_SetThreadName(DWORD dwThreadID, LPCSTR szThreadNam
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// _Get44kHzDrift
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void AudioDeviceWindowsCore::_Get44kHzDrift()
|
||||
{
|
||||
// We aren't able to resample at 44.1 kHz. Instead we run at 44 kHz and push/pull
|
||||
// from the engine faster to compensate. If only one direction is set to 44.1 kHz
|
||||
// the result is indistinguishable from clock drift to the AEC. We can compensate
|
||||
// internally if we inform the AEC about the drift.
|
||||
_sampleDriftAt48kHz = 0;
|
||||
_driftAccumulator = 0;
|
||||
|
||||
if (_playSampleRate == 44000 && _recSampleRate != 44000)
|
||||
{
|
||||
_sampleDriftAt48kHz = 480.0f/440;
|
||||
}
|
||||
else if(_playSampleRate != 44000 && _recSampleRate == 44000)
|
||||
{
|
||||
_sampleDriftAt48kHz = -480.0f/441;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// WideToUTF8
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -67,7 +67,7 @@ class ScopedCOMInitializer {
|
||||
}
|
||||
|
||||
bool succeeded() const { return SUCCEEDED(hr_); }
|
||||
|
||||
|
||||
private:
|
||||
void Initialize(COINIT init) {
|
||||
hr_ = CoInitializeEx(NULL, init);
|
||||
@ -268,8 +268,6 @@ private:
|
||||
int32_t _GetDefaultDevice(EDataFlow dir, ERole role, IMMDevice** ppDevice);
|
||||
int32_t _GetListDevice(EDataFlow dir, int index, IMMDevice** ppDevice);
|
||||
|
||||
void _Get44kHzDrift();
|
||||
|
||||
// Converts from wide-char to UTF-8 if UNICODE is defined.
|
||||
// Does nothing if UNICODE is undefined.
|
||||
char* WideToUTF8(const TCHAR* src) const;
|
||||
@ -336,9 +334,6 @@ private: // WASAPI
|
||||
UINT64 _readSamples;
|
||||
uint32_t _sndCardRecDelay;
|
||||
|
||||
float _sampleDriftAt48kHz;
|
||||
float _driftAccumulator;
|
||||
|
||||
uint16_t _recChannelsPrioList[2];
|
||||
uint16_t _playChannelsPrioList[2];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user