⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 287618 in webkit


Ignore:
Timestamp:
Jan 5, 2022, 10:20:33 AM (5 years ago)
Author:
Russell Epstein
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

Location:
branches/safari-612-branch
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-612-branch/Source/WebCore/ChangeLog

    r287337 r287618  
     12022-01-05  Russell Epstein  <repstein@apple.com>
     2
     3        Cherry-pick r284980. rdar://problem/84223894
     4
     5    Fix CARingBuffer mix mode
     6    https://bugs.webkit.org/show_bug.cgi?id=232427
     7    Source/WebCore:
     8   
     9    Reviewed by Eric Carlson.
     10   
     11    Like done for Copy, we need to use the destination offset to write data properly.
     12   
     13    Covered by API test.
     14   
     15    * platform/audio/cocoa/CARingBuffer.cpp:
     16   
     17    Tools:
     18   
     19    <rdar://problem/84747657>
     20   
     21    Reviewed by Eric Carlson.
     22   
     23    * TestWebKitAPI/Tests/WebCore/CARingBuffer.cpp:
     24   
     25   
     26    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284980 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     27
     28    2021-10-28  Youenn Fablet  <youenn@apple.com>
     29
     30            Fix CARingBuffer mix mode
     31            https://bugs.webkit.org/show_bug.cgi?id=232427
     32
     33            Reviewed by Eric Carlson.
     34
     35            Like done for Copy, we need to use the destination offset to write data properly.
     36
     37            Covered by API test.
     38
     39            * platform/audio/cocoa/CARingBuffer.cpp:
     40
    1412021-12-21  Alan Coon  <alancoon@apple.com>
    242
  • branches/safari-612-branch/Source/WebCore/platform/audio/cocoa/CARingBuffer.cpp

    r281001 r287618  
    167167            continue;
    168168
     169        auto* destinationData = static_cast<Byte*>(dest->mData) + destOffset;
     170        auto* sourceData = pointer + srcOffset;
    169171        nbytes = std::min<size_t>(nbytes, dest->mDataByteSize - destOffset);
    170172        if (mode == CARingBuffer::Copy)
    171             memcpy(static_cast<Byte*>(dest->mData) + destOffset, pointer + srcOffset, nbytes);
     173            memcpy(destinationData, sourceData, nbytes);
    172174        else {
    173175            switch (format) {
    174176            case AudioStreamDescription::Int16: {
    175                 int16_t* destination = static_cast<int16_t*>(dest->mData);
    176                 int16_t* source = reinterpret_cast<int16_t*>(pointer + srcOffset);
     177                auto* destination = reinterpret_cast<int16_t*>(destinationData);
     178                auto* source = reinterpret_cast<int16_t*>(sourceData);
    177179                for (size_t i = 0; i < nbytes / sizeof(int16_t); i++)
    178180                    destination[i] += source[i];
    … …  
    180182            }
    181183            case AudioStreamDescription::Int32: {
    182                 int32_t* destination = static_cast<int32_t*>(dest->mData);
    183                 vDSP_vaddi(destination, 1, reinterpret_cast<int32_t*>(pointer + srcOffset), 1, destination, 1, nbytes / sizeof(int32_t));
     184                auto* destination = reinterpret_cast<int32_t*>(destinationData);
     185                vDSP_vaddi(destination, 1, reinterpret_cast<int32_t*>(sourceData), 1, destination, 1, nbytes / sizeof(int32_t));
    184186                break;
    185187            }
    186188            case AudioStreamDescription::Float32: {
    187                 float* destination = static_cast<float*>(dest->mData);
    188                 vDSP_vadd(destination, 1, reinterpret_cast<float*>(pointer + srcOffset), 1, destination, 1, nbytes / sizeof(float));
     189                auto* destination = reinterpret_cast<float*>(destinationData);
     190                vDSP_vadd(destination, 1, reinterpret_cast<float*>(sourceData), 1, destination, 1, nbytes / sizeof(float));
    189191                break;
    190192            }
    191193            case AudioStreamDescription::Float64: {
    192                 double* destination = static_cast<double*>(dest->mData);
    193                 vDSP_vaddD(destination, 1, reinterpret_cast<double*>(pointer + srcOffset), 1, destination, 1, nbytes / sizeof(double));
     194                auto* destination = reinterpret_cast<double*>(destinationData);
     195                vDSP_vaddD(destination, 1, reinterpret_cast<double*>(sourceData), 1, destination, 1, nbytes / sizeof(double));
    194196                break;
    195197            }
  • branches/safari-612-branch/Tools/ChangeLog

    r287332 r287618  
     12022-01-05  Russell Epstein  <repstein@apple.com>
     2
     3        Cherry-pick r284980. rdar://problem/84223894
     4
     5    Fix CARingBuffer mix mode
     6    https://bugs.webkit.org/show_bug.cgi?id=232427
     7    Source/WebCore:
     8   
     9    Reviewed by Eric Carlson.
     10   
     11    Like done for Copy, we need to use the destination offset to write data properly.
     12   
     13    Covered by API test.
     14   
     15    * platform/audio/cocoa/CARingBuffer.cpp:
     16   
     17    Tools:
     18   
     19    <rdar://problem/84747657>
     20   
     21    Reviewed by Eric Carlson.
     22   
     23    * TestWebKitAPI/Tests/WebCore/CARingBuffer.cpp:
     24   
     25   
     26    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284980 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     27
     28    2021-10-28  Youenn Fablet  <youenn@apple.com>
     29
     30            Fix CARingBuffer mix mode
     31            https://bugs.webkit.org/show_bug.cgi?id=232427
     32            <rdar://problem/84747657>
     33
     34            Reviewed by Eric Carlson.
     35
     36            * TestWebKitAPI/Tests/WebCore/CARingBuffer.cpp:
     37
    1382021-12-21  Robert Jenner  <Jenner@apple.com>
    239
  • branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebCore/CARingBuffer.cpp

    r270663 r287618  
    153153    static void run(CARingBufferTest& test)
    154154    {
    155         const int sampleCount = 64;
     155        const int sampleCount = 441;
    156156
    157157        CAAudioStreamDescription::PCMFormat format;
    … …  
    198198        for (int i = 0; i < sampleCount; i++)
    199199            EXPECT_EQ(readBuffer[i], referenceBuffer[i]) << "Ring buffer value differs at index " << i;
     200
     201        test.ringBuffer().fetch(&test.bufferList(), sampleCount, 0, CARingBuffer::FetchMode::Copy);
     202        err = test.ringBuffer().store(&test.bufferList(), sampleCount, sampleCount);
     203        EXPECT_EQ(err, CARingBuffer::Error::Ok);
     204
     205        test.ringBuffer().fetch(&test.bufferList(), sampleCount, sampleCount, CARingBuffer::FetchMode::Copy);
     206        test.ringBuffer().fetch(&test.bufferList(), sampleCount, sampleCount, CARingBuffer::FetchMode::Mix);
     207        test.ringBuffer().fetch(&test.bufferList(), sampleCount, sampleCount, CARingBuffer::FetchMode::Mix);
     208
     209        for (int i = 0; i < sampleCount; i++)
     210            referenceBuffer[i] = sourceBuffer[i] * 3;
     211
     212        for (int i = 0; i < sampleCount; i++)
     213            EXPECT_EQ(readBuffer[i], referenceBuffer[i]) << "Ring buffer value differs at index " << i;
    200214    }
    201215};
Note: See TracChangeset for help on using the changeset viewer.