Title: [215626] trunk/Source/WebCore
- Revision
- 215626
- Author
- [email protected]
- Date
- 2017-04-21 12:59:07 -0700 (Fri, 21 Apr 2017)
Log Message
[MediaCapture][iOS] AVAudioSession must be active and the correct category before IO AudioUnits start producing data.
https://bugs.webkit.org/show_bug.cgi?id=171095
Reviewed by Youenn Fablet.
If an input audio unit is asked to start before the AVAudioSession is in a recording category and active,
CoreAudio will return an error stating that no input device is available.
The PlatformMediaSessionManager will automatically set the category of and activate the AVAudioSession when one
of its associated MediaStreams has a capturing RealtimeMediaSource and is currently producing data. To solve
the chicken-or-egg problem of activating the AVAudioSession before the source produces data, move the state bit
of "producing data" directly into MediaStreams, and notify the PlatformMediaSessionManager that capturing is
occurring after flipping that bit, but before asking the constituent tracks to begin producing data.
In places (i.e. UserMediaRequest) where we previously told a stream's tracks to begin producing data, instead
allow the stream to handle that by telling it to produce data directly.
* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::startProducingData):
(WebCore::MediaStream::stopProducingData):
(WebCore::MediaStream::mediaState):
(WebCore::MediaStream::mediaType):
(WebCore::MediaStream::characteristics):
(WebCore::MediaStream::canProduceAudio):
* Modules/mediastream/MediaStream.h:
* Modules/mediastream/UserMediaRequest.cpp:
(WebCore::UserMediaRequest::allow):
* platform/mediastream/mac/CoreAudioCaptureSource.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (215625 => 215626)
--- trunk/Source/WebCore/ChangeLog 2017-04-21 19:56:05 UTC (rev 215625)
+++ trunk/Source/WebCore/ChangeLog 2017-04-21 19:59:07 UTC (rev 215626)
@@ -1,5 +1,36 @@
2017-04-21 Jer Noble <[email protected]>
+ [MediaCapture][iOS] AVAudioSession must be active and the correct category before IO AudioUnits start producing data.
+ https://bugs.webkit.org/show_bug.cgi?id=171095
+
+ Reviewed by Youenn Fablet.
+
+ If an input audio unit is asked to start before the AVAudioSession is in a recording category and active,
+ CoreAudio will return an error stating that no input device is available.
+
+ The PlatformMediaSessionManager will automatically set the category of and activate the AVAudioSession when one
+ of its associated MediaStreams has a capturing RealtimeMediaSource and is currently producing data. To solve
+ the chicken-or-egg problem of activating the AVAudioSession before the source produces data, move the state bit
+ of "producing data" directly into MediaStreams, and notify the PlatformMediaSessionManager that capturing is
+ occurring after flipping that bit, but before asking the constituent tracks to begin producing data.
+
+ In places (i.e. UserMediaRequest) where we previously told a stream's tracks to begin producing data, instead
+ allow the stream to handle that by telling it to produce data directly.
+
+ * Modules/mediastream/MediaStream.cpp:
+ (WebCore::MediaStream::startProducingData):
+ (WebCore::MediaStream::stopProducingData):
+ (WebCore::MediaStream::mediaState):
+ (WebCore::MediaStream::mediaType):
+ (WebCore::MediaStream::characteristics):
+ (WebCore::MediaStream::canProduceAudio):
+ * Modules/mediastream/MediaStream.h:
+ * Modules/mediastream/UserMediaRequest.cpp:
+ (WebCore::UserMediaRequest::allow):
+ * platform/mediastream/mac/CoreAudioCaptureSource.h:
+
+2017-04-21 Jer Noble <[email protected]>
+
Add a method to retrieve the current I/O buffer size from AudioSession
https://bugs.webkit.org/show_bug.cgi?id=171126
Modified: trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp (215625 => 215626)
--- trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp 2017-04-21 19:56:05 UTC (rev 215625)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp 2017-04-21 19:59:07 UTC (rev 215626)
@@ -294,11 +294,23 @@
return;
}
+ if (m_isProducingData)
+ return;
+ m_isProducingData = true;
+
+ m_mediaSession->canProduceAudioChanged();
+
m_private->startProducingData();
}
void MediaStream::stopProducingData()
{
+ if (!m_isProducingData)
+ return;
+ m_isProducingData = false;
+
+ m_mediaSession->canProduceAudioChanged();
+
m_private->stopProducingData();
}
@@ -324,7 +336,7 @@
if (m_private->hasAudio()) {
state |= HasAudioOrVideo;
if (m_private->hasCaptureAudioSource()) {
- if (m_private->isProducingData())
+ if (m_isProducingData)
state |= HasActiveAudioCaptureDevice;
else if (m_private->muted())
state |= HasMutedAudioCaptureDevice;
@@ -334,7 +346,7 @@
if (m_private->hasVideo()) {
state |= HasAudioOrVideo;
if (m_private->hasCaptureVideoSource()) {
- if (m_private->isProducingData())
+ if (m_isProducingData)
state |= HasActiveVideoCaptureDevice;
else if (m_private->muted())
state |= HasMutedVideoCaptureDevice;
@@ -433,7 +445,7 @@
{
// We only need to override the type when capturing audio, HTMLMediaElement and/or WebAudio
// will do the right thing when a stream is attached to a media element or an audio context.
- if (m_private->hasAudio() && m_private->isProducingData() && m_private->hasCaptureAudioSource())
+ if (m_private->hasAudio() && m_isProducingData && m_private->hasCaptureAudioSource())
return PlatformMediaSession::MediaStreamCapturingAudio;
return PlatformMediaSession::None;
@@ -448,7 +460,7 @@
{
PlatformMediaSession::CharacteristicsFlags state = PlatformMediaSession::HasNothing;
- if (!m_private->isProducingData())
+ if (!m_isProducingData)
return state;
if (m_private->hasAudio())
@@ -483,7 +495,7 @@
bool MediaStream::canProduceAudio() const
{
- return !muted() && active() && m_private->hasAudio() && m_private->isProducingData();
+ return !muted() && active() && m_private->hasAudio() && m_isProducingData;
}
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/mediastream/MediaStream.h (215625 => 215626)
--- trunk/Source/WebCore/Modules/mediastream/MediaStream.h 2017-04-21 19:56:05 UTC (rev 215625)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStream.h 2017-04-21 19:59:07 UTC (rev 215626)
@@ -174,6 +174,7 @@
bool m_isActive { false };
bool m_isMuted { true };
+ bool m_isProducingData { false };
bool m_isWaitingUntilMediaCanStart { false };
};
Modified: trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp (215625 => 215626)
--- trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp 2017-04-21 19:56:05 UTC (rev 215625)
+++ trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp 2017-04-21 19:59:07 UTC (rev 215626)
@@ -174,11 +174,7 @@
return;
}
- for (auto& track : stream->getAudioTracks())
- track->source().startProducingData();
-
- for (auto& track : stream->getVideoTracks())
- track->source().startProducingData();
+ stream->startProducingData();
m_promise.resolve(stream);
};
Modified: trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h (215625 => 215626)
--- trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h 2017-04-21 19:56:05 UTC (rev 215625)
+++ trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h 2017-04-21 19:59:07 UTC (rev 215626)
@@ -71,6 +71,7 @@
CoreAudioCaptureSource(const String& deviceID);
virtual ~CoreAudioCaptureSource();
+ bool isCaptureSource() const final { return true; }
void startProducingData() final;
void stopProducingData() final;
bool isProducingData() const final { return m_ioUnitStarted; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes