Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Source/WebCore/Modules/mediasource/SourceBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ SourceBuffer::SourceBuffer(Ref<SourceBufferPrivate>&& sourceBufferPrivate, Media

m_private->setClient(this);
m_private->setIsAttached(true);

if (document().quirks().shouldBypassAudioFlushOnSampleReplacement()) {
m_private->setShouldBypassAudioFlushOnSampleReplacement(true);
}
}

SourceBuffer::~SourceBuffer()
Expand Down
18 changes: 18 additions & 0 deletions Source/WebCore/page/Quirks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1490,4 +1490,22 @@ bool Quirks::shouldDisableLazyImageLoadingQuirk() const
return m_shouldDisableLazyImageLoadingQuirk.value();
}

#if ENABLE(MEDIA_SOURCE)
bool Quirks::shouldBypassAudioFlushOnSampleReplacement() const
{
if (!needsQuirks())
return false;

if (m_shouldBypassAudioFlushOnSampleReplacementQuirk)
return m_shouldBypassAudioFlushOnSampleReplacementQuirk.value();

auto domain = m_document->securityOrigin().domain().convertToASCIILowercase();

m_shouldBypassAudioFlushOnSampleReplacementQuirk =
(domain.endsWith(".spotify.com"_s) || domain == "tv.scdn.co"_s);

return m_shouldBypassAudioFlushOnSampleReplacementQuirk.value();
}
#endif

}
8 changes: 8 additions & 0 deletions Source/WebCore/page/Quirks.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ class Quirks {

bool shouldDisableLazyImageLoadingQuirk() const;

#if ENABLE(MEDIA_SOURCE)
bool shouldBypassAudioFlushOnSampleReplacement() const;
#endif

private:
bool needsQuirks() const;

Expand Down Expand Up @@ -217,6 +221,10 @@ class Quirks {
mutable std::optional<bool> m_needsVideoShouldMaintainAspectRatioQuirk;
mutable std::optional<bool> m_shouldExposeShowModalDialog;
mutable std::optional<bool> m_shouldDisableLazyImageLoadingQuirk;
#if ENABLE(MEDIA_SOURCE)
mutable std::optional<bool> m_shouldBypassAudioFlushOnSampleReplacementQuirk;
#endif

};

} // namespace WebCore
2 changes: 1 addition & 1 deletion Source/WebCore/platform/graphics/SourceBufferPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ void SourceBufferPrivate::didReceiveSample(Ref<MediaSample>&& originalSample)
// Only force the TrackBuffer to re-enqueue if the removed ranges overlap with enqueued and possibly
// not yet displayed samples.
MediaTime currentTime = currentMediaTime();
if (trackBuffer.highestEnqueuedPresentationTime().isValid() && currentTime < trackBuffer.highestEnqueuedPresentationTime()) {
if (trackBuffer.highestEnqueuedPresentationTime().isValid() && currentTime < trackBuffer.highestEnqueuedPresentationTime() && (!hasAudio() || !m_shouldBypassAudioFlushOnSampleReplacement)) {
PlatformTimeRanges possiblyEnqueuedRanges(currentTime, trackBuffer.highestEnqueuedPresentationTime());
possiblyEnqueuedRanges.intersectWith(erasedRanges);
if (possiblyEnqueuedRanges.length())
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/platform/graphics/SourceBufferPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class SourceBufferPrivate
virtual const void* sourceBufferLogIdentifier() = 0;
#endif

void setShouldBypassAudioFlushOnSampleReplacement(bool flag) { m_shouldBypassAudioFlushOnSampleReplacement = flag; }
protected:
// The following method should never be called directly and be overridden instead.
WEBCORE_EXPORT virtual void append(Vector<unsigned char>&&);
Expand Down Expand Up @@ -193,6 +194,7 @@ class SourceBufferPrivate

bool m_isMediaSourceEnded { false };
RefPtr<TimeRanges> m_buffered;
bool m_shouldBypassAudioFlushOnSampleReplacement { false };
};

} // namespace WebCore
Expand Down