Title: [261566] trunk/Source
Revision
261566
Author
[email protected]
Date
2020-05-12 11:23:37 -0700 (Tue, 12 May 2020)

Log 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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (261565 => 261566)


--- trunk/Source/WebCore/ChangeLog	2020-05-12 17:59:25 UTC (rev 261565)
+++ trunk/Source/WebCore/ChangeLog	2020-05-12 18:23:37 UTC (rev 261566)
@@ -1,3 +1,17 @@
+2020-05-12  Jacob Uphoff  <[email protected]>
+
+        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
+
 2020-05-12  Simon Fraser  <[email protected]>
 
         Speculative fix for crash in ScrollingTree::handleWheelEvent()

Modified: trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.cpp (261565 => 261566)


--- trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.cpp	2020-05-12 17:59:25 UTC (rev 261565)
+++ trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.cpp	2020-05-12 18:23:37 UTC (rev 261566)
@@ -29,7 +29,7 @@
 #if ENABLE(MEDIA_STREAM)
 
 #include "NotImplemented.h"
-#include "PlatformAudioData.h"
+#include <wtf/UUID.h>
 
 namespace WebCore {
 
@@ -39,8 +39,6 @@
     m_currentSettings.setSampleRate(sampleRate);
 }
 
-MediaStreamAudioSource::~MediaStreamAudioSource() = default;
-
 const RealtimeMediaSourceCapabilities& MediaStreamAudioSource::capabilities()
 {
     // FIXME: implement this.

Modified: trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.h (261565 => 261566)


--- trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.h	2020-05-12 17:59:25 UTC (rev 261565)
+++ trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.h	2020-05-12 18:23:37 UTC (rev 261566)
@@ -35,7 +35,6 @@
 namespace WebCore {
 
 class AudioBus;
-class PlatformAudioData;
 class RealtimeMediaSourceCapabilities;
 
 class MediaStreamAudioSource final : public RealtimeMediaSource {
@@ -42,7 +41,7 @@
 public:
     static Ref<MediaStreamAudioSource> create(float sampleRate) { return adoptRef(*new MediaStreamAudioSource { sampleRate }); }
 
-    ~MediaStreamAudioSource();
+    ~MediaStreamAudioSource() = default;
 
     const RealtimeMediaSourceCapabilities& capabilities() final;
     const RealtimeMediaSourceSettings& settings() final;
@@ -59,7 +58,6 @@
 
     String m_deviceId;
     RealtimeMediaSourceSettings m_currentSettings;
-    std::unique_ptr<PlatformAudioData> m_audioBuffer;
 #if USE(AVFOUNDATION)
     size_t m_numberOfFrames { 0 };
 #endif

Modified: trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceCocoa.cpp (261565 => 261566)


--- trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceCocoa.cpp	2020-05-12 17:59:25 UTC (rev 261565)
+++ trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceCocoa.cpp	2020-05-12 18:23:37 UTC (rev 261566)
@@ -41,7 +41,7 @@
 
 namespace WebCore {
 
-static inline CAAudioStreamDescription streamDescription(size_t sampleRate, size_t channelCount)
+static inline AudioStreamBasicDescription streamDescription(size_t sampleRate, size_t channelCount)
 {
     bool isFloat = true;
     bool isBigEndian = false;
@@ -75,19 +75,15 @@
     auto mediaTime = PAL::toMediaTime(startTime);
     m_numberOfFrames += numberOfFrames;
 
-    auto* audioBuffer = m_audioBuffer ? &downcast<WebAudioBufferList>(*m_audioBuffer) : nullptr;
+    AudioStreamBasicDescription newDescription = streamDescription(m_currentSettings.sampleRate(), bus.numberOfChannels());
 
-    auto description = streamDescription(m_currentSettings.sampleRate(), bus.numberOfChannels());
-    if (!audioBuffer || audioBuffer->channelCount() != bus.numberOfChannels()) {
-        m_audioBuffer = makeUnique<WebAudioBufferList>(description, WTF::safeCast<uint32_t>(numberOfFrames));
-        audioBuffer = &downcast<WebAudioBufferList>(*m_audioBuffer);
-    } else
-        audioBuffer->setSampleCount(numberOfFrames);
+    // FIXME: We should do the memory allocation once in MediaStreamAudioSource and resize it according numberOfFrames.
+    WebAudioBufferList audioBufferList { CAAudioStreamDescription(newDescription), WTF::safeCast<uint32_t>(numberOfFrames) };
 
     for (size_t cptr = 0; cptr < bus.numberOfChannels(); ++cptr)
-        copyChannelData(*bus.channel(cptr), *audioBuffer->buffer(cptr), numberOfFrames, muted());
+        copyChannelData(*bus.channel(cptr), *audioBufferList.buffer(cptr), numberOfFrames, muted());
 
-    audioSamplesAvailable(mediaTime, *m_audioBuffer, description, numberOfFrames);
+    audioSamplesAvailable(mediaTime, audioBufferList, CAAudioStreamDescription(newDescription), numberOfFrames);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/audio/cocoa/WebAudioBufferList.cpp (261565 => 261566)


--- trunk/Source/WebCore/platform/audio/cocoa/WebAudioBufferList.cpp	2020-05-12 17:59:25 UTC (rev 261565)
+++ trunk/Source/WebCore/platform/audio/cocoa/WebAudioBufferList.cpp	2020-05-12 18:23:37 UTC (rev 261566)
@@ -33,12 +33,11 @@
 using namespace PAL;
 
 WebAudioBufferList::WebAudioBufferList(const CAAudioStreamDescription& format)
-    : m_bytesPerFrame(format.bytesPerFrame())
-    , m_channelCount(format.numberOfInterleavedChannels())
 {
     // AudioBufferList is a variable-length struct, so create on the heap with a generic new() operator
     // with a custom size, and initialize the struct manually.
     uint32_t bufferCount = format.numberOfChannelStreams();
+    uint32_t channelCount = format.numberOfInterleavedChannels();
 
     uint64_t bufferListSize = offsetof(AudioBufferList, mBuffers) + (sizeof(AudioBuffer) * std::max(1U, bufferCount));
     ASSERT(bufferListSize <= SIZE_MAX);
@@ -48,7 +47,7 @@
     memset(m_canonicalList.get(), 0, m_listBufferSize);
     m_canonicalList->mNumberBuffers = bufferCount;
     for (uint32_t buffer = 0; buffer < bufferCount; ++buffer)
-        m_canonicalList->mBuffers[buffer].mNumberChannels = m_channelCount;
+        m_canonicalList->mBuffers[buffer].mNumberChannels = channelCount;
 
     reset();
 }
@@ -56,19 +55,14 @@
 WebAudioBufferList::WebAudioBufferList(const CAAudioStreamDescription& format, uint32_t sampleCount)
     : WebAudioBufferList(format)
 {
-    if (sampleCount)
-        setSampleCount(sampleCount);
-}
-
-void WebAudioBufferList::setSampleCount(uint32_t sampleCount)
-{
-    uint32_t bufferCount = m_canonicalList->mNumberBuffers;
-    if (!bufferCount || m_sampleCount == sampleCount)
+    if (!sampleCount)
         return;
 
-    m_sampleCount = sampleCount;
-    size_t bytesPerBuffer = m_sampleCount * m_channelCount * m_bytesPerFrame;
-    m_flatBuffer.reserveCapacity(bufferCount * bytesPerBuffer);
+    uint32_t bufferCount = format.numberOfChannelStreams();
+    uint32_t channelCount = format.numberOfInterleavedChannels();
+
+    size_t bytesPerBuffer = sampleCount * channelCount * format.bytesPerFrame();
+    m_flatBuffer.reserveInitialCapacity(bufferCount * bytesPerBuffer);
     auto data = ""
 
     for (uint32_t buffer = 0; buffer < m_canonicalList->mNumberBuffers; ++buffer) {
@@ -83,6 +77,7 @@
 WebAudioBufferList::WebAudioBufferList(const CAAudioStreamDescription& format, CMSampleBufferRef sampleBuffer)
     : WebAudioBufferList(format)
 {
+
     if (!sampleBuffer)
         return;
 

Modified: trunk/Source/WebCore/platform/audio/cocoa/WebAudioBufferList.h (261565 => 261566)


--- trunk/Source/WebCore/platform/audio/cocoa/WebAudioBufferList.h	2020-05-12 17:59:25 UTC (rev 261565)
+++ trunk/Source/WebCore/platform/audio/cocoa/WebAudioBufferList.h	2020-05-12 18:23:37 UTC (rev 261566)
@@ -46,13 +46,11 @@
     WebAudioBufferList(const CAAudioStreamDescription&, CMSampleBufferRef);
 
     void reset();
-    WEBCORE_EXPORT void setSampleCount(uint32_t);
 
     AudioBufferList* list() const { return m_list.get(); }
     operator AudioBufferList&() const { return *m_list; }
 
     uint32_t bufferCount() const;
-    uint32_t channelCount() const { return m_channelCount; }
     AudioBuffer* buffer(uint32_t index) const;
     WTF::IteratorRange<AudioBuffer*> buffers() const;
 
@@ -60,9 +58,6 @@
     Kind kind() const { return Kind::WebAudioBufferList; }
 
     size_t m_listBufferSize { 0 };
-    uint32_t m_bytesPerFrame { 0 };
-    uint32_t m_channelCount { 0 };
-    uint32_t m_sampleCount { 0 };
     std::unique_ptr<AudioBufferList> m_canonicalList;
     std::unique_ptr<AudioBufferList> m_list;
     RetainPtr<CMBlockBufferRef> m_blockBuffer;

Modified: trunk/Source/WebKit/ChangeLog (261565 => 261566)


--- trunk/Source/WebKit/ChangeLog	2020-05-12 17:59:25 UTC (rev 261565)
+++ trunk/Source/WebKit/ChangeLog	2020-05-12 18:23:37 UTC (rev 261566)
@@ -1,3 +1,17 @@
+2020-05-12  Jacob Uphoff  <[email protected]>
+
+        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
+
 2020-05-12  Per Arne Vollan  <[email protected]>
 
         Unreviewed crash fix.

Modified: trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.cpp (261565 => 261566)


--- trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.cpp	2020-05-12 17:59:25 UTC (rev 261565)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.cpp	2020-05-12 18:23:37 UTC (rev 261566)
@@ -138,17 +138,17 @@
     storage.setStorage(memory.releaseNonNull());
     storage.setReadOnly(true);
     m_ringBuffer->allocate(description, numberOfFrames);
-    m_buffer = makeUnique<WebAudioBufferList>(description, numberOfFrames);
 }
 
 void RemoteCaptureSampleManager::RemoteAudio::audioSamplesAvailable(MediaTime time, uint64_t numberOfFrames, uint64_t startFrame, uint64_t endFrame)
 {
-    m_buffer->setSampleCount(numberOfFrames);
+    // FIXME: We should allocate this buffer once and resize it as needed.
+    WebAudioBufferList audioData(m_description, numberOfFrames);
 
     m_ringBuffer->setCurrentFrameBounds(startFrame, endFrame);
-    m_ringBuffer->fetch(m_buffer->list(), numberOfFrames, time.timeValue());
+    m_ringBuffer->fetch(audioData.list(), numberOfFrames, time.timeValue());
 
-    m_source->remoteAudioSamplesAvailable(time, *m_buffer, m_description, numberOfFrames);
+    m_source->remoteAudioSamplesAvailable(time, audioData, m_description, numberOfFrames);
 }
 
 }

Modified: trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.h (261565 => 261566)


--- trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.h	2020-05-12 17:59:25 UTC (rev 261565)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.h	2020-05-12 18:23:37 UTC (rev 261566)
@@ -33,7 +33,6 @@
 #include "SharedMemory.h"
 #include <WebCore/CAAudioStreamDescription.h>
 #include <WebCore/CARingBuffer.h>
-#include <WebCore/WebAudioBufferList.h>
 #include <wtf/HashMap.h>
 #include <wtf/WorkQueue.h>
 
@@ -72,7 +71,6 @@
         Ref<RemoteRealtimeMediaSource> m_source;
         WebCore::CAAudioStreamDescription m_description;
         std::unique_ptr<WebCore::CARingBuffer> m_ringBuffer;
-        std::unique_ptr<WebCore::WebAudioBufferList> m_buffer;
     };
 
     Ref<WorkQueue> m_queue;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to