Changeset 261566 in webkit


Ignore:
Timestamp:
May 12, 2020 11:23:37 AM (4 years ago)
Author:
Jacob Uphoff
Message:

Unreviewed, reverting r261557.

This commit caused testing to exit early due to too many
crashes on macOS Catalina Asan

Reverted changeset:

"Allow WebAudioBufferList to dynamically change its number of
frames"
https://bugs.webkit.org/show_bug.cgi?id=211720
https://trac.webkit.org/changeset/261557

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r261558 r261566  
     12020-05-12  Jacob Uphoff  <jacob_uphoff@apple.com>
     2
     3        Unreviewed, reverting r261557.
     4
     5        This commit caused testing to exit early due to too many
     6        crashes on macOS Catalina Asan
     7
     8        Reverted changeset:
     9
     10        "Allow WebAudioBufferList to dynamically change its number of
     11        frames"
     12        https://bugs.webkit.org/show_bug.cgi?id=211720
     13        https://trac.webkit.org/changeset/261557
     14
    1152020-05-12  Simon Fraser  <simon.fraser@apple.com>
    216
  • trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.cpp

    r261557 r261566  
    3030
    3131#include "NotImplemented.h"
    32 #include "PlatformAudioData.h"
     32#include <wtf/UUID.h>
    3333
    3434namespace WebCore {
     
    3939    m_currentSettings.setSampleRate(sampleRate);
    4040}
    41 
    42 MediaStreamAudioSource::~MediaStreamAudioSource() = default;
    4341
    4442const RealtimeMediaSourceCapabilities& MediaStreamAudioSource::capabilities()
  • trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.h

    r261557 r261566  
    3636
    3737class AudioBus;
    38 class PlatformAudioData;
    3938class RealtimeMediaSourceCapabilities;
    4039
     
    4342    static Ref<MediaStreamAudioSource> create(float sampleRate) { return adoptRef(*new MediaStreamAudioSource { sampleRate }); }
    4443
    45     ~MediaStreamAudioSource();
     44    ~MediaStreamAudioSource() = default;
    4645
    4746    const RealtimeMediaSourceCapabilities& capabilities() final;
     
    6059    String m_deviceId;
    6160    RealtimeMediaSourceSettings m_currentSettings;
    62     std::unique_ptr<PlatformAudioData> m_audioBuffer;
    6361#if USE(AVFOUNDATION)
    6462    size_t m_numberOfFrames { 0 };
  • trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceCocoa.cpp

    r261557 r261566  
    4242namespace WebCore {
    4343
    44 static inline CAAudioStreamDescription streamDescription(size_t sampleRate, size_t channelCount)
     44static inline AudioStreamBasicDescription streamDescription(size_t sampleRate, size_t channelCount)
    4545{
    4646    bool isFloat = true;
     
    7676    m_numberOfFrames += numberOfFrames;
    7777
    78     auto* audioBuffer = m_audioBuffer ? &downcast<WebAudioBufferList>(*m_audioBuffer) : nullptr;
     78    AudioStreamBasicDescription newDescription = streamDescription(m_currentSettings.sampleRate(), bus.numberOfChannels());
    7979
    80     auto description = streamDescription(m_currentSettings.sampleRate(), bus.numberOfChannels());
    81     if (!audioBuffer || audioBuffer->channelCount() != bus.numberOfChannels()) {
    82         m_audioBuffer = makeUnique<WebAudioBufferList>(description, WTF::safeCast<uint32_t>(numberOfFrames));
    83         audioBuffer = &downcast<WebAudioBufferList>(*m_audioBuffer);
    84     } else
    85         audioBuffer->setSampleCount(numberOfFrames);
     80    // FIXME: We should do the memory allocation once in MediaStreamAudioSource and resize it according numberOfFrames.
     81    WebAudioBufferList audioBufferList { CAAudioStreamDescription(newDescription), WTF::safeCast<uint32_t>(numberOfFrames) };
    8682
    8783    for (size_t cptr = 0; cptr < bus.numberOfChannels(); ++cptr)
    88         copyChannelData(*bus.channel(cptr), *audioBuffer->buffer(cptr), numberOfFrames, muted());
     84        copyChannelData(*bus.channel(cptr), *audioBufferList.buffer(cptr), numberOfFrames, muted());
    8985
    90     audioSamplesAvailable(mediaTime, *m_audioBuffer, description, numberOfFrames);
     86    audioSamplesAvailable(mediaTime, audioBufferList, CAAudioStreamDescription(newDescription), numberOfFrames);
    9187}
    9288
  • trunk/Source/WebCore/platform/audio/cocoa/WebAudioBufferList.cpp

    r261557 r261566  
    3434
    3535WebAudioBufferList::WebAudioBufferList(const CAAudioStreamDescription& format)
    36     : m_bytesPerFrame(format.bytesPerFrame())
    37     , m_channelCount(format.numberOfInterleavedChannels())
    3836{
    3937    // AudioBufferList is a variable-length struct, so create on the heap with a generic new() operator
    4038    // with a custom size, and initialize the struct manually.
    4139    uint32_t bufferCount = format.numberOfChannelStreams();
     40    uint32_t channelCount = format.numberOfInterleavedChannels();
    4241
    4342    uint64_t bufferListSize = offsetof(AudioBufferList, mBuffers) + (sizeof(AudioBuffer) * std::max(1U, bufferCount));
     
    4948    m_canonicalList->mNumberBuffers = bufferCount;
    5049    for (uint32_t buffer = 0; buffer < bufferCount; ++buffer)
    51         m_canonicalList->mBuffers[buffer].mNumberChannels = m_channelCount;
     50        m_canonicalList->mBuffers[buffer].mNumberChannels = channelCount;
    5251
    5352    reset();
     
    5756    : WebAudioBufferList(format)
    5857{
    59     if (sampleCount)
    60         setSampleCount(sampleCount);
    61 }
    62 
    63 void WebAudioBufferList::setSampleCount(uint32_t sampleCount)
    64 {
    65     uint32_t bufferCount = m_canonicalList->mNumberBuffers;
    66     if (!bufferCount || m_sampleCount == sampleCount)
     58    if (!sampleCount)
    6759        return;
    6860
    69     m_sampleCount = sampleCount;
    70     size_t bytesPerBuffer = m_sampleCount * m_channelCount * m_bytesPerFrame;
    71     m_flatBuffer.reserveCapacity(bufferCount * bytesPerBuffer);
     61    uint32_t bufferCount = format.numberOfChannelStreams();
     62    uint32_t channelCount = format.numberOfInterleavedChannels();
     63
     64    size_t bytesPerBuffer = sampleCount * channelCount * format.bytesPerFrame();
     65    m_flatBuffer.reserveInitialCapacity(bufferCount * bytesPerBuffer);
    7266    auto data = m_flatBuffer.data();
    7367
     
    8478    : WebAudioBufferList(format)
    8579{
     80
    8681    if (!sampleBuffer)
    8782        return;
  • trunk/Source/WebCore/platform/audio/cocoa/WebAudioBufferList.h

    r261557 r261566  
    4747
    4848    void reset();
    49     WEBCORE_EXPORT void setSampleCount(uint32_t);
    5049
    5150    AudioBufferList* list() const { return m_list.get(); }
     
    5352
    5453    uint32_t bufferCount() const;
    55     uint32_t channelCount() const { return m_channelCount; }
    5654    AudioBuffer* buffer(uint32_t index) const;
    5755    WTF::IteratorRange<AudioBuffer*> buffers() const;
     
    6159
    6260    size_t m_listBufferSize { 0 };
    63     uint32_t m_bytesPerFrame { 0 };
    64     uint32_t m_channelCount { 0 };
    65     uint32_t m_sampleCount { 0 };
    6661    std::unique_ptr<AudioBufferList> m_canonicalList;
    6762    std::unique_ptr<AudioBufferList> m_list;
  • trunk/Source/WebKit/ChangeLog

    r261560 r261566  
     12020-05-12  Jacob Uphoff  <jacob_uphoff@apple.com>
     2
     3        Unreviewed, reverting r261557.
     4
     5        This commit caused testing to exit early due to too many
     6        crashes on macOS Catalina Asan
     7
     8        Reverted changeset:
     9
     10        "Allow WebAudioBufferList to dynamically change its number of
     11        frames"
     12        https://bugs.webkit.org/show_bug.cgi?id=211720
     13        https://trac.webkit.org/changeset/261557
     14
    1152020-05-12  Per Arne Vollan  <pvollan@apple.com>
    216
  • trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.cpp

    r261557 r261566  
    139139    storage.setReadOnly(true);
    140140    m_ringBuffer->allocate(description, numberOfFrames);
    141     m_buffer = makeUnique<WebAudioBufferList>(description, numberOfFrames);
    142141}
    143142
    144143void RemoteCaptureSampleManager::RemoteAudio::audioSamplesAvailable(MediaTime time, uint64_t numberOfFrames, uint64_t startFrame, uint64_t endFrame)
    145144{
    146     m_buffer->setSampleCount(numberOfFrames);
     145    // FIXME: We should allocate this buffer once and resize it as needed.
     146    WebAudioBufferList audioData(m_description, numberOfFrames);
    147147
    148148    m_ringBuffer->setCurrentFrameBounds(startFrame, endFrame);
    149     m_ringBuffer->fetch(m_buffer->list(), numberOfFrames, time.timeValue());
     149    m_ringBuffer->fetch(audioData.list(), numberOfFrames, time.timeValue());
    150150
    151     m_source->remoteAudioSamplesAvailable(time, *m_buffer, m_description, numberOfFrames);
     151    m_source->remoteAudioSamplesAvailable(time, audioData, m_description, numberOfFrames);
    152152}
    153153
  • trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.h

    r261557 r261566  
    3434#include <WebCore/CAAudioStreamDescription.h>
    3535#include <WebCore/CARingBuffer.h>
    36 #include <WebCore/WebAudioBufferList.h>
    3736#include <wtf/HashMap.h>
    3837#include <wtf/WorkQueue.h>
     
    7372        WebCore::CAAudioStreamDescription m_description;
    7473        std::unique_ptr<WebCore::CARingBuffer> m_ringBuffer;
    75         std::unique_ptr<WebCore::WebAudioBufferList> m_buffer;
    7674    };
    7775
Note: See TracChangeset for help on using the changeset viewer.