Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 2cfd74cacfc8104b3189fca9832451375b893d80
https://github.com/WebKit/WebKit/commit/2cfd74cacfc8104b3189fca9832451375b893d80
Author: Jean-Yves Avenard <[email protected]>
Date: 2026-03-12 (Thu, 12 Mar 2026)
Changed paths:
M LayoutTests/platform/glib/TestExpectations
A LayoutTests/webaudio/decode-audio-data-aac-expected.txt
A LayoutTests/webaudio/decode-audio-data-aac.html
A LayoutTests/webaudio/decode-audio-data-flac-expected.txt
A LayoutTests/webaudio/decode-audio-data-flac.html
A LayoutTests/webaudio/decode-audio-data-mp3-8000-expected.txt
A LayoutTests/webaudio/decode-audio-data-mp3-8000.html
A LayoutTests/webaudio/decode-audio-data-mp3-expected.txt
A LayoutTests/webaudio/decode-audio-data-mp3.html
A LayoutTests/webaudio/decode-audio-data-mp4-opus-expected.txt
A LayoutTests/webaudio/decode-audio-data-mp4-opus.html
A LayoutTests/webaudio/resources/media/aac.aac
A LayoutTests/webaudio/resources/media/flac.flac
A LayoutTests/webaudio/resources/media/half-a-second-48000.mp3
A LayoutTests/webaudio/resources/media/half-a-second-8000.mp3
A LayoutTests/webaudio/resources/media/opus.mp4
M Source/WebCore/PAL/pal/cf/AudioToolboxSoftLink.cpp
M Source/WebCore/PAL/pal/cf/AudioToolboxSoftLink.h
M Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h
M Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.mm
M Source/WebCore/SourcesCocoa.txt
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
R Source/WebCore/platform/audio/cocoa/AudioFileReaderCocoa.cpp
M Source/WebCore/platform/audio/cocoa/AudioFileReaderCocoa.h
A Source/WebCore/platform/audio/cocoa/AudioFileReaderCocoa.mm
M Source/WebCore/platform/audio/ios/MediaDeviceRouteController.mm
M Source/WebCore/platform/cocoa/ParentalControlsURLFilter.mm
M Source/WebCore/platform/graphics/MIMESniffer.cpp
M
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
M Tools/TestWebKitAPI/Tests/WebCore/cocoa/AVFoundationSoftLinkTest.mm
Log Message:
-----------
MP4 with Opus track isn't usable with decodeAudioData
https://bugs.webkit.org/show_bug.cgi?id=307632
rdar://170196423
Reviewed by Youenn Fablet.
When using webaudio's decodeAudioData for anything other than webm file,
and AudioToolbox's AudioFile was used. It doesn't support opus due to
rdar://99670539.
We instead rewrite the AudioFileReader to use an AVAssetReader with an
AVAssetReaderTrackOutput
to demux the content and extract each compressed audio frames.
As CoreMedia's AVAssetReader does perform any media mimetype sniffing of any
kind
we need to extend the MIMESniffer capabilities a bit.
The inability of the MIMESniffer to properly detect many MP3s point out to
serious flaws in the w3c mimetype sniffing spec. We fix those as well.
As the MIMESniffer only covers a more limited set of supported codecs over
AudioFile
should we fail to sniff, we will use the AudioFile to parse the content and let
it determine
the content type.
Now that we can individually retrieve all the MediaSample from file, we can
now use a single decoding path for both webm and all other content type,
simplifying the code and reducing complexity.
No observable change except for some content such as AAC in ADTS.
An AudioFile would ignore the encoder delay and output several silent audio
frame.
The AVAssetReaderTrackOutput properly determines the number of frames to be
trimmed
and we can correctly drop those. This leads to some decoded content to be
slightly
shorter than before. The audible content however remains the same.
Tests: webaudio/decode-audio-data-aac.html
webaudio/decode-audio-data-flac.html
webaudio/decode-audio-data-mp3-8000.html
webaudio/decode-audio-data-mp3.html
webaudio/decode-audio-data-mp4-opus.html
Tools/TestWebKitAPI/Tests/WebCore/cocoa/AVFoundationSoftLinkTest.mm
* LayoutTests/webaudio/decode-audio-data-aac-expected.txt: Added.
* LayoutTests/webaudio/decode-audio-data-aac.html: Added.
* LayoutTests/webaudio/decode-audio-data-flac-expected.txt: Added.
* LayoutTests/webaudio/decode-audio-data-flac.html: Added.
* LayoutTests/webaudio/decode-audio-data-mp3-8000-expected.txt: Added.
* LayoutTests/webaudio/decode-audio-data-mp3-8000.html: Added.
* LayoutTests/webaudio/decode-audio-data-mp3-expected.txt: Added.
* LayoutTests/webaudio/decode-audio-data-mp3.html: Added.
* LayoutTests/webaudio/decode-audio-data-mp4-opus-expected.txt: Added.
* LayoutTests/webaudio/decode-audio-data-mp4-opus.html: Added.
* LayoutTests/webaudio/resources/media/aac.aac: Added.
* LayoutTests/webaudio/resources/media/flac.flac: Added.
* LayoutTests/webaudio/resources/media/half-a-second-48000.mp3: Added.
* LayoutTests/webaudio/resources/media/half-a-second-8000.mp3: Added.
* LayoutTests/webaudio/resources/media/opus.mp4: Added.
* Source/WebCore/PAL/pal/cf/AudioToolboxSoftLink.cpp:
* Source/WebCore/PAL/pal/cf/AudioToolboxSoftLink.h:
* Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h:
* Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.mm:
* Source/WebCore/SourcesCocoa.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/platform/audio/cocoa/AudioFileReaderCocoa.h:
(WebCore::AudioFileReader::dataSize const): Deleted.
* Source/WebCore/platform/audio/cocoa/AudioFileReaderCocoa.mm: Renamed from
Source/WebCore/platform/audio/cocoa/AudioFileReaderCocoa.cpp.
(-[WebCoreAudioFileReaderLoaderDelegate initWithData:mimeType:]):
(-[WebCoreAudioFileReaderLoaderDelegate
resourceLoader:shouldWaitForLoadingOfRequestedResource:]):
(WebCore::tryCreateAudioBufferList):
(WebCore::destroyAudioBufferList):
(WebCore::validateAudioBufferList):
(WebCore::readProc):
(WebCore::getSizeProc):
(WebCore::mimeTypeFor):
(WebCore::AudioBufferListHolder::AudioBufferListHolder):
(WebCore::AudioBufferListHolder::~AudioBufferListHolder):
(WebCore::AudioBufferListHolder::operator bool const):
(WebCore::AudioBufferListHolder::operator-> const):
(WebCore::AudioBufferListHolder::operator AudioBufferList* const):
(WebCore::AudioBufferListHolder::operator* const):
(WebCore::AudioBufferListHolder::isValid const):
(WebCore::AudioFileReader::AudioFileReader):
(WebCore::framesInSamples):
(WebCore::AudioFileReader::demuxAVFData const):
(WebCore::AudioFileReader::isMaybeWebM const):
(WebCore::AudioFileReader::demuxWebMData const):
(WebCore::passthroughInputDataCallback):
(WebCore::AudioFileReader::decodeData const):
(WebCore::AudioFileReader::fileDataFormat const):
(WebCore::AudioFileReader::clientDataFormat const):
(WebCore::AudioFileReader::createBus):
(WebCore::createBusFromInMemoryAudioFile):
(WebCore::AudioFileReader::logChannel const):
* Source/WebCore/platform/audio/ios/MediaDeviceRouteController.mm:
* Source/WebCore/platform/cocoa/ParentalControlsURLFilter.mm:
* Source/WebCore/platform/graphics/MIMESniffer.cpp:
(WebCore::MIMESniffer::matchMP3Header):
(WebCore::MIMESniffer::mp3FrameSize):
(WebCore::MIMESniffer::parseMP3Frame):
(WebCore::MIMESniffer::mimeTypeFromSnifferEntries):
*
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL):
* Tools/TestWebKitAPI/Tests/WebCore/cocoa/AVFoundationSoftLinkTest.mm:
(TestWebKitAPI::TEST(AVFoundationSoftLink, Constants)):
Canonical link: https://commits.webkit.org/309140@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications