Bug 1247574: Force webrtc audio input processing to resample to target rate to fix 16KHz mics. r=padenot, a=lizzard
authorRandell Jesup <rjesup@jesup.org>
Sat, 19 Mar 2016 16:05:13 -0400
changeset 325514 df61f320dfb1525ecb8de217a4ca11bde7122522
parent 325513 62de4de10ebbbca861118a12b90b9df867032a23
child 325515 ab8c8b724584654a4d333bd1920e38d6a63c76a4
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot, lizzard
bugs1247574
milestone47.0a2
Bug 1247574: Force webrtc audio input processing to resample to target rate to fix 16KHz mics. r=padenot, a=lizzard MozReview-Commit-ID: BBZcX03Z6Kn
media/webrtc/trunk/webrtc/modules/audio_device/win/audio_device_core_win.cc
media/webrtc/trunk/webrtc/voice_engine/utility.cc
--- a/media/webrtc/trunk/webrtc/modules/audio_device/win/audio_device_core_win.cc
+++ b/media/webrtc/trunk/webrtc/modules/audio_device/win/audio_device_core_win.cc
@@ -2231,17 +2231,17 @@ int32_t AudioDeviceWindowsCore::InitPlay
         WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "cbSize         : %d", pWfxOut->cbSize);
     }
 
     // Set wave format
     Wfx.wFormatTag = WAVE_FORMAT_PCM;
     Wfx.wBitsPerSample = 16;
     Wfx.cbSize = 0;
 
-    const int freqs[] = {48000, 44100, 16000, 96000, 32000, 8000};
+    const int freqs[] = {48000, 44100, 32000, 96000, 16000, 8000};
     hr = S_FALSE;
 
     // Iterate over frequencies and channels, in order of priority
     for (int freq = 0; freq < sizeof(freqs)/sizeof(freqs[0]); freq++)
     {
         for (int chan = 0; chan < sizeof(_playChannelsPrioList)/sizeof(_playChannelsPrioList[0]); chan++)
         {
             Wfx.nChannels = _playChannelsPrioList[chan];
@@ -2568,17 +2568,17 @@ int32_t AudioDeviceWindowsCore::InitReco
         WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "cbSize         : %d", pWfxIn->cbSize);
     }
 
     // Set wave format
     Wfx.wFormatTag = WAVE_FORMAT_PCM;
     Wfx.wBitsPerSample = 16;
     Wfx.cbSize = 0;
 
-    const int freqs[6] = {48000, 44100, 16000, 96000, 32000, 8000};
+    const int freqs[6] = {48000, 44100, 32000, 96000, 16000, 8000};
     hr = S_FALSE;
 
     // Iterate over frequencies and channels, in order of priority
     for (int freq = 0; freq < sizeof(freqs)/sizeof(freqs[0]); freq++)
     {
         for (int chan = 0; chan < sizeof(_recChannelsPrioList)/sizeof(_recChannelsPrioList[0]); chan++)
         {
             Wfx.nChannels = _recChannelsPrioList[chan];
--- a/media/webrtc/trunk/webrtc/voice_engine/utility.cc
+++ b/media/webrtc/trunk/webrtc/voice_engine/utility.cc
@@ -81,17 +81,21 @@ void DownConvertToCodecFormat(const int1
                               AudioFrame* dst_af) {
   assert(samples_per_channel <= kMaxMonoDataSizeSamples);
   assert(num_channels == 1 || num_channels == 2);
   assert(codec_num_channels == 1 || codec_num_channels == 2);
   dst_af->Reset();
 
   // Never upsample the capture signal here. This should be done at the
   // end of the send chain.
-  int destination_rate = std::min(codec_rate_hz, sample_rate_hz);
+  // XXX bug 1247574 temporary hack until we switch to full-duplex
+  // We need to know the final audio rate before starting the audio channels,
+  // and this means we can get called back in Process() with the input
+  // rate if it's less than the codec rate.
+  int destination_rate = codec_rate_hz;
 
   // If no stereo codecs are in use, we downmix a stereo stream from the
   // device early in the chain, before resampling.
   if (num_channels == 2 && codec_num_channels == 1) {
     AudioFrameOperations::StereoToMono(src_data, samples_per_channel,
                                        mono_buffer);
     src_data = mono_buffer;
     num_channels = 1;