Skip to content

Commit

Permalink
REGRESSION (iPadOS 17.5): Audio distortion occurs when using AudioCon…
Browse files Browse the repository at this point in the history
…text with a sample rate of 44100Hz and an AudioWorklet

https://bugs.webkit.org/show_bug.cgi?id=274507
rdar://128551401

Reviewed by Jer Noble.

Wait until render has completed on worklet thread before processing the next one.

* Source/WebCore/platform/audio/SharedAudioDestination.cpp:
(WebCore::SharedAudioDestination::sharedRender):

Canonical link: https://commits.webkit.org/279409@main
  • Loading branch information
jyavenard committed May 28, 2024
1 parent bb30fda commit d723230
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Source/WebCore/platform/audio/SharedAudioDestination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <wtf/WTFSemaphore.h>
#include <wtf/WeakPtr.h>
#include <wtf/WorkQueue.h>
#include <wtf/threads/BinarySemaphore.h>

namespace WebCore {

Expand Down Expand Up @@ -285,9 +286,12 @@ void SharedAudioDestination::sharedRender(AudioBus* sourceBus, AudioBus* destina
if (!m_dispatchToRenderThread)
callRenderCallback(sourceBus, destinationBus, numberOfFrames, outputPosition);
else {
m_dispatchToRenderThread([protectedThis = Ref { *this }, sourceBus = RefPtr { sourceBus }, destinationBus = RefPtr { destinationBus }, numberOfFrames, outputPosition]() mutable {
BinarySemaphore semaphore;
m_dispatchToRenderThread([protectedThis = Ref { *this }, sourceBus = RefPtr { sourceBus }, destinationBus = RefPtr { destinationBus }, numberOfFrames, outputPosition, &semaphore]() mutable {
protectedThis->callRenderCallback(sourceBus.get(), destinationBus.get(), numberOfFrames, outputPosition);
semaphore.signal();
});
semaphore.wait();
}
}

Expand Down

0 comments on commit d723230

Please sign in to comment.