Configure MockRealtimeAudioSourceMac to generate stereo audio
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Feb 2017 16:33:06 +0000 (16:33 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Feb 2017 16:33:06 +0000 (16:33 +0000)
commit7ff0f923124b115bb7b3ba37d67d0c64bdeb513a
tree8a7193b5692baea83961990f604f0611f22b90ea
parent4d781e6f490abaf184f1415c31c05ccec2d84d68
Configure MockRealtimeAudioSourceMac to generate stereo audio
https://bugs.webkit.org/show_bug.cgi?id=168027

Reviewed by Eric Carlson.

Update MockRealtimeAudioSourceMac to generate stereo audio.

First, because the pattern of creating a AudioBufferList structure (with all it's quirks and
weird requirements) was repeated multiple places, add a new wrapper around ABL called
WebAudioBufferList which takes care of correctly initializing the ABL structure and manages
the lifetime of its data members.

* WebCore.xcodeproj/project.pbxproj:
* platform/audio/PlatformAudioData.h: Added.
(WebCore::PlatformAudioData::kind):
* platform/audio/WebAudioBufferList.cpp: Added.
(WebCore::WebAudioBufferList::WebAudioBufferList):
(WebCore::WebAudioBufferList::buffers):
(WebCore::WebAudioBufferList::bufferCount):
(WebCore::WebAudioBufferList::buffer):
* platform/audio/WebAudioBufferList.h: Added.
(WebCore::WebAudioBufferList::list):
(WebCore::WebAudioBufferList::operator AudioBufferList&):
(WebCore::WebAudioBufferList::kind):
(isType):

Then update existing code to work in terms of WebAudioBufferList:

* platform/audio/mac/AudioSampleBufferList.cpp:
(WebCore::AudioSampleBufferList::AudioSampleBufferList):
(WebCore::AudioSampleBufferList::mixFrom):
(WebCore::AudioSampleBufferList::copyFrom):
(WebCore::AudioSampleBufferList::copyTo):
(WebCore::AudioSampleBufferList::reset):
(WebCore::AudioSampleBufferList::configureBufferListForStream): Deleted.
* platform/audio/mac/AudioSampleBufferList.h:
(WebCore::AudioSampleBufferList::bufferList):
* platform/audio/mac/AudioSampleDataSource.cpp:
(WebCore::AudioSampleDataSource::pushSamples):
* platform/audio/mac/AudioSampleDataSource.h:
* platform/mediastream/RealtimeMediaSource.cpp:
(WebCore::RealtimeMediaSource::audioSamplesAvailable):
* platform/mediastream/RealtimeMediaSource.h:
(WebCore::RealtimeMediaSource::Observer::audioSamplesAvailable):
* platform/mediastream/mac/AVAudioCaptureSource.h:
* platform/mediastream/mac/AVAudioCaptureSource.mm:
(WebCore::AVAudioCaptureSource::captureOutputDidOutputSampleBufferFromConnection):
* platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.cpp:
(WebCore::AudioTrackPrivateMediaStreamCocoa::audioSamplesAvailable):
* platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.h:
* platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp:
(WebCore::RealtimeOutgoingAudioSource::audioSamplesAvailable):
* platform/mediastream/mac/RealtimeOutgoingAudioSource.h:

Finally, actually update MockRealtimeAudioSource to emit stereo samples. Importantly, set
the correct values for the m_streamFormat; mBytesPerFrame and mBytesPerPacket are not
multiplied by the channelCount. When generating audio, write to both channels of data.

* platform/mediastream/mac/MockRealtimeAudioSourceMac.h:
* platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
(WebCore::MockRealtimeAudioSourceMac::emitSampleBuffers):
(WebCore::MockRealtimeAudioSourceMac::reconfigure):
(WebCore::MockRealtimeAudioSourceMac::render):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/audio/PlatformAudioData.h [new file with mode: 0644]
Source/WebCore/platform/audio/WebAudioBufferList.cpp [new file with mode: 0644]
Source/WebCore/platform/audio/WebAudioBufferList.h [new file with mode: 0644]
Source/WebCore/platform/audio/mac/AudioSampleBufferList.cpp
Source/WebCore/platform/audio/mac/AudioSampleBufferList.h
Source/WebCore/platform/audio/mac/AudioSampleDataSource.cpp
Source/WebCore/platform/audio/mac/AudioSampleDataSource.h
Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp
Source/WebCore/platform/mediastream/RealtimeMediaSource.h
Source/WebCore/platform/mediastream/mac/AVAudioCaptureSource.h
Source/WebCore/platform/mediastream/mac/AVAudioCaptureSource.mm
Source/WebCore/platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.cpp
Source/WebCore/platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.h
Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.h
Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm
Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp
Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.h