Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: chromecast/browser/cast_browser_main_parts.cc

Issue 2811293003: [Chromecast] Initialize media_resource_tracker with media_thread. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromecast/browser/cast_browser_main_parts.h" 5 #include "chromecast/browser/cast_browser_main_parts.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } 310 }
311 311
312 scoped_refptr<base::SingleThreadTaskRunner> 312 scoped_refptr<base::SingleThreadTaskRunner>
313 CastBrowserMainParts::GetMediaTaskRunner() { 313 CastBrowserMainParts::GetMediaTaskRunner() {
314 #if BUILDFLAG(IS_CAST_USING_CMA_BACKEND) 314 #if BUILDFLAG(IS_CAST_USING_CMA_BACKEND)
315 if (!media_thread_) { 315 if (!media_thread_) {
316 media_thread_.reset(new base::Thread("CastMediaThread")); 316 media_thread_.reset(new base::Thread("CastMediaThread"));
317 base::Thread::Options options; 317 base::Thread::Options options;
318 options.priority = base::ThreadPriority::REALTIME_AUDIO; 318 options.priority = base::ThreadPriority::REALTIME_AUDIO;
319 CHECK(media_thread_->StartWithOptions(options)); 319 CHECK(media_thread_->StartWithOptions(options));
320 // Start the media_resource_tracker as soon as the media thread is created.
321 // There are services that run on the media thread that depend on it,
322 // and we want to initialize it with the correct task runner before any
323 // tasks that might use it are posted to the media thread.
324 media_resource_tracker_ = new media::MediaResourceTracker(
325 base::ThreadTaskRunnerHandle::Get(), media_thread_->task_runner());
320 } 326 }
321 return media_thread_->task_runner(); 327 return media_thread_->task_runner();
322 #else 328 #else
323 return nullptr; 329 return nullptr;
324 #endif // BUILDFLAG(IS_CAST_USING_CMA_BACKEND) 330 #endif // BUILDFLAG(IS_CAST_USING_CMA_BACKEND)
325 } 331 }
326 332
327 #if BUILDFLAG(IS_CAST_USING_CMA_BACKEND) 333 #if BUILDFLAG(IS_CAST_USING_CMA_BACKEND)
328 media::MediaResourceTracker* CastBrowserMainParts::media_resource_tracker() { 334 media::MediaResourceTracker* CastBrowserMainParts::media_resource_tracker() {
329 if (!media_resource_tracker_) { 335 DCHECK(media_thread_);
330 media_resource_tracker_ = new media::MediaResourceTracker(
331 base::ThreadTaskRunnerHandle::Get(), GetMediaTaskRunner());
332 }
333 return media_resource_tracker_; 336 return media_resource_tracker_;
334 } 337 }
335 338
336 media::MediaPipelineBackendManager* 339 media::MediaPipelineBackendManager*
337 CastBrowserMainParts::media_pipeline_backend_manager() { 340 CastBrowserMainParts::media_pipeline_backend_manager() {
338 if (!media_pipeline_backend_manager_) { 341 if (!media_pipeline_backend_manager_) {
339 media_pipeline_backend_manager_.reset( 342 media_pipeline_backend_manager_.reset(
340 new media::MediaPipelineBackendManager(GetMediaTaskRunner())); 343 new media::MediaPipelineBackendManager(GetMediaTaskRunner()));
341 } 344 }
342 return media_pipeline_backend_manager_.get(); 345 return media_pipeline_backend_manager_.get();
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 564
562 void CastBrowserMainParts::PostDestroyThreads() { 565 void CastBrowserMainParts::PostDestroyThreads() {
563 #if !defined(OS_ANDROID) 566 #if !defined(OS_ANDROID)
564 media_resource_tracker_->FinalizeAndDestroy(); 567 media_resource_tracker_->FinalizeAndDestroy();
565 media_resource_tracker_ = nullptr; 568 media_resource_tracker_ = nullptr;
566 #endif 569 #endif
567 } 570 }
568 571
569 } // namespace shell 572 } // namespace shell
570 } // namespace chromecast 573 } // namespace chromecast
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698