Diff
Modified: trunk/Source/WebCore/ChangeLog (181005 => 181006)
--- trunk/Source/WebCore/ChangeLog 2015-03-04 19:22:59 UTC (rev 181005)
+++ trunk/Source/WebCore/ChangeLog 2015-03-04 19:26:22 UTC (rev 181006)
@@ -1,5 +1,33 @@
2015-03-04 Jer Noble <[email protected]>
+ [Mac] YouTube playback at 1.5x speed has audible distortion
+ https://bugs.webkit.org/show_bug.cgi?id=142280
+
+ Reviewed by Eric Carlson.
+
+ Use the high-quality AVAudioTimePitchAlgorithmSpectral algorithm for the
+ AVSampleBufferAudioRenderer rather than its default value of
+ AVAudioTimePitchAlgorithmTimeDomain.
+
+ Drive-by fix:
+
+ Might as well add support for MediaPlayer::setPreservesPitch() while we're
+ changing the audio pitch algorithm. If preservesPitch() is false use the
+ AVAudioTimePitchAlgorithmVarispeed algorithm in both AVFObjC-based media players
+ (MediaPlayerPrivateAVFoundationObjC & MediaPlayerPrivateMediaSourceAVFObjC).
+
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::setPreservesPitch):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::setRateDouble): Deleted.
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setPreservesPitch):
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::addAudioRenderer):
+
+2015-03-04 Jer Noble <[email protected]>
+
[MSE][EME][Mac] Calling close on a MediaKeysSession will cause many decoding errors to be emitted
https://bugs.webkit.org/show_bug.cgi?id=142285
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (181005 => 181006)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2015-03-04 19:22:59 UTC (rev 181005)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2015-03-04 19:26:22 UTC (rev 181006)
@@ -178,6 +178,7 @@
virtual void checkPlayability();
virtual void setRateDouble(double) override;
virtual double rate() const;
+ void setPreservesPitch(bool) override;
virtual void seekToTime(const MediaTime&, const MediaTime& negativeTolerance, const MediaTime& positiveTolerance);
virtual unsigned long long totalBytes() const;
virtual std::unique_ptr<PlatformTimeRanges> platformBufferedTimeRanges() const;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (181005 => 181006)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2015-03-04 19:22:59 UTC (rev 181005)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2015-03-04 19:26:22 UTC (rev 181006)
@@ -182,6 +182,8 @@
SOFT_LINK_CLASS(CoreImage, CIContext)
SOFT_LINK_CLASS(CoreImage, CIImage)
+SOFT_LINK_POINTER(AVFoundation, AVAudioTimePitchAlgorithmSpectral, NSString*)
+SOFT_LINK_POINTER(AVFoundation, AVAudioTimePitchAlgorithmVarispeed, NSString*)
SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicVisual, NSString *)
SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicAudible, NSString *)
SOFT_LINK_POINTER(AVFoundation, AVMediaTypeClosedCaption, NSString *)
@@ -206,6 +208,8 @@
#define AVAssetImageGenerator getAVAssetImageGeneratorClass()
#define AVMetadataItem getAVMetadataItemClass()
+#define AVAudioTimePitchAlgorithmSpectral getAVAudioTimePitchAlgorithmSpectral()
+#define AVAudioTimePitchAlgorithmVarispeed getAVAudioTimePitchAlgorithmVarispeed()
#define AVMediaCharacteristicVisual getAVMediaCharacteristicVisual()
#define AVMediaCharacteristicAudible getAVMediaCharacteristicAudible()
#define AVMediaTypeClosedCaption getAVMediaTypeClosedCaption()
@@ -962,6 +966,8 @@
for (NSString *keyName in itemKVOProperties())
[m_avPlayerItem.get() addObserver:m_objcObserver.get() forKeyPath:keyName options:options context:(void *)MediaPlayerAVFoundationObservationContextPlayerItem];
+ [m_avPlayerItem setAudioTimePitchAlgorithm:(player()->preservesPitch() ? AVAudioTimePitchAlgorithmSpectral : AVAudioTimePitchAlgorithmVarispeed)];
+
if (m_avPlayer)
setAVPlayerItem(m_avPlayerItem.get());
@@ -969,7 +975,7 @@
AtomicString value;
if (player()->doesHaveAttribute("data-youtube-id", &value))
[m_avPlayerItem.get() setDataYouTubeID: value];
- #endif
+#endif
#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
const NSTimeInterval legibleOutputAdvanceInterval = 2;
@@ -1320,7 +1326,6 @@
}
void MediaPlayerPrivateAVFoundationObjC::setRateDouble(double rate)
-
{
setDelayCallbacks(true);
m_cachedRate = rate;
@@ -1336,6 +1341,12 @@
return m_cachedRate;
}
+void MediaPlayerPrivateAVFoundationObjC::setPreservesPitch(bool preservesPitch)
+{
+ if (m_avPlayerItem)
+ [m_avPlayerItem setAudioTimePitchAlgorithm:(preservesPitch ? AVAudioTimePitchAlgorithmSpectral : AVAudioTimePitchAlgorithmVarispeed)];
+}
+
std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateAVFoundationObjC::platformBufferedTimeRanges() const
{
auto timeRanges = std::make_unique<PlatformTimeRanges>();
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (181005 => 181006)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2015-03-04 19:22:59 UTC (rev 181005)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2015-03-04 19:26:22 UTC (rev 181006)
@@ -131,6 +131,8 @@
virtual bool seeking() const override;
virtual void setRateDouble(double) override;
+ void setPreservesPitch(bool) override;
+
virtual std::unique_ptr<PlatformTimeRanges> seekable() const override;
virtual MediaTime maxMediaTimeSeekable() const override;
virtual MediaTime minMediaTimeSeekable() const override;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (181005 => 181006)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2015-03-04 19:22:59 UTC (rev 181005)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2015-03-04 19:26:22 UTC (rev 181006)
@@ -62,7 +62,12 @@
SOFT_LINK_CLASS_OPTIONAL(AVFoundation, AVStreamSession);
SOFT_LINK_CLASS_OPTIONAL(AVFoundation, AVVideoPerformanceMetrics)
+SOFT_LINK_CONSTANT(AVFoundation, AVAudioTimePitchAlgorithmSpectral, NSString*)
+SOFT_LINK_CONSTANT(AVFoundation, AVAudioTimePitchAlgorithmVarispeed, NSString*)
SOFT_LINK_CONSTANT(CoreMedia, kCMTimebaseNotification_EffectiveRateChanged, CFStringRef)
+
+#define AVAudioTimePitchAlgorithmSpectral getAVAudioTimePitchAlgorithmSpectral()
+#define AVAudioTimePitchAlgorithmVarispeed getAVAudioTimePitchAlgorithmVarispeed()
#define kCMTimebaseNotification_EffectiveRateChanged getkCMTimebaseNotification_EffectiveRateChanged()
#pragma mark -
@@ -91,6 +96,7 @@
@interface AVSampleBufferAudioRenderer : NSObject
- (void)setVolume:(float)volume;
- (void)setMuted:(BOOL)muted;
+@property (nonatomic, copy) NSString *audioTimePitchAlgorithm;
@end
#pragma mark -
@@ -470,6 +476,13 @@
[m_synchronizer setRate:m_rate];
}
+void MediaPlayerPrivateMediaSourceAVFObjC::setPreservesPitch(bool preservesPitch)
+{
+ NSString *algorithm = preservesPitch ? AVAudioTimePitchAlgorithmSpectral : AVAudioTimePitchAlgorithmVarispeed;
+ for (auto& renderer : m_sampleBufferAudioRenderers)
+ [renderer setAudioTimePitchAlgorithm:algorithm];
+}
+
MediaPlayer::NetworkState MediaPlayerPrivateMediaSourceAVFObjC::networkState() const
{
return m_networkState;
@@ -772,6 +785,7 @@
[audioRenderer setMuted:m_player->muted()];
[audioRenderer setVolume:m_player->volume()];
+ [audioRenderer setAudioTimePitchAlgorithm:(m_player->preservesPitch() ? AVAudioTimePitchAlgorithmSpectral : AVAudioTimePitchAlgorithmVarispeed)];
[m_synchronizer addRenderer:audioRenderer];
m_player->client().mediaPlayerRenderingModeChanged(m_player);