OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ | 5 #ifndef MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ |
6 #define MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ | 6 #define MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "media/base/audio_converter.h" | 12 #include "media/base/audio_converter.h" |
13 #include "media/base/audio_renderer_sink.h" | 13 #include "media/base/audio_renderer_sink.h" |
14 #include "media/base/output_device.h" | |
14 #include "url/origin.h" | 15 #include "url/origin.h" |
15 | 16 |
16 namespace media { | 17 namespace media { |
17 | 18 |
18 class AudioRendererMixer; | 19 class AudioRendererMixer; |
19 | 20 |
20 class MEDIA_EXPORT AudioRendererMixerInput | 21 class MEDIA_EXPORT AudioRendererMixerInput |
21 : NON_EXPORTED_BASE(public RestartableAudioRendererSink), | 22 : NON_EXPORTED_BASE(public RestartableAudioRendererSink), |
22 NON_EXPORTED_BASE(public OutputDevice), | 23 NON_EXPORTED_BASE(public OutputDevice), |
23 public AudioConverter::InputCallback { | 24 public AudioConverter::InputCallback { |
24 public: | 25 public: |
25 typedef base::Callback<AudioRendererMixer*(const AudioParameters& params, | 26 typedef base::Callback<AudioRendererMixer*(const AudioParameters& params, |
26 const std::string& device_id, | 27 const std::string& device_id, |
27 const url::Origin& security_origin, | 28 const url::Origin& security_origin, |
28 OutputDeviceStatus* device_status)> | 29 OutputDeviceStatus* device_status)> |
29 GetMixerCB; | 30 GetMixerCB; |
30 typedef base::Callback<void(const AudioParameters& params, | 31 typedef base::Callback<void(const AudioParameters& params, |
31 const std::string& device_id, | 32 const std::string& device_id, |
32 const url::Origin& security_origin)> | 33 const url::Origin& security_origin)> |
33 RemoveMixerCB; | 34 RemoveMixerCB; |
34 | 35 |
36 typedef base::Callback<AudioParameters(const std::string& device_id, | |
37 const url::Origin& security_origin)> | |
38 GetHWParamsCB; | |
Henrik Grunell
2016/02/11 12:01:26
Name it "GetHardwareParamsCallback".
o1ka
2016/02/11 17:18:23
Done.
| |
39 | |
35 AudioRendererMixerInput(const GetMixerCB& get_mixer_cb, | 40 AudioRendererMixerInput(const GetMixerCB& get_mixer_cb, |
36 const RemoveMixerCB& remove_mixer_cb, | 41 const RemoveMixerCB& remove_mixer_cb, |
42 const GetHWParamsCB& get_hw_params_cb, | |
37 const std::string& device_id, | 43 const std::string& device_id, |
38 const url::Origin& security_origin); | 44 const url::Origin& security_origin); |
39 | 45 |
40 // RestartableAudioRendererSink implementation. | 46 // RestartableAudioRendererSink implementation. |
41 void Start() override; | 47 void Start() override; |
42 void Stop() override; | 48 void Stop() override; |
43 void Play() override; | 49 void Play() override; |
44 void Pause() override; | 50 void Pause() override; |
45 bool SetVolume(double volume) override; | 51 bool SetVolume(double volume) override; |
46 OutputDevice* GetOutputDevice() override; | 52 OutputDevice* GetOutputDevice() override; |
47 void Initialize(const AudioParameters& params, | 53 void Initialize(const AudioParameters& params, |
48 AudioRendererSink::RenderCallback* renderer) override; | 54 AudioRendererSink::RenderCallback* renderer) override; |
49 | 55 |
50 // OutputDevice implementation. | 56 // OutputDevice implementation. |
51 void SwitchOutputDevice(const std::string& device_id, | 57 void SwitchOutputDevice(const std::string& device_id, |
52 const url::Origin& security_origin, | 58 const url::Origin& security_origin, |
53 const SwitchOutputDeviceCB& callback) override; | 59 const SwitchOutputDeviceCB& callback) override; |
54 AudioParameters GetOutputParameters() override; | 60 AudioParameters GetOutputParameters() override; |
55 OutputDeviceStatus GetDeviceStatus() override; | 61 OutputDeviceStatus GetDeviceStatus() override; |
56 | 62 |
57 // Called by AudioRendererMixer when an error occurs. | 63 // Called by AudioRendererMixer when an error occurs. |
58 void OnRenderError(); | 64 void OnRenderError(); |
59 | 65 |
60 protected: | 66 protected: |
61 ~AudioRendererMixerInput() override; | 67 ~AudioRendererMixerInput() override; |
62 | 68 |
63 private: | 69 private: |
64 friend class AudioRendererMixerInputTest; | 70 friend class AudioRendererMixerInputTest; |
65 | 71 |
66 bool initialized_; | 72 bool started_; |
67 bool playing_; | 73 bool playing_; |
68 double volume_; | 74 double volume_; |
69 | 75 |
70 // AudioConverter::InputCallback implementation. | 76 // AudioConverter::InputCallback implementation. |
71 double ProvideInput(AudioBus* audio_bus, | 77 double ProvideInput(AudioBus* audio_bus, |
72 base::TimeDelta buffer_delay) override; | 78 base::TimeDelta buffer_delay) override; |
73 | 79 |
74 // Callbacks provided during construction which allow AudioRendererMixerInput | 80 // Callbacks provided during construction which allow AudioRendererMixerInput |
75 // to retrieve a mixer during Initialize() and notify when it's done with it. | 81 // to retrieve a mixer during Initialize() and notify when it's done with it. |
76 const GetMixerCB get_mixer_cb_; | 82 const GetMixerCB get_mixer_cb_; |
77 const RemoveMixerCB remove_mixer_cb_; | 83 const RemoveMixerCB remove_mixer_cb_; |
78 | 84 |
85 // Callbacks provided during construction which allows AudioRendererMixerInput | |
86 // to access hardware output parameters when it is detached from the mixer. | |
87 const GetHWParamsCB get_hw_params_cb_; | |
Henrik Grunell
2016/02/11 12:01:26
Same here, spell out the abbreviations in the memb
o1ka
2016/02/11 17:18:23
Done.
| |
88 | |
79 // AudioParameters received during Initialize(). | 89 // AudioParameters received during Initialize(). |
80 AudioParameters params_; | 90 AudioParameters params_; |
81 | 91 |
82 // ID of hardware device to use | 92 // ID of hardware device to use |
83 std::string device_id_; | 93 std::string device_id_; |
84 url::Origin security_origin_; | 94 url::Origin security_origin_; |
85 | 95 |
86 // AudioRendererMixer provided through |get_mixer_cb_| during Initialize(), | 96 // AudioRendererMixer provided through |get_mixer_cb_| during Initialize(), |
87 // guaranteed to live (at least) until |remove_mixer_cb_| is called. | 97 // guaranteed to live (at least) until |remove_mixer_cb_| is called. |
88 AudioRendererMixer* mixer_; | 98 AudioRendererMixer* mixer_; |
89 | 99 |
90 // Source of audio data which is provided to the mixer. | 100 // Source of audio data which is provided to the mixer. |
91 AudioRendererSink::RenderCallback* callback_; | 101 AudioRendererSink::RenderCallback* callback_; |
92 | 102 |
93 // Error callback for handing to AudioRendererMixer. | 103 // Error callback for handing to AudioRendererMixer. |
94 const base::Closure error_cb_; | 104 const base::Closure error_cb_; |
95 | 105 |
96 // Pending switch-device callback, in case SwitchOutputDevice() is invoked | 106 // Pending switch-device callback, in case SwitchOutputDevice() is invoked |
97 // before Start() | 107 // before Start() |
98 SwitchOutputDeviceCB pending_switch_callback_; | 108 SwitchOutputDeviceCB pending_switch_callback_; |
99 std::string pending_switch_device_id_; | 109 std::string pending_switch_device_id_; |
100 url::Origin pending_switch_security_origin_; | 110 url::Origin pending_switch_security_origin_; |
101 | 111 |
102 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInput); | 112 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInput); |
103 }; | 113 }; |
104 | 114 |
105 } // namespace media | 115 } // namespace media |
106 | 116 |
107 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ | 117 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ |
OLD | NEW |