Changeset 284980 in webkit
- Timestamp:
- Oct 28, 2021, 8:32:57 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/audio/cocoa/CARingBuffer.cpp (modified) (2 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebCore/CARingBuffer.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r284976 r284980 1 2021-10-28 Youenn Fablet <youenn@apple.com> 2 3 Fix CARingBuffer mix mode 4 https://bugs.webkit.org/show_bug.cgi?id=232427 5 6 Reviewed by Eric Carlson. 7 8 Like done for Copy, we need to use the destination offset to write data properly. 9 10 Covered by API test. 11 12 * platform/audio/cocoa/CARingBuffer.cpp: 13 1 14 2021-10-28 Youenn Fablet <youenn@apple.com> 2 15 -
trunk/Source/WebCore/platform/audio/cocoa/CARingBuffer.cpp
r281001 r284980 167 167 continue; 168 168 169 auto* destinationData = static_cast<Byte*>(dest->mData) + destOffset; 170 auto* sourceData = pointer + srcOffset; 169 171 nbytes = std::min<size_t>(nbytes, dest->mDataByteSize - destOffset); 170 172 if (mode == CARingBuffer::Copy) 171 memcpy( static_cast<Byte*>(dest->mData) + destOffset, pointer + srcOffset, nbytes);173 memcpy(destinationData, sourceData, nbytes); 172 174 else { 173 175 switch (format) { 174 176 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); 177 179 for (size_t i = 0; i < nbytes / sizeof(int16_t); i++) 178 180 destination[i] += source[i]; … … 180 182 } 181 183 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)); 184 186 break; 185 187 } 186 188 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)); 189 191 break; 190 192 } 191 193 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)); 194 196 break; 195 197 } -
trunk/Tools/ChangeLog
r284979 r284980 1 2021-10-28 Youenn Fablet <youenn@apple.com> 2 3 Fix CARingBuffer mix mode 4 https://bugs.webkit.org/show_bug.cgi?id=232427 5 <rdar://problem/84747657> 6 7 Reviewed by Eric Carlson. 8 9 * TestWebKitAPI/Tests/WebCore/CARingBuffer.cpp: 10 1 11 2021-10-28 Simon Fraser <simon.fraser@apple.com> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WebCore/CARingBuffer.cpp
r270663 r284980 153 153 static void run(CARingBufferTest& test) 154 154 { 155 const int sampleCount = 64;155 const int sampleCount = 441; 156 156 157 157 CAAudioStreamDescription::PCMFormat format; … … 198 198 for (int i = 0; i < sampleCount; i++) 199 199 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; 200 214 } 201 215 };
Note:
See TracChangeset
for help on using the changeset viewer.