Changeset 275510 in webkit


Ignore:
Timestamp:
Apr 6, 2021 6:24:32 AM (3 years ago)
Author:
commit-queue@webkit.org
Message:

[GStreamer][MediaStream] AudioSource triggering critical warnings
https://bugs.webkit.org/show_bug.cgi?id=224180

Patch by Philippe Normand <pnormand@igalia.com> on 2021-04-06
Reviewed by Xabier Rodriguez-Calvar.

Keep track of audio channel offsets and store them as metadata in audio buffers. This is
used by downstream elements such as the audio convert elements.

  • Modules/webaudio/MediaStreamAudioSourceGStreamer.cpp:

(WebCore::copyBusData):
(WebCore::MediaStreamAudioSource::consumeAudio):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r275509 r275510  
     12021-04-06  Philippe Normand  <pnormand@igalia.com>
     2
     3        [GStreamer][MediaStream] AudioSource triggering critical warnings
     4        https://bugs.webkit.org/show_bug.cgi?id=224180
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        Keep track of audio channel offsets and store them as metadata in audio buffers. This is
     9        used by downstream elements such as the audio convert elements.
     10
     11        * Modules/webaudio/MediaStreamAudioSourceGStreamer.cpp:
     12        (WebCore::copyBusData):
     13        (WebCore::MediaStreamAudioSource::consumeAudio):
     14
    1152021-04-06  Antti Koivisto  <antti@apple.com>
    216
  • trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceGStreamer.cpp

    r269849 r275510  
    3030namespace WebCore {
    3131
    32 static void copyBusData(AudioBus& bus, GstBuffer* buffer, bool isMuted)
     32static Vector<size_t> copyBusData(AudioBus& bus, GstBuffer* buffer, bool isMuted)
    3333{
     34    Vector<size_t> offsets;
    3435    GstMappedBuffer mappedBuffer(buffer, GST_MAP_WRITE);
    3536    if (isMuted) {
    3637        memset(mappedBuffer.data(), 0, mappedBuffer.size());
    37         return;
     38        return offsets;
    3839    }
    3940
     41    DisableMallocRestrictionsForCurrentThreadScope disableMallocRestrictions;
     42    offsets.reserveInitialCapacity(sizeof(size_t) * bus.numberOfChannels());
    4043    size_t size = mappedBuffer.size() / bus.numberOfChannels();
    4144    for (size_t channelIndex = 0; channelIndex < bus.numberOfChannels(); ++channelIndex) {
    42         AudioChannel& channel = *bus.channel(channelIndex);
    43         float* destination = reinterpret_cast<float*>(mappedBuffer.data() + (channelIndex * size));
    44         memcpy(destination, channel.data(), size);
     45        const auto& channel = *bus.channel(channelIndex);
     46        auto offset = reinterpret_cast<size_t>(channelIndex * size);
     47        memcpy(reinterpret_cast<float*>(mappedBuffer.data() + offset), channel.data(), sizeof(float) * channel.length());
     48        offsets.uncheckedAppend(offset);
    4549    }
     50    return offsets;
    4651}
    4752
     
    6368    auto caps = adoptGRef(gst_audio_info_to_caps(&info));
    6469    auto buffer = adoptGRef(gst_buffer_new_allocate(nullptr, size, nullptr));
    65     copyBusData(bus, buffer.get(), muted());
     70    auto offsets = copyBusData(bus, buffer.get(), muted());
     71#if GST_CHECK_VERSION(1, 16, 0)
     72    gst_buffer_add_audio_meta(buffer.get(), &info, numberOfFrames, offsets.data());
     73#else
     74    UNUSED_VARIABLE(offsets);
     75#endif
    6676    auto sample = adoptGRef(gst_sample_new(buffer.get(), caps.get(), nullptr, nullptr));
    6777    GStreamerAudioData audioBuffer(WTFMove(sample), info);
Note: See TracChangeset for help on using the changeset viewer.