Changeset 215546 in webkit
- Timestamp:
- Apr 19, 2017 5:53:37 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r215541 r215546 1 2017-04-19 Eric Carlson <eric.carlson@apple.com> 2 3 Another deadlock in CoreAudioCaptureSource 4 https://bugs.webkit.org/show_bug.cgi?id=171001 5 6 Fix another regression introduced by r215201, plus make changes suggested 7 in the review of 170771. 8 9 Reviewed by Youenn Fablet. 10 11 * platform/mediastream/mac/CoreAudioCaptureSource.cpp: 12 (WebCore::CoreAudioCaptureSource::configureSpeakerProc): Assert if the lock is no held. 13 (WebCore::CoreAudioCaptureSource::provideSpeakerData): Don't reset the buffer. 14 (WebCore::CoreAudioCaptureSource::processMicrophoneSamples): Take the state lock. Don't 15 reset the buffer. No more microphone callbacks. 16 (WebCore::CoreAudioCaptureSource::stopProducingData): Return early if the io unit isn't 17 running. Drop the lock before calling setMuted to avoid another deadlock. 18 (WebCore::CoreAudioCaptureSource::addMicrophoneDataConsumer): Deleted. 19 (WebCore::CoreAudioCaptureSource::removeMicrophoneDataConsumer): Deleted. 20 * platform/mediastream/mac/CoreAudioCaptureSource.h: 21 1 22 2017-04-19 Anders Carlsson <andersca@apple.com> 2 23 -
trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp
r215485 r215546 171 171 OSStatus CoreAudioCaptureSource::configureSpeakerProc() 172 172 { 173 ASSERT(m_internalStateLock.isHeld()); 174 173 175 AURenderCallbackStruct callback = { speakerCallback, this }; 174 176 auto err = AudioUnitSetProperty(m_ioUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Global, outputBus, &callback, sizeof(callback)); … … 192 194 return err; 193 195 } 194 195 uint64_t CoreAudioCaptureSource::addMicrophoneDataConsumer(MicrophoneDataCallback&& callback)196 {197 std::lock_guard<Lock> lock(m_pendingSourceQueueLock);198 m_microphoneDataCallbacks.add(++m_nextMicrophoneDataCallbackID, callback);199 200 return m_nextMicrophoneDataCallbackID;201 }202 203 void CoreAudioCaptureSource::removeMicrophoneDataConsumer(uint64_t callbackID)204 {205 std::lock_guard<Lock> lock(m_pendingSourceQueueLock);206 m_microphoneDataCallbacks.remove(callbackID);207 }208 196 209 197 void CoreAudioCaptureSource::addEchoCancellationSource(AudioSampleDataSource& source) … … 265 253 uint64_t sampleTime = timeStamp.mSampleTime; 266 254 checkTimestamps(timeStamp, sampleTime, adjustedHostTime); 267 268 m_speakerSampleBuffer->reset();269 255 m_speakerSampleBuffer->setTimes(adjustedHostTime, sampleTime); 270 256 … … 292 278 OSStatus CoreAudioCaptureSource::processMicrophoneSamples(AudioUnitRenderActionFlags& ioActionFlags, const AudioTimeStamp& timeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList* /*ioData*/) 293 279 { 280 std::lock_guard<Lock> lock(m_internalStateLock); 281 294 282 ++m_microphoneProcsCalled; 295 283 296 284 // Pull through the vpio unit to our mic buffer. 297 m_microphoneSampleBuffer->reset();298 285 AudioBufferList& bufferList = m_microphoneSampleBuffer->bufferList(); 299 286 auto err = AudioUnitRender(m_ioUnit, &ioActionFlags, &timeStamp, inBusNumber, inNumberFrames, &bufferList); … … 307 294 checkTimestamps(timeStamp, sampleTime, adjustedHostTime); 308 295 m_latestMicTimeStamp = sampleTime; 309 310 296 m_microphoneSampleBuffer->setTimes(adjustedHostTime, sampleTime); 311 297 312 298 audioSamplesAvailable(MediaTime(sampleTime, m_microphoneProcFormat.sampleRate()), m_microphoneSampleBuffer->bufferList(), m_microphoneProcFormat, inNumberFrames); 313 314 if (m_microphoneDataCallbacks.isEmpty())315 return 0;316 317 for (auto& callback : m_microphoneDataCallbacks.values())318 callback(MediaTime(sampleTime, m_microphoneProcFormat.sampleRate()), m_microphoneSampleBuffer->bufferList(), m_microphoneProcFormat, inNumberFrames);319 299 320 300 return noErr; … … 468 448 void CoreAudioCaptureSource::stopProducingData() 469 449 { 470 std::lock_guard<Lock> lock(m_internalStateLock); 471 472 if (!m_ioUnit) 450 if (!m_ioUnit || !m_ioUnitStarted) 473 451 return; 474 452 475 auto err = AudioOutputUnitStop(m_ioUnit); 476 if (err) { 477 LOG(Media, "CoreAudioCaptureSource::stop(%p) AudioOutputUnitStop failed with error %d (%.4s)", this, (int)err, (char*)&err); 478 return; 479 } 480 m_ioUnitStarted = false; 453 { 454 std::lock_guard<Lock> lock(m_internalStateLock); 455 456 auto err = AudioOutputUnitStop(m_ioUnit); 457 if (err) { 458 LOG(Media, "CoreAudioCaptureSource::stop(%p) AudioOutputUnitStop failed with error %d (%.4s)", this, (int)err, (char*)&err); 459 return; 460 } 461 m_ioUnitStarted = false; 462 } 463 481 464 setMuted(true); 482 465 } -
trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h
r215485 r215546 116 116 uint64_t m_latestMicTimeStamp { 0 }; 117 117 118 HashMap<uint64_t, MicrophoneDataCallback> m_microphoneDataCallbacks;119 uint64_t m_nextMicrophoneDataCallbackID { 0 };120 121 118 CAAudioStreamDescription m_speakerProcFormat; 122 119 RefPtr<AudioSampleBufferList> m_speakerSampleBuffer;
Note: See TracChangeset
for help on using the changeset viewer.