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

Changeset 267686 in webkit


Ignore:
Timestamp:
Sep 27, 2020, 1:00:50 PM (6 years ago)
Author:
Alan Coon
Message:

Cherry-pick r267530. rdar://problem/69594070

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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267530 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-610-branch/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-610-branch/Source/WebCore/ChangeLog

    r267682 r267686  
     12020-09-27  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r267530. rdar://problem/69594070
     4
     5    Regression(r265280) Web Audio sources malfunction when disconnected from the audio graph
     6    https://bugs.webkit.org/show_bug.cgi?id=216703
     7    <rdar://problem/69158436>
     8   
     9    Reviewed by Eric Carlson.
     10   
     11    In case of an audio source that stops producing data, but does not end or mute the track,
     12    we would continuously try to read the data until getting to the end of the data.
     13    When reaching the end of the data, we would return silence and go back in time a little bit
     14    to restart playing with some margin. This allows to read just one chunk of audio until we are back to the end of data.
     15   
     16    We fix this by storing the end of the data counter when reaching it.
     17    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.
     18    Otherwise, we just output silence.
     19   
     20    Covered by manual test.
     21   
     22    * platform/audio/mac/AudioSampleDataSource.h:
     23    * platform/audio/mac/AudioSampleDataSource.mm:
     24    (WebCore::AudioSampleDataSource::pullSamplesInternal):
     25   
     26   
     27    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     28
     29    2020-09-24  Youenn Fablet  <youenn@apple.com>
     30
     31            Regression(r265280) Web Audio sources malfunction when disconnected from the audio graph
     32            https://bugs.webkit.org/show_bug.cgi?id=216703
     33            <rdar://problem/69158436>
     34
     35            Reviewed by Eric Carlson.
     36
     37            In case of an audio source that stops producing data, but does not end or mute the track,
     38            we would continuously try to read the data until getting to the end of the data.
     39            When reaching the end of the data, we would return silence and go back in time a little bit
     40            to restart playing with some margin. This allows to read just one chunk of audio until we are back to the end of data.
     41
     42            We fix this by storing the end of the data counter when reaching it.
     43            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.
     44            Otherwise, we just output silence.
     45
     46            Covered by manual test.
     47
     48            * platform/audio/mac/AudioSampleDataSource.h:
     49            * platform/audio/mac/AudioSampleDataSource.mm:
     50            (WebCore::AudioSampleDataSource::pullSamplesInternal):
     51
    1522020-09-27  Alan Coon  <alancoon@apple.com>
    253
  • branches/safari-610-branch/Source/WebCore/platform/audio/mac/AudioSampleDataSource.h

    r265280 r267686  
    115115    bool m_muted { false };
    116116    bool m_shouldComputeOutputSampleOffset { true };
     117    uint64_t m_endFrameWhenNotEnoughData { 0 };
    117118
    118119#if !RELEASE_LOG_DISABLED
  • branches/safari-610-branch/Source/WebCore/platform/audio/mac/AudioSampleDataSource.mm

    r265280 r267686  
    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.