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

Side by Side Diff: chromecast/media/cma/backend/media_pipeline_backend_manager.h

Issue 1855633002: Revert of [chromecast] Pass media task runner to MediaPipelineBackendManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_PIPELINE_BACKEND_MANAGER_H_ 5 #ifndef CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_PIPELINE_BACKEND_MANAGER_H_
6 #define CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_PIPELINE_BACKEND_MANAGER_H_ 6 #define CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_PIPELINE_BACKEND_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
14 #include "chromecast/public/media/media_pipeline_backend.h" 13 #include "chromecast/public/media/media_pipeline_backend.h"
15 #include "chromecast/public/media/media_pipeline_device_params.h" 14 #include "chromecast/public/media/media_pipeline_device_params.h"
16 15
17 namespace base { 16 namespace base {
18 class SingleThreadTaskRunner; 17 template <typename T>
18 struct DefaultLazyInstanceTraits;
19 } // namespace base 19 } // namespace base
20 20
21 namespace chromecast { 21 namespace chromecast {
22 namespace media { 22 namespace media {
23 23
24 // This class manages created media pipelines, and provides volume control by 24 // This class manages created media pipelines, and provides volume control by
25 // stream type. 25 // stream type.
26 // All functions in this class should be called on the media thread. 26 // All functions in this class should be called on the media thread.
27 class MediaPipelineBackendManager { 27 class MediaPipelineBackendManager {
28 public: 28 public:
29 explicit MediaPipelineBackendManager(
30 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner);
31 ~MediaPipelineBackendManager();
32
33 // Create media pipeline backend. 29 // Create media pipeline backend.
34 scoped_ptr<MediaPipelineBackend> CreateMediaPipelineBackend( 30 static MediaPipelineBackend* CreateMediaPipelineBackend(
35 const MediaPipelineDeviceParams& params); 31 const MediaPipelineDeviceParams& params);
36 32
37 // Create media pipeline backend with a specific stream_type. 33 // Create media pipeline backend with a specific stream_type.
38 scoped_ptr<MediaPipelineBackend> CreateMediaPipelineBackend( 34 static MediaPipelineBackend* CreateMediaPipelineBackend(
39 const MediaPipelineDeviceParams& params, 35 const MediaPipelineDeviceParams& params,
40 int stream_type); 36 int stream_type);
41 37
42 // Internal clean up when a new media pipeline backend is destroyed. 38 // Internal clean up when a new media pipeline backend is destroyed.
43 void OnMediaPipelineBackendDestroyed(const MediaPipelineBackend* backend); 39 static void OnMediaPipelineBackendDestroyed(
40 const MediaPipelineBackend* backend);
44 41
45 // Sets the relative volume for a specified stream type, 42 // Sets the relative volume for a specified stream type,
46 // with range [0.0, 1.0] inclusive. If |multiplier| is outside the 43 // with range [0.0, 1.0] inclusive. If |multiplier| is outside the
47 // range [0.0, 1.0], it is clamped to that range. 44 // range [0.0, 1.0], it is clamped to that range.
48 // TODO(tianyuwang): change stream_type to use a enum. 45 // TODO(tianyuwang): change stream_type to use a enum.
49 void SetVolumeMultiplier(int stream_type, float volume); 46 static void SetVolumeMultiplier(int stream_type, float volume);
50 47
51 private: 48 private:
49 friend struct base::DefaultLazyInstanceTraits<MediaPipelineBackendManager>;
50
52 // Returns a pointer to a singleton instance of the 51 // Returns a pointer to a singleton instance of the
53 // MediaPipelineBackendManager. 52 // MediaPipelineBackendManager.
54 static MediaPipelineBackendManager* Get(); 53 static MediaPipelineBackendManager* Get();
55 54
55 MediaPipelineBackendManager();
56 ~MediaPipelineBackendManager();
57
56 float GetVolumeMultiplier(int stream_type); 58 float GetVolumeMultiplier(int stream_type);
57 59
58 const scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
59
60 // A vector that stores all of the existing media_pipeline_backends_. 60 // A vector that stores all of the existing media_pipeline_backends_.
61 std::vector<MediaPipelineBackend*> media_pipeline_backends_; 61 std::vector<MediaPipelineBackend*> media_pipeline_backends_;
62 62
63 // Volume multiplier for each type of audio streams. 63 // Volume multiplier for each type of audio streams.
64 std::map<int, float> volume_by_stream_type_; 64 std::map<int, float> volume_by_stream_type_;
65 65
66 DISALLOW_COPY_AND_ASSIGN(MediaPipelineBackendManager); 66 DISALLOW_COPY_AND_ASSIGN(MediaPipelineBackendManager);
67 }; 67 };
68 68
69 } // namespace media 69 } // namespace media
70 } // namespace chromecast 70 } // namespace chromecast
71 71
72 #endif // CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_PIPELINE_BACKEND_MANAGER_H_ 72 #endif // CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_PIPELINE_BACKEND_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698