Skip to content

Commit

Permalink
[WebCodecs] Realign audio decoder configuration
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=261325

Reviewed by Youenn Fablet.

The decoder is now closed earlier on, in case the codec is not supported. The video decoder does
this as well.

* Source/WebCore/Modules/webcodecs/WebCodecsAudioDecoder.cpp:
(WebCore::WebCodecsAudioDecoder::configure):

Canonical link: https://commits.webkit.org/267788@main
  • Loading branch information
philn committed Sep 8, 2023
1 parent 0ca3d95 commit 1e0ed8c
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions Source/WebCore/Modules/webcodecs/WebCodecsAudioDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,20 @@ ExceptionOr<void> WebCodecsAudioDecoder::configure(ScriptExecutionContext&, WebC

bool isSupportedCodec = AudioDecoder::isCodecSupported(config.codec);
queueControlMessageAndProcess([this, config = WTFMove(config), isSupportedCodec, identifier = scriptExecutionContext()->identifier()]() mutable {
if (!isSupportedCodec) {
closeDecoder(Exception { NotSupportedError, "Codec is not supported"_s });
return;
}

m_isMessageQueueBlocked = true;
AudioDecoder::PostTaskCallback postTaskCallback = [identifier, weakThis = WeakPtr { *this }](auto&& task) {
ScriptExecutionContext::postTaskTo(identifier, [weakThis, task = WTFMove(task)](auto&) mutable {
if (!weakThis)
return;
weakThis->queueTaskKeepingObjectAlive(*weakThis, TaskSource::MediaElement, [task = WTFMove(task)]() mutable {
task();
});
weakThis->queueTaskKeepingObjectAlive(*weakThis, TaskSource::MediaElement, WTFMove(task));
});
};

if (!isSupportedCodec) {
closeDecoder(Exception { NotSupportedError, "Codec is not supported"_s });
return;
}

AudioDecoder::create(config.codec, createAudioDecoderConfig(config), [this](auto&& result) {
if (!result.has_value()) {
closeDecoder(Exception { NotSupportedError, WTFMove(result.error()) });
Expand Down

0 comments on commit 1e0ed8c

Please sign in to comment.