Modified: branches/safari-612.1.5-branch/Source/WebCore/ChangeLog (273988 => 273989)
--- branches/safari-612.1.5-branch/Source/WebCore/ChangeLog 2021-03-05 19:51:15 UTC (rev 273988)
+++ branches/safari-612.1.5-branch/Source/WebCore/ChangeLog 2021-03-05 19:51:19 UTC (rev 273989)
@@ -1,3 +1,48 @@
+2021-03-05 Ruben Turcios <[email protected]>
+
+ Cherry-pick r273498. rdar://problem/75101801
+
+ [iOS] Crash when playing Dolby Atmos audio tracks with AVAudioTimePitchAlgorithmTimeDomain
+ https://bugs.webkit.org/show_bug.cgi?id=222420
+ <rdar://74612532>
+
+ Reviewed by Eric Carlson.
+
+ CoreAudio throws an assertion when using the TimeDomain pitch-correction algorithm on tracks
+ with > 2 channels. To work around this assertion for now, only set the pitch-correction
+ algorithm when the playbackRate is set to a non 0 or 1 value.
+
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::audioTimePitchAlgorithmForMediaPlayerPitchCorrectionAlgorithm):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::setPlayerRate):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::setPreservesPitch):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::setPitchCorrectionAlgorithm):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::playerItemStatusDidChange):
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273498 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-02-25 Jer Noble <[email protected]>
+
+ [iOS] Crash when playing Dolby Atmos audio tracks with AVAudioTimePitchAlgorithmTimeDomain
+ https://bugs.webkit.org/show_bug.cgi?id=222420
+ <rdar://74612532>
+
+ Reviewed by Eric Carlson.
+
+ CoreAudio throws an assertion when using the TimeDomain pitch-correction algorithm on tracks
+ with > 2 channels. To work around this assertion for now, only set the pitch-correction
+ algorithm when the playbackRate is set to a non 0 or 1 value.
+
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::audioTimePitchAlgorithmForMediaPlayerPitchCorrectionAlgorithm):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::setPlayerRate):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::setPreservesPitch):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::setPitchCorrectionAlgorithm):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::playerItemStatusDidChange):
+
2021-03-03 Alan Coon <[email protected]>
Cherry-pick r273839. rdar://problem/75009410
Modified: branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (273988 => 273989)
--- branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2021-03-05 19:51:15 UTC (rev 273988)
+++ branches/safari-612.1.5-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2021-03-05 19:51:19 UTC (rev 273989)
@@ -1034,9 +1034,9 @@
setDelayCallbacks(false);
}
-static NSString* audioTimePitchAlgorithmForMediaPlayerPitchCorrectionAlgorithm(MediaPlayer::PitchCorrectionAlgorithm pitchCorrectionAlgorithm, bool preservesPitch)
+static NSString* audioTimePitchAlgorithmForMediaPlayerPitchCorrectionAlgorithm(MediaPlayer::PitchCorrectionAlgorithm pitchCorrectionAlgorithm, bool preservesPitch, double rate)
{
- if (!preservesPitch)
+ if (!preservesPitch || !rate || rate == 1.)
return AVAudioTimePitchAlgorithmVarispeed;
switch (pitchCorrectionAlgorithm) {
@@ -1066,7 +1066,7 @@
for (NSString *keyName in itemKVOProperties())
[m_avPlayerItem.get() addObserver:m_objcObserver.get() forKeyPath:keyName options:options context:(void *)MediaPlayerAVFoundationObservationContextPlayerItem];
- [m_avPlayerItem setAudioTimePitchAlgorithm:audioTimePitchAlgorithmForMediaPlayerPitchCorrectionAlgorithm(player()->pitchCorrectionAlgorithm(), player()->preservesPitch())];
+ [m_avPlayerItem setAudioTimePitchAlgorithm:audioTimePitchAlgorithmForMediaPlayerPitchCorrectionAlgorithm(player()->pitchCorrectionAlgorithm(), player()->preservesPitch(), m_cachedRate)];
#if HAVE(AVFOUNDATION_INTERSTITIAL_EVENTS)
ALLOW_NEW_API_WITHOUT_GUARDS_BEGIN
@@ -1445,6 +1445,9 @@
{
setDelayCallbacks(true);
m_cachedRate = rate;
+
+ [m_avPlayerItem setAudioTimePitchAlgorithm:audioTimePitchAlgorithmForMediaPlayerPitchCorrectionAlgorithm(player()->pitchCorrectionAlgorithm(), player()->preservesPitch(), m_cachedRate)];
+
setShouldObserveTimeControlStatus(false);
[m_avPlayer setRate:rate];
m_cachedTimeControlStatus = [m_avPlayer timeControlStatus];
@@ -1481,13 +1484,13 @@
void MediaPlayerPrivateAVFoundationObjC::setPreservesPitch(bool preservesPitch)
{
if (m_avPlayerItem)
- [m_avPlayerItem setAudioTimePitchAlgorithm:audioTimePitchAlgorithmForMediaPlayerPitchCorrectionAlgorithm(player()->pitchCorrectionAlgorithm(), preservesPitch)];
+ [m_avPlayerItem setAudioTimePitchAlgorithm:audioTimePitchAlgorithmForMediaPlayerPitchCorrectionAlgorithm(player()->pitchCorrectionAlgorithm(), preservesPitch, m_cachedRate)];
}
void MediaPlayerPrivateAVFoundationObjC::setPitchCorrectionAlgorithm(MediaPlayer::PitchCorrectionAlgorithm pitchCorrectionAlgorithm)
{
if (m_avPlayerItem)
- [m_avPlayerItem setAudioTimePitchAlgorithm:audioTimePitchAlgorithmForMediaPlayerPitchCorrectionAlgorithm(pitchCorrectionAlgorithm, player()->preservesPitch())];
+ [m_avPlayerItem setAudioTimePitchAlgorithm:audioTimePitchAlgorithmForMediaPlayerPitchCorrectionAlgorithm(pitchCorrectionAlgorithm, player()->preservesPitch(), m_cachedRate)];
}
std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateAVFoundationObjC::platformBufferedTimeRanges() const
@@ -2971,7 +2974,7 @@
#if !(PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED > 101400)
// FIXME(rdar://72829354): Remove after AVFoundation radar is fixed.
if (status == AVPlayerItemStatusReadyToPlay)
- [m_avPlayerItem setAudioTimePitchAlgorithm:audioTimePitchAlgorithmForMediaPlayerPitchCorrectionAlgorithm(player()->pitchCorrectionAlgorithm(), player()->preservesPitch())];
+ [m_avPlayerItem setAudioTimePitchAlgorithm:audioTimePitchAlgorithmForMediaPlayerPitchCorrectionAlgorithm(player()->pitchCorrectionAlgorithm(), player()->preservesPitch(), m_cachedRate)];
#endif
updateStates();