[MSE][GStreamer] Introduce AbortableTaskQueue
authoraboya@igalia.com <aboya@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Nov 2018 14:40:26 +0000 (14:40 +0000)
committeraboya@igalia.com <aboya@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Nov 2018 14:40:26 +0000 (14:40 +0000)
commitcbf3219af4564d70273d6d03f457057efbdf92d8
tree7ea91553fa42dd9d1c007a36c4e047c1ccd10760
parent3b9208b9f47b00d038f303eab4fee63e41e1bff6
[MSE][GStreamer] Introduce AbortableTaskQueue
https://bugs.webkit.org/show_bug.cgi?id=190902

Reviewed by Xabier Rodriguez-Calvar.

Source/WebCore:

A new synchronization primitive is introduced: AbortableTaskQueue,
which allows to send work to the main thread from a background thread
with the option to perform two-phase cancellation (startAborting() and
finishAborting()).

This new primitive has been used to overhaul GstBus messaging in
AppendPipeline. A lot of code made redundant has been deleted in the
process and lots of internal functions were now able to be made
private. As part of the refactor all glib signals in AppendPipeline
now use lambdas. All usages of WTF::isMainThread() in AppendPipeline
have been replaced by isMainThread() for consistency with the rest of
WebKit.

Two-phase cancellation is still not used in AppendPipeline as of this
patch, but it will be used in a future patch that makes use of
GStreamer flushes to implement correct MSE abort semantics. There are
unit tests to ensure it works correctly, even if it's still not used.

* WebCore.xcodeproj/project.pbxproj:
* platform/AbortableTaskQueue.h: Added.
* platform/graphics/gstreamer/mse/AppendPipeline.cpp:
(WebCore::AppendPipeline::dumpAppendState):
(WebCore::AppendPipeline::AppendPipeline):
(WebCore::AppendPipeline::~AppendPipeline):
(WebCore::AppendPipeline::appsrcEndOfAppendCheckerProbe):
(WebCore::AppendPipeline::handleAppsinkNewSampleFromAnyThread):
(WebCore::AppendPipeline::connectDemuxerSrcPadToAppsinkFromAnyThread):
* platform/graphics/gstreamer/mse/AppendPipeline.h:
(WebCore::AppendPipeline::sourceBufferPrivate):
(WebCore::AppendPipeline::appsinkCaps):
(WebCore::AppendPipeline::track):
(WebCore::AppendPipeline::demuxerSrcPadCaps):
(WebCore::AppendPipeline::playerPrivate):

Tools:

Tests for AbortableTaskQueue are included.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/PlatformGTK.cmake:
* TestWebKitAPI/Tests/WebCore/AbortableTaskQueue.cpp: Added.
(TestWebKitAPI::TEST):
(TestWebKitAPI::FancyResponse::FancyResponse):
(TestWebKitAPI::FancyResponse::operator=):
(TestWebKitAPI::DeterministicScheduler::DeterministicScheduler):
(TestWebKitAPI::DeterministicScheduler::ThreadContext::ThreadContext):
(TestWebKitAPI::DeterministicScheduler::ThreadContext::waitMyTurn):
(TestWebKitAPI::DeterministicScheduler::ThreadContext::yieldToThread):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238084 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/AbortableTaskQueue.h [new file with mode: 0644]
Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp
Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.h
Tools/ChangeLog
Tools/TestWebKitAPI/PlatformGTK.cmake
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebCore/AbortableTaskQueue.cpp [new file with mode: 0644]