Changeset 216455 in webkit
- Timestamp:
- May 8, 2017 3:12:39 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r216452 r216455 1 2017-05-08 Youenn Fablet <youenn@apple.com> 2 3 CoreAudioSharedUnit should own its configuration parameters 4 https://bugs.webkit.org/show_bug.cgi?id=171812 5 6 Reviewed by Eric Carlson. 7 8 Covered by manual tests. 9 10 Add sampleRate, volume and echoCancellation parameters to the shared audio unit. 11 Set default values when creating the shared audio unit and use those for the creation of new sources. 12 Add support for volume. 13 Add support for disabling echo cancellation. 14 Check valid sample rates when trying to apply a sample rate. 15 16 * platform/mediastream/RealtimeMediaSource.h: 17 * platform/mediastream/mac/CoreAudioCaptureSource.cpp: 18 (WebCore::CoreAudioSharedUnit::volume): 19 (WebCore::CoreAudioSharedUnit::sampleRate): 20 (WebCore::CoreAudioSharedUnit::enableEchoCancellation): 21 (WebCore::CoreAudioSharedUnit::setVolume): 22 (WebCore::CoreAudioSharedUnit::setSampleRate): 23 (WebCore::CoreAudioSharedUnit::setEnableEchoCancellation): 24 (WebCore::CoreAudioSharedUnit::CoreAudioSharedUnit): 25 (WebCore::CoreAudioSharedUnit::setupAudioUnits): 26 (WebCore::CoreAudioSharedUnit::configureMicrophoneProc): 27 (WebCore::CoreAudioSharedUnit::configureSpeakerProc): 28 (WebCore::CoreAudioSharedUnit::processMicrophoneSamples): 29 (WebCore::CoreAudioCaptureSource::CoreAudioCaptureSource): 30 (WebCore::CoreAudioCaptureSource::applySampleRate): 31 (WebCore::CoreAudioCaptureSource::applyEchoCancellation): 32 * platform/mediastream/mac/CoreAudioCaptureSource.h: 33 1 34 2017-05-08 Joanmarie Diggs <jdiggs@igalia.com> 2 35 -
trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h
r215955 r216455 216 216 void notifyMutedObservers() const; 217 217 218 void initializeVolume(double volume) { m_volume = volume; } 219 void initializeSampleRate(int sampleRate) { m_sampleRate = sampleRate; } 220 void initializeEchoCancellation(bool echoCancellation) { m_echoCancellation = echoCancellation; } 221 218 222 bool m_muted { false }; 219 223 bool m_enabled { true }; -
trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp
r216432 r216455 81 81 public: 82 82 static CoreAudioSharedUnit& singleton(); 83 CoreAudioSharedUnit(); 83 84 84 85 void addClient(CoreAudioCaptureSource&); … … 100 101 101 102 const CAAudioStreamDescription& microphoneFormat() const { return m_microphoneProcFormat; } 103 104 double volume() const { return m_volume; } 105 int sampleRate() const { return m_sampleRate; } 106 bool enableEchoCancellation() const { return m_enableEchoCancellation; } 107 108 void setVolume(double volume) { m_volume = volume; } 109 void setSampleRate(int sampleRate) { m_sampleRate = sampleRate; } 110 void setEnableEchoCancellation(bool enableEchoCancellation) { m_enableEchoCancellation = enableEchoCancellation; } 102 111 103 112 private: … … 154 163 uint64_t m_microphoneProcsCalled { 0 }; 155 164 #endif 165 166 bool m_enableEchoCancellation { true }; 167 double m_volume { 1 }; 168 int m_sampleRate; 156 169 }; 157 170 … … 160 173 static NeverDestroyed<CoreAudioSharedUnit> singleton; 161 174 return singleton; 175 } 176 177 CoreAudioSharedUnit::CoreAudioSharedUnit() 178 { 179 m_sampleRate = AudioSession::sharedSession().sampleRate(); 162 180 } 163 181 … … 229 247 } 230 248 231 uint32_t param = m_clients.first()->echoCancellation(); 232 err = AudioUnitSetProperty(m_ioUnit, kAUVoiceIOProperty_VoiceProcessingEnableAGC, kAudioUnitScope_Global, inputBus, ¶m, sizeof(param)); 233 if (err) { 234 LOG(Media, "CoreAudioCaptureSource::setupAudioUnits(%p) unable to set vpio unit echo cancellation, error %d (%.4s)", this, (int)err, (char*)&err); 235 return err; 249 if (!m_enableEchoCancellation) { 250 uint32_t param = 0; 251 err = AudioUnitSetProperty(m_ioUnit, kAUVoiceIOProperty_VoiceProcessingEnableAGC, kAudioUnitScope_Global, inputBus, ¶m, sizeof(param)); 252 if (err) { 253 LOG(Media, "CoreAudioCaptureSource::setupAudioUnits(%p) unable to set vpio automatic gain control, error %d (%.4s)", this, (int)err, (char*)&err); 254 return err; 255 } 256 param = 1; 257 err = AudioUnitSetProperty(m_ioUnit, kAUVoiceIOProperty_BypassVoiceProcessing, kAudioUnitScope_Global, inputBus, ¶m, sizeof(param)); 258 if (err) { 259 LOG(Media, "CoreAudioCaptureSource::setupAudioUnits(%p) unable to set vpio unit echo cancellation, error %d (%.4s)", this, (int)err, (char*)&err); 260 return err; 261 } 236 262 } 237 263 238 264 #if PLATFORM(IOS) 239 param = 1;265 uint32_t param = 1; 240 266 err = AudioUnitSetProperty(m_ioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, inputBus, ¶m, sizeof(param)); 241 267 if (err) { … … 293 319 } 294 320 295 microphoneProcFormat.mSampleRate = m_ clients.first()->sampleRate();321 microphoneProcFormat.mSampleRate = m_sampleRate; 296 322 err = AudioUnitSetProperty(m_ioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, inputBus, µphoneProcFormat, size); 297 323 if (err) { … … 324 350 } 325 351 326 speakerProcFormat.mSampleRate = m_ clients.first()->sampleRate();352 speakerProcFormat.mSampleRate = m_sampleRate; 327 353 err = AudioUnitSetProperty(m_ioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, outputBus, &speakerProcFormat, size); 328 354 if (err) { … … 430 456 m_microphoneSampleBuffer->setTimes(adjustedHostTime, sampleTime); 431 457 458 if (m_volume != 1.0) 459 m_microphoneSampleBuffer->applyGain(m_volume); 460 432 461 for (auto* client : m_clients) { 433 462 if (client->isProducingData()) … … 599 628 m_muted = true; 600 629 601 setVolume(1.0); 602 setSampleRate(AudioSession::sharedSession().sampleRate()); 603 setEchoCancellation(true); 604 605 CoreAudioSharedUnit::singleton().addClient(*this); 630 auto& unit = CoreAudioSharedUnit::singleton(); 631 632 initializeEchoCancellation(unit.enableEchoCancellation()); 633 initializeSampleRate(unit.sampleRate()); 634 initializeVolume(unit.volume()); 635 636 unit.addClient(*this); 606 637 } 607 638 … … 705 736 } 706 737 738 bool CoreAudioCaptureSource::applySampleRate(int sampleRate) 739 { 740 // FIXME: We should be able to describe sample rate as a discreet range constraint so that we only enter here with values that can be applied. 741 switch (sampleRate) { 742 case 8000: 743 case 16000: 744 case 32000: 745 case 44100: 746 case 48000: 747 case 96000: 748 break; 749 default: 750 return false; 751 } 752 753 CoreAudioSharedUnit::singleton().setSampleRate(sampleRate); 754 755 // FIXME: do reconfiguration if audio unit is started. 756 return true; 757 } 758 759 bool CoreAudioCaptureSource::applyEchoCancellation(bool enableEchoCancellation) 760 { 761 CoreAudioSharedUnit::singleton().setEnableEchoCancellation(enableEchoCancellation); 762 763 // FIXME: do reconfiguration if audio unit is started. 764 return true; 765 } 766 707 767 } // namespace WebCore 708 768 -
trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h
r216349 r216455 52 52 class WebAudioSourceProviderAVFObjC; 53 53 54 class CoreAudioCaptureSource : public RealtimeMediaSource {54 class CoreAudioCaptureSource final : public RealtimeMediaSource { 55 55 public: 56 56 … … 81 81 bool isProducingData() const final { return m_isProducingData; } 82 82 83 bool applyVolume(double) override{ return true; }84 bool applySampleRate(int) override { return true; }85 bool applyEchoCancellation(bool) override { return true; }83 bool applyVolume(double) final { return true; } 84 bool applySampleRate(int) final; 85 bool applyEchoCancellation(bool) final; 86 86 87 87 const RealtimeMediaSourceCapabilities& capabilities() const final;
Note: See TracChangeset
for help on using the changeset viewer.