diff options
Diffstat (limited to 'chromecast/media/base')
-rw-r--r-- | chromecast/media/base/BUILD.gn | 4 | ||||
-rw-r--r-- | chromecast/media/base/cast_media_default.cc | 19 |
2 files changed, 23 insertions, 0 deletions
diff --git a/chromecast/media/base/BUILD.gn b/chromecast/media/base/BUILD.gn index 5371726..85cfcf3 100644 --- a/chromecast/media/base/BUILD.gn +++ b/chromecast/media/base/BUILD.gn @@ -100,7 +100,9 @@ source_set("libcast_media_1.0_default_core") { ] deps = [ + "//base", "//build/config/sanitizers:deps", + "//chromecast/base", "//chromecast/media/cma/backend", ] } @@ -121,7 +123,9 @@ shared_library("libcast_media_1.0_default") { ] deps = [ + "//base", "//build/config/sanitizers:deps", + "//chromecast/base", "//chromecast/media/cma/backend", ] } diff --git a/chromecast/media/base/cast_media_default.cc b/chromecast/media/base/cast_media_default.cc index 33f9590..dbf4867 100644 --- a/chromecast/media/base/cast_media_default.cc +++ b/chromecast/media/base/cast_media_default.cc @@ -2,10 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/memory/scoped_ptr.h" #include "build/build_config.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" +#include "chromecast/base/task_runner_impl.h" #include "chromecast/media/cma/backend/media_pipeline_backend_default.h" #include "chromecast/public/cast_media_shlib.h" #include "chromecast/public/graphics_types.h" +#include "chromecast/public/media/media_pipeline_device_params.h" #include "chromecast/public/media_codec_support_shlib.h" #include "chromecast/public/video_plane.h" @@ -22,6 +27,7 @@ class DefaultVideoPlane : public VideoPlane { }; DefaultVideoPlane* g_video_plane = nullptr; +base::ThreadTaskRunnerHandle* g_thread_task_runner_handle = nullptr; } // namespace @@ -32,6 +38,8 @@ void CastMediaShlib::Initialize(const std::vector<std::string>& argv) { void CastMediaShlib::Finalize() { delete g_video_plane; g_video_plane = nullptr; + delete g_thread_task_runner_handle; + g_thread_task_runner_handle = nullptr; } VideoPlane* CastMediaShlib::GetVideoPlane() { @@ -40,6 +48,17 @@ VideoPlane* CastMediaShlib::GetVideoPlane() { MediaPipelineBackend* CastMediaShlib::CreateMediaPipelineBackend( const MediaPipelineDeviceParams& params) { + // Set up the static reference in base::ThreadTaskRunnerHandle::Get + // for the media thread in this shared library. We can extract the + // SingleThreadTaskRunner passed in from cast_shell for this. + if (!base::ThreadTaskRunnerHandle::IsSet()) { + DCHECK(!g_thread_task_runner_handle); + const scoped_refptr<base::SingleThreadTaskRunner> task_runner = + static_cast<TaskRunnerImpl*>(params.task_runner)->runner(); + DCHECK(task_runner->BelongsToCurrentThread()); + g_thread_task_runner_handle = new base::ThreadTaskRunnerHandle(task_runner); + } + return new MediaPipelineBackendDefault(); } |