⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 267530 in webkit


Ignore:
Timestamp:
Sep 24, 2020, 8:11:31 AM (6 years ago)
Author:
youenn@apple.com
Message:

Regression(r265280) Web Audio sources malfunction when disconnected from the audio graph
https://bugs.webkit.org/show_bug.cgi?id=216703
<rdar://problem/69158436>

Reviewed by Eric Carlson.

In case of an audio source that stops producing data, but does not end or mute the track,
we would continuously try to read the data until getting to the end of the data.
When reaching the end of the data, we would return silence and go back in time a little bit
to restart playing with some margin. This allows to read just one chunk of audio until we are back to the end of data.

We fix this by storing the end of the data counter when reaching it.
When trying to pull some more data, we will go back in time a little bit only if some more data was added in the meantime.
Otherwise, we just output silence.

Covered by manual test.

  • platform/audio/mac/AudioSampleDataSource.h:
  • platform/audio/mac/AudioSampleDataSource.mm:

(WebCore::AudioSampleDataSource::pullSamplesInternal):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r267528 r267530  
     12020-09-24  Youenn Fablet  <youenn@apple.com>
     2
     3        Regression(r265280) Web Audio sources malfunction when disconnected from the audio graph
     4        https://bugs.webkit.org/show_bug.cgi?id=216703
     5        <rdar://problem/69158436>
     6
     7        Reviewed by Eric Carlson.
     8
     9        In case of an audio source that stops producing data, but does not end or mute the track,
     10        we would continuously try to read the data until getting to the end of the data.
     11        When reaching the end of the data, we would return silence and go back in time a little bit
     12        to restart playing with some margin. This allows to read just one chunk of audio until we are back to the end of data.
     13
     14        We fix this by storing the end of the data counter when reaching it.
     15        When trying to pull some more data, we will go back in time a little bit only if some more data was added in the meantime.
     16        Otherwise, we just output silence.
     17
     18        Covered by manual test.
     19
     20        * platform/audio/mac/AudioSampleDataSource.h:
     21        * platform/audio/mac/AudioSampleDataSource.mm:
     22        (WebCore::AudioSampleDataSource::pullSamplesInternal):
     23
    1242020-09-24  Antti Koivisto  <antti@apple.com>
    225
  • trunk/Source/WebCore/platform/audio/mac/AudioSampleDataSource.h

    r265280 r267530  
    115115    bool m_muted { false };
    116116    bool m_shouldComputeOutputSampleOffset { true };
     117    uint64_t m_endFrameWhenNotEnoughData { 0 };
    117118
    118119#if !RELEASE_LOG_DISABLED
  • trunk/Source/WebCore/platform/audio/mac/AudioSampleDataSource.mm

    r265280 r267530  
    233233    if (m_shouldComputeOutputSampleOffset) {
    234234        uint64_t buffered = endFrame - startFrame;
    235         if (buffered < sampleCount * 2) {
     235        if (buffered < sampleCount * 2 || (m_endFrameWhenNotEnoughData && m_endFrameWhenNotEnoughData == endFrame)) {
    236236            AudioSampleBufferList::zeroABL(buffer, byteCount);
    237237            sampleCount = 0;
     
    240240
    241241        m_shouldComputeOutputSampleOffset = false;
     242        m_endFrameWhenNotEnoughData = 0;
    242243
    243244        m_outputSampleOffset = (endFrame - sampleCount) - timeStamp;
     
    258259            // We are out of the window, let's restart the offset computation.
    259260            m_shouldComputeOutputSampleOffset = true;
     261
     262            if (timeStamp >= endFrame)
     263                m_endFrameWhenNotEnoughData = endFrame;
    260264        } else {
    261265            // We are too close from endFrame, let's back up a little bit.
Note: See TracChangeset for help on using the changeset viewer.