Title: [287618] branches/safari-612-branch
Revision
287618
Author
repst...@apple.com
Date
2022-01-05 10:20:33 -0800 (Wed, 05 Jan 2022)

Log Message

Cherry-pick r284980. rdar://problem/84223894

    Fix CARingBuffer mix mode
    https://bugs.webkit.org/show_bug.cgi?id=232427
    Source/WebCore:

    Reviewed by Eric Carlson.

    Like done for Copy, we need to use the destination offset to write data properly.

    Covered by API test.

    * platform/audio/cocoa/CARingBuffer.cpp:

    Tools:

    <rdar://problem/84747657>

    Reviewed by Eric Carlson.

    * TestWebKitAPI/Tests/WebCore/CARingBuffer.cpp:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284980 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (287617 => 287618)


--- branches/safari-612-branch/Source/WebCore/ChangeLog	2022-01-05 18:20:28 UTC (rev 287617)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog	2022-01-05 18:20:33 UTC (rev 287618)
@@ -1,3 +1,43 @@
+2022-01-05  Russell Epstein  <repst...@apple.com>
+
+        Cherry-pick r284980. rdar://problem/84223894
+
+    Fix CARingBuffer mix mode
+    https://bugs.webkit.org/show_bug.cgi?id=232427
+    Source/WebCore:
+    
+    Reviewed by Eric Carlson.
+    
+    Like done for Copy, we need to use the destination offset to write data properly.
+    
+    Covered by API test.
+    
+    * platform/audio/cocoa/CARingBuffer.cpp:
+    
+    Tools:
+    
+    <rdar://problem/84747657>
+    
+    Reviewed by Eric Carlson.
+    
+    * TestWebKitAPI/Tests/WebCore/CARingBuffer.cpp:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284980 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-10-28  Youenn Fablet  <you...@apple.com>
+
+            Fix CARingBuffer mix mode
+            https://bugs.webkit.org/show_bug.cgi?id=232427
+
+            Reviewed by Eric Carlson.
+
+            Like done for Copy, we need to use the destination offset to write data properly.
+
+            Covered by API test.
+
+            * platform/audio/cocoa/CARingBuffer.cpp:
+
 2021-12-21  Alan Coon  <alanc...@apple.com>
 
         Cherry-pick r287107. rdar://problem/85150486

Modified: branches/safari-612-branch/Source/WebCore/platform/audio/cocoa/CARingBuffer.cpp (287617 => 287618)


--- branches/safari-612-branch/Source/WebCore/platform/audio/cocoa/CARingBuffer.cpp	2022-01-05 18:20:28 UTC (rev 287617)
+++ branches/safari-612-branch/Source/WebCore/platform/audio/cocoa/CARingBuffer.cpp	2022-01-05 18:20:33 UTC (rev 287618)
@@ -166,31 +166,33 @@
         if (destOffset > dest->mDataByteSize)
             continue;
 
+        auto* destinationData = static_cast<Byte*>(dest->mData) + destOffset;
+        auto* sourceData = pointer + srcOffset;
         nbytes = std::min<size_t>(nbytes, dest->mDataByteSize - destOffset);
         if (mode == CARingBuffer::Copy)
-            memcpy(static_cast<Byte*>(dest->mData) + destOffset, pointer + srcOffset, nbytes);
+            memcpy(destinationData, sourceData, nbytes);
         else {
             switch (format) {
             case AudioStreamDescription::Int16: {
-                int16_t* destination = static_cast<int16_t*>(dest->mData);
-                int16_t* source = reinterpret_cast<int16_t*>(pointer + srcOffset);
+                auto* destination = reinterpret_cast<int16_t*>(destinationData);
+                auto* source = reinterpret_cast<int16_t*>(sourceData);
                 for (size_t i = 0; i < nbytes / sizeof(int16_t); i++)
                     destination[i] += source[i];
                 break;
             }
             case AudioStreamDescription::Int32: {
-                int32_t* destination = static_cast<int32_t*>(dest->mData);
-                vDSP_vaddi(destination, 1, reinterpret_cast<int32_t*>(pointer + srcOffset), 1, destination, 1, nbytes / sizeof(int32_t));
+                auto* destination = reinterpret_cast<int32_t*>(destinationData);
+                vDSP_vaddi(destination, 1, reinterpret_cast<int32_t*>(sourceData), 1, destination, 1, nbytes / sizeof(int32_t));
                 break;
             }
             case AudioStreamDescription::Float32: {
-                float* destination = static_cast<float*>(dest->mData);
-                vDSP_vadd(destination, 1, reinterpret_cast<float*>(pointer + srcOffset), 1, destination, 1, nbytes / sizeof(float));
+                auto* destination = reinterpret_cast<float*>(destinationData);
+                vDSP_vadd(destination, 1, reinterpret_cast<float*>(sourceData), 1, destination, 1, nbytes / sizeof(float));
                 break;
             }
             case AudioStreamDescription::Float64: {
-                double* destination = static_cast<double*>(dest->mData);
-                vDSP_vaddD(destination, 1, reinterpret_cast<double*>(pointer + srcOffset), 1, destination, 1, nbytes / sizeof(double));
+                auto* destination = reinterpret_cast<double*>(destinationData);
+                vDSP_vaddD(destination, 1, reinterpret_cast<double*>(sourceData), 1, destination, 1, nbytes / sizeof(double));
                 break;
             }
             case AudioStreamDescription::None:

Modified: branches/safari-612-branch/Tools/ChangeLog (287617 => 287618)


--- branches/safari-612-branch/Tools/ChangeLog	2022-01-05 18:20:28 UTC (rev 287617)
+++ branches/safari-612-branch/Tools/ChangeLog	2022-01-05 18:20:33 UTC (rev 287618)
@@ -1,3 +1,40 @@
+2022-01-05  Russell Epstein  <repst...@apple.com>
+
+        Cherry-pick r284980. rdar://problem/84223894
+
+    Fix CARingBuffer mix mode
+    https://bugs.webkit.org/show_bug.cgi?id=232427
+    Source/WebCore:
+    
+    Reviewed by Eric Carlson.
+    
+    Like done for Copy, we need to use the destination offset to write data properly.
+    
+    Covered by API test.
+    
+    * platform/audio/cocoa/CARingBuffer.cpp:
+    
+    Tools:
+    
+    <rdar://problem/84747657>
+    
+    Reviewed by Eric Carlson.
+    
+    * TestWebKitAPI/Tests/WebCore/CARingBuffer.cpp:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284980 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-10-28  Youenn Fablet  <you...@apple.com>
+
+            Fix CARingBuffer mix mode
+            https://bugs.webkit.org/show_bug.cgi?id=232427
+            <rdar://problem/84747657>
+
+            Reviewed by Eric Carlson.
+
+            * TestWebKitAPI/Tests/WebCore/CARingBuffer.cpp:
+
 2021-12-21  Robert Jenner  <jen...@apple.com>
 
         Cherry-pick r285057. rdar://problem/84000764

Modified: branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebCore/CARingBuffer.cpp (287617 => 287618)


--- branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebCore/CARingBuffer.cpp	2022-01-05 18:20:28 UTC (rev 287617)
+++ branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebCore/CARingBuffer.cpp	2022-01-05 18:20:33 UTC (rev 287618)
@@ -152,7 +152,7 @@
 public:
     static void run(CARingBufferTest& test)
     {
-        const int sampleCount = 64;
+        const int sampleCount = 441;
 
         CAAudioStreamDescription::PCMFormat format;
         if (std::is_same<type, float>::value)
@@ -197,6 +197,20 @@
         
         for (int i = 0; i < sampleCount; i++)
             EXPECT_EQ(readBuffer[i], referenceBuffer[i]) << "Ring buffer value differs at index " << i;
+
+        test.ringBuffer().fetch(&test.bufferList(), sampleCount, 0, CARingBuffer::FetchMode::Copy);
+        err = test.ringBuffer().store(&test.bufferList(), sampleCount, sampleCount);
+        EXPECT_EQ(err, CARingBuffer::Error::Ok);
+
+        test.ringBuffer().fetch(&test.bufferList(), sampleCount, sampleCount, CARingBuffer::FetchMode::Copy);
+        test.ringBuffer().fetch(&test.bufferList(), sampleCount, sampleCount, CARingBuffer::FetchMode::Mix);
+        test.ringBuffer().fetch(&test.bufferList(), sampleCount, sampleCount, CARingBuffer::FetchMode::Mix);
+
+        for (int i = 0; i < sampleCount; i++)
+            referenceBuffer[i] = sourceBuffer[i] * 3;
+
+        for (int i = 0; i < sampleCount; i++)
+            EXPECT_EQ(readBuffer[i], referenceBuffer[i]) << "Ring buffer value differs at index " << i;
     }
 };
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to