Title: [290964] trunk
Revision
290964
Author
[email protected]
Date
2022-03-07 16:00:31 -0800 (Mon, 07 Mar 2022)

Log Message

MediaTime::invalidTime() conversion to CMTime incorrectly creates a valid time.
https://bugs.webkit.org/show_bug.cgi?id=237473
rdar://problem/89814921

Reviewed by Jer Noble.

Source/WebCore:

Fly-by fix: update call to AVOutputContextOutputDevicesDidChangeNotification
now that the access macro got fixed.

API Test added.

* platform/audio/ios/MediaSessionHelperIOS.mm:
(-[WebMediaSessionHelper startMonitoringAirPlayRoutes]):
* platform/graphics/avfoundation/objc/AVRoutePickerViewTargetPicker.mm:
(WebCore::AVRoutePickerViewTargetPicker::outputContextInternal):
(WebCore::AVRoutePickerViewTargetPicker::routeDetector):
(WebCore::AVRoutePickerViewTargetPicker::invalidatePlaybackTargets):
(-[WebAVRoutePickerViewHelper notificationHandler:]):

Source/WebCore/PAL:

Fly-by fix: macro definition to access method
AVOutputContextOutputDevicesDidChangeNotification was incorrect.

* pal/avfoundation/MediaTimeAVFoundation.cpp:
(PAL::toCMTime): Ensure that if the converted time was invalid. The
flag is carried accross.
* pal/cocoa/AVFoundationSoftLink.h:

Tools:

Fly-by fixes: AVFoundationSoftLinkTest wasn't being compiled

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebCore/cocoa/AVFoundationSoftLinkTest.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebCore/cocoa/CoreMediaUtilities.mm: Added.
(TestWebKitAPI::TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (290963 => 290964)


--- trunk/Source/WebCore/ChangeLog	2022-03-07 23:51:19 UTC (rev 290963)
+++ trunk/Source/WebCore/ChangeLog	2022-03-08 00:00:31 UTC (rev 290964)
@@ -1,3 +1,24 @@
+2022-03-07  Jean-Yves Avenard  <[email protected]>
+
+        MediaTime::invalidTime() conversion to CMTime incorrectly creates a valid time.
+        https://bugs.webkit.org/show_bug.cgi?id=237473
+        rdar://problem/89814921
+
+        Reviewed by Jer Noble.
+
+        Fly-by fix: update call to AVOutputContextOutputDevicesDidChangeNotification
+        now that the access macro got fixed.
+
+        API Test added.
+
+        * platform/audio/ios/MediaSessionHelperIOS.mm:
+        (-[WebMediaSessionHelper startMonitoringAirPlayRoutes]):
+        * platform/graphics/avfoundation/objc/AVRoutePickerViewTargetPicker.mm:
+        (WebCore::AVRoutePickerViewTargetPicker::outputContextInternal):
+        (WebCore::AVRoutePickerViewTargetPicker::routeDetector):
+        (WebCore::AVRoutePickerViewTargetPicker::invalidatePlaybackTargets):
+        (-[WebAVRoutePickerViewHelper notificationHandler:]):
+
 2022-03-07  Chris Dumez  <[email protected]>
 
         allow-custom-protocols-navigation sandbox flag.

Modified: trunk/Source/WebCore/PAL/ChangeLog (290963 => 290964)


--- trunk/Source/WebCore/PAL/ChangeLog	2022-03-07 23:51:19 UTC (rev 290963)
+++ trunk/Source/WebCore/PAL/ChangeLog	2022-03-08 00:00:31 UTC (rev 290964)
@@ -1,3 +1,19 @@
+2022-03-07  Jean-Yves Avenard  <[email protected]>
+
+        MediaTime::invalidTime() conversion to CMTime incorrectly creates a valid time.
+        https://bugs.webkit.org/show_bug.cgi?id=237473
+        rdar://problem/89814921
+
+        Reviewed by Jer Noble.
+
+        Fly-by fix: macro definition to access method
+        AVOutputContextOutputDevicesDidChangeNotification was incorrect.
+
+        * pal/avfoundation/MediaTimeAVFoundation.cpp:
+        (PAL::toCMTime): Ensure that if the converted time was invalid. The
+        flag is carried accross.
+        * pal/cocoa/AVFoundationSoftLink.h:
+
 2022-03-02  Dan Glastonbury  <[email protected]>
 
         [WebGPU] Implement GPUDeviceDescriptor.requiredLimits

Modified: trunk/Source/WebCore/PAL/pal/avfoundation/MediaTimeAVFoundation.cpp (290963 => 290964)


--- trunk/Source/WebCore/PAL/pal/avfoundation/MediaTimeAVFoundation.cpp	2022-03-07 23:51:19 UTC (rev 290963)
+++ trunk/Source/WebCore/PAL/pal/avfoundation/MediaTimeAVFoundation.cpp	2022-03-08 00:00:31 UTC (rev 290964)
@@ -65,6 +65,8 @@
 
     if (mediaTime.isValid())
         time.flags |= kCMTimeFlags_Valid;
+    else
+        time.flags &= ~kCMTimeFlags_Valid;
     if (mediaTime.hasBeenRounded())
         time.flags |= kCMTimeFlags_HasBeenRounded;
     if (mediaTime.isPositiveInfinite())

Modified: trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h (290963 => 290964)


--- trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h	2022-03-07 23:51:19 UTC (rev 290963)
+++ trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h	2022-03-08 00:00:31 UTC (rev 290964)
@@ -338,11 +338,12 @@
 
 #if !PLATFORM(WATCHOS)
 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, AVFoundation, AVRouteDetectorMultipleRoutesDetectedDidChangeNotification, NSString *)
-#define AVRouteDetectorMultipleRoutesDetectedDidChangeNotification PAL::get_AVFoundation_AVRouteDetectorMultipleRoutesDetectedDidChangeNotification()
+#define AVRouteDetectorMultipleRoutesDetectedDidChangeNotification get_AVFoundation_AVRouteDetectorMultipleRoutesDetectedDidChangeNotification()
 #endif // HAVE(WATCHOS)
 
 #if HAVE(AVROUTEPICKERVIEW)
 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, AVFoundation, AVOutputContextOutputDevicesDidChangeNotification, NSNotificationName)
+#define AVOutputContextOutputDevicesDidChangeNotification get_AVFoundation_AVOutputContextOutputDevicesDidChangeNotification()
 #endif // HAVE(AVROUTEPICKERVIEW)
 
 #if PLATFORM(COCOA)

Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionHelperIOS.mm (290963 => 290964)


--- trunk/Source/WebCore/platform/audio/ios/MediaSessionHelperIOS.mm	2022-03-07 23:51:19 UTC (rev 290963)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionHelperIOS.mm	2022-03-08 00:00:31 UTC (rev 290964)
@@ -460,7 +460,7 @@
             BEGIN_BLOCK_OBJC_EXCEPTIONS
             protectedSelf->_routeDetector = adoptNS([PAL::allocAVRouteDetectorInstance() init]);
             protectedSelf->_routeDetector.get().routeDetectionEnabled = protectedSelf->_monitoringAirPlayRoutes;
-            [[NSNotificationCenter defaultCenter] addObserver:protectedSelf.get() selector:@selector(wirelessRoutesAvailableDidChange:) name:AVRouteDetectorMultipleRoutesDetectedDidChangeNotification object:protectedSelf->_routeDetector.get()];
+            [[NSNotificationCenter defaultCenter] addObserver:protectedSelf.get() selector:@selector(wirelessRoutesAvailableDidChange:) name:PAL::AVRouteDetectorMultipleRoutesDetectedDidChangeNotification object:protectedSelf->_routeDetector.get()];
 
             protectedSelf->_callback->externalOutputDeviceAvailableDidChange();
             END_BLOCK_OBJC_EXCEPTIONS

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVRoutePickerViewTargetPicker.mm (290963 => 290964)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVRoutePickerViewTargetPicker.mm	2022-03-07 23:51:19 UTC (rev 290963)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVRoutePickerViewTargetPicker.mm	2022-03-08 00:00:31 UTC (rev 290964)
@@ -91,7 +91,7 @@
             m_outputContext = [PAL::getAVOutputContextClass() outputContext];
         ASSERT(m_outputContext);
         if (m_outputContext)
-            [[NSNotificationCenter defaultCenter] addObserver:m_routePickerViewDelegate.get() selector:@selector(notificationHandler:) name:PAL::get_AVFoundation_AVOutputContextOutputDevicesDidChangeNotification() object:m_outputContext.get()];
+            [[NSNotificationCenter defaultCenter] addObserver:m_routePickerViewDelegate.get() selector:@selector(notificationHandler:) name:PAL::AVOutputContextOutputDevicesDidChangeNotification object:m_outputContext.get()];
     }
 
     return m_outputContext.get();
@@ -111,7 +111,7 @@
 {
     if (!m_routeDetector) {
         m_routeDetector = adoptNS([PAL::allocAVRouteDetectorInstance() init]);
-        [[NSNotificationCenter defaultCenter] addObserver:m_routePickerViewDelegate.get() selector:@selector(notificationHandler:) name:PAL::get_AVFoundation_AVRouteDetectorMultipleRoutesDetectedDidChangeNotification() object:m_routeDetector.get()];
+        [[NSNotificationCenter defaultCenter] addObserver:m_routePickerViewDelegate.get() selector:@selector(notificationHandler:) name:PAL::AVRouteDetectorMultipleRoutesDetectedDidChangeNotification object:m_routeDetector.get()];
         if ([m_routeDetector multipleRoutesDetected])
             availableDevicesDidChange();
     }
@@ -170,13 +170,13 @@
 void AVRoutePickerViewTargetPicker::invalidatePlaybackTargets()
 {
     if (m_routeDetector) {
-        [[NSNotificationCenter defaultCenter] removeObserver:m_routePickerViewDelegate.get() name:PAL::get_AVFoundation_AVRouteDetectorMultipleRoutesDetectedDidChangeNotification() object:m_routeDetector.get()];
+        [[NSNotificationCenter defaultCenter] removeObserver:m_routePickerViewDelegate.get() name:PAL::AVRouteDetectorMultipleRoutesDetectedDidChangeNotification object:m_routeDetector.get()];
         [m_routeDetector setRouteDetectionEnabled:NO];
         m_routePickerView = nullptr;
     }
 
     if (m_outputContext) {
-        [[NSNotificationCenter defaultCenter] removeObserver:m_routePickerViewDelegate.get() name:PAL::get_AVFoundation_AVOutputContextOutputDevicesDidChangeNotification() object:m_outputContext.get()];
+        [[NSNotificationCenter defaultCenter] removeObserver:m_routePickerViewDelegate.get() name:PAL::AVOutputContextOutputDevicesDidChangeNotification object:m_outputContext.get()];
         m_outputContext = nullptr;
     }
 
@@ -282,9 +282,9 @@
         if (!m_callback)
             return;
 
-        if ([[notification name] isEqualToString:PAL::get_AVFoundation_AVOutputContextOutputDevicesDidChangeNotification()])
+        if ([[notification name] isEqualToString:PAL::AVOutputContextOutputDevicesDidChangeNotification])
             m_callback->currentDeviceDidChange();
-        else if ([[notification name] isEqualToString:PAL::get_AVFoundation_AVRouteDetectorMultipleRoutesDetectedDidChangeNotification()])
+        else if ([[notification name] isEqualToString:PAL::AVRouteDetectorMultipleRoutesDetectedDidChangeNotification])
             m_callback->availableDevicesDidChange();
     });
 }

Modified: trunk/Tools/ChangeLog (290963 => 290964)


--- trunk/Tools/ChangeLog	2022-03-07 23:51:19 UTC (rev 290963)
+++ trunk/Tools/ChangeLog	2022-03-08 00:00:31 UTC (rev 290964)
@@ -1,3 +1,19 @@
+2022-03-07  Jean-Yves Avenard  <[email protected]>
+
+        MediaTime::invalidTime() conversion to CMTime incorrectly creates a valid time.
+        https://bugs.webkit.org/show_bug.cgi?id=237473
+        rdar://problem/89814921
+
+        Reviewed by Jer Noble.
+
+        Fly-by fixes: AVFoundationSoftLinkTest wasn't being compiled
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebCore/cocoa/AVFoundationSoftLinkTest.mm:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebCore/cocoa/CoreMediaUtilities.mm: Added.
+        (TestWebKitAPI::TEST):
+
 2022-03-07  Chris Dumez  <[email protected]>
 
         allow-custom-protocols-navigation sandbox flag.

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (290963 => 290964)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2022-03-07 23:51:19 UTC (rev 290963)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2022-03-08 00:00:31 UTC (rev 290964)
@@ -262,6 +262,8 @@
 		510477731D298DDD009747EB /* IDBDeleteRecovery.sqlite3-shm in Copy Resources */ = {isa = PBXBuildFile; fileRef = 510477701D298D85009747EB /* IDBDeleteRecovery.sqlite3-shm */; };
 		510477741D298DDD009747EB /* IDBDeleteRecovery.sqlite3-wal in Copy Resources */ = {isa = PBXBuildFile; fileRef = 510477711D298D85009747EB /* IDBDeleteRecovery.sqlite3-wal */; };
 		510477771D298E72009747EB /* IDBDeleteRecovery.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 510477761D298E57009747EB /* IDBDeleteRecovery.html */; };
+		510A667B27D301AC00D22629 /* CoreMediaUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = 510A667A27D2FC7A00D22629 /* CoreMediaUtilities.mm */; };
+		510A667C27D301C600D22629 /* AVFoundationSoftLinkTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0711DF51226A95FB003DD2F7 /* AVFoundationSoftLinkTest.mm */; };
 		510A91F824D3622100BFD89C /* SonyDualShock3.mm in Sources */ = {isa = PBXBuildFile; fileRef = 510A91F724D3621900BFD89C /* SonyDualShock3.mm */; };
 		510A920A24D5048900BFD89C /* LogitechF310.mm in Sources */ = {isa = PBXBuildFile; fileRef = 510A920924D5048300BFD89C /* LogitechF310.mm */; };
 		510A920C24D5275500BFD89C /* LogitechF710.mm in Sources */ = {isa = PBXBuildFile; fileRef = 510A920B24D5275100BFD89C /* LogitechF710.mm */; };
@@ -2070,6 +2072,7 @@
 		510477711D298D85009747EB /* IDBDeleteRecovery.sqlite3-wal */ = {isa = PBXFileReference; lastKnownFileType = file; path = "IDBDeleteRecovery.sqlite3-wal"; sourceTree = "<group>"; };
 		510477751D298E03009747EB /* IDBDeleteRecovery.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IDBDeleteRecovery.mm; sourceTree = "<group>"; };
 		510477761D298E57009747EB /* IDBDeleteRecovery.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = IDBDeleteRecovery.html; sourceTree = "<group>"; };
+		510A667A27D2FC7A00D22629 /* CoreMediaUtilities.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CoreMediaUtilities.mm; sourceTree = "<group>"; };
 		510A91F724D3621900BFD89C /* SonyDualShock3.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SonyDualShock3.mm; sourceTree = "<group>"; };
 		510A920924D5048300BFD89C /* LogitechF310.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LogitechF310.mm; sourceTree = "<group>"; };
 		510A920B24D5275100BFD89C /* LogitechF710.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LogitechF710.mm; sourceTree = "<group>"; };
@@ -5059,6 +5062,7 @@
 			children = (
 				0711DF51226A95FB003DD2F7 /* AVFoundationSoftLinkTest.mm */,
 				31F865E526701E73003BFC6D /* CoreCryptoSPI.h */,
+				510A667A27D2FC7A00D22629 /* CoreMediaUtilities.mm */,
 				751B05D51F8EAC1A0028A09E /* DatabaseTrackerTest.mm */,
 				57F1C91025DDD51900E8F6EA /* PrivateClickMeasurementCocoa.mm */,
 				5769C50A1D9B0001000847FB /* SerializedCryptoKeyWrap.mm */,
@@ -5531,6 +5535,7 @@
 				F4FA2A4F24D1F05700618A46 /* AttributedSubstringForProposedRange.mm in Sources */,
 				CDC8E48D1BC5CB4500594FEC /* AudioSessionCategoryIOS.mm in Sources */,
 				F42D634422A1729F00D2FB3A /* AutocorrectionTestsIOS.mm in Sources */,
+				510A667C27D301C600D22629 /* AVFoundationSoftLinkTest.mm in Sources */,
 				7CCE7EB51A411A7E00447C4C /* BackForwardList.mm in Sources */,
 				1C7FEB20207C0F2E00D23278 /* BackgroundColor.mm in Sources */,
 				C15CBB3023F1FF1A00300CC7 /* BacklightLevelNotification.mm in Sources */,
@@ -5560,6 +5565,7 @@
 				CD0BD0A61F79924D001AB2CF /* ContextMenuImgWithVideo.mm in Sources */,
 				A1C142C224AA7B2E00444207 /* ContextMenuMouseEvents.mm in Sources */,
 				F4034FA1275D5402003A81F8 /* CookieConsent.mm in Sources */,
+				510A667B27D301AC00D22629 /* CoreMediaUtilities.mm in Sources */,
 				7CCE7EAC1A411A3400447C4C /* Counters.cpp in Sources */,
 				7AEAD47F1E20116C00416EFE /* CrossPartitionFileSchemeAccess.mm in Sources */,
 				7CCE7EDB1A411A9200447C4C /* CSSParser.cpp in Sources */,

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/cocoa/AVFoundationSoftLinkTest.mm (290963 => 290964)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/cocoa/AVFoundationSoftLinkTest.mm	2022-03-07 23:51:19 UTC (rev 290963)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/cocoa/AVFoundationSoftLinkTest.mm	2022-03-08 00:00:31 UTC (rev 290964)
@@ -193,11 +193,14 @@
 #endif
 
 #endif
-    
+
+#if !PLATFORM(WATCHOS)
+    EXPECT_TRUE([PAL::AVRouteDetectorMultipleRoutesDetectedDidChangeNotification isEqualToString:@"AVRouteDetectorMultipleRoutesDetectedDidChangeNotification"]);
+#endif
+
 #if HAVE(AVROUTEPICKERVIEW)
-    EXPECT_TRUE([AVRouteDetectorMultipleRoutesDetectedDidChangeNotification isEqualToString:@"AVRouteDetectorMultipleRoutesDetectedDidChangeNotification"]);
-    EXPECT_TRUE([AVOutputContextOutputDevicesDidChangeNotification isEqualToString:@"AVOutputContextOutputDevicesDidChangeNotification"]);
-#endif // PLATFORM(WATCHOS)
+    EXPECT_TRUE([PAL::AVOutputContextOutputDevicesDidChangeNotification isEqualToString:@"AVOutputContextOutputDevicesDidChangeNotification"]);
+#endif // HAVE(AVROUTEPICKERVIEW)
 
 }
 

Added: trunk/Tools/TestWebKitAPI/Tests/WebCore/cocoa/CoreMediaUtilities.mm (0 => 290964)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/cocoa/CoreMediaUtilities.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/cocoa/CoreMediaUtilities.mm	2022-03-08 00:00:31 UTC (rev 290964)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2022 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if USE(AVFOUNDATION)
+
+#include <pal/avfoundation/MediaTimeAVFoundation.h>
+
+namespace TestWebKitAPI {
+
+TEST(PAL, MediaTime)
+{
+    EXPECT_EQ(PAL::toMediaTime(PAL::toCMTime(MediaTime::invalidTime())), MediaTime::invalidTime());
+}
+
+} // namespace TestWebKitAPI
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to