Chromium Code Reviews| 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 CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ | 6 #define CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 15 #include "media/audio/audio_manager_base.h" | |
| 15 #include "media/audio/audio_parameters.h" | 16 #include "media/audio/audio_parameters.h" |
| 16 #include "media/base/output_device.h" | 17 #include "media/base/output_device.h" |
| 17 #include "url/origin.h" | 18 #include "url/origin.h" |
| 18 | 19 |
| 19 namespace media { | 20 namespace media { |
| 20 class AudioHardwareConfig; | 21 class AudioHardwareConfig; |
| 21 class AudioRendererMixer; | 22 class AudioRendererMixer; |
| 22 class AudioRendererMixerInput; | 23 class AudioRendererMixerInput; |
| 23 class AudioRendererSink; | 24 class AudioRendererSink; |
| 24 } | 25 } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 44 ~AudioRendererMixerManager(); | 45 ~AudioRendererMixerManager(); |
| 45 | 46 |
| 46 // Creates an AudioRendererMixerInput with the proper callbacks necessary to | 47 // Creates an AudioRendererMixerInput with the proper callbacks necessary to |
| 47 // retrieve an AudioRendererMixer instance from AudioRendererMixerManager. | 48 // retrieve an AudioRendererMixer instance from AudioRendererMixerManager. |
| 48 // |source_render_frame_id| refers to the RenderFrame containing the entity | 49 // |source_render_frame_id| refers to the RenderFrame containing the entity |
| 49 // rendering the audio. Caller must ensure AudioRendererMixerManager outlives | 50 // rendering the audio. Caller must ensure AudioRendererMixerManager outlives |
| 50 // the returned input. |device_id| and |security_origin| identify the output | 51 // the returned input. |device_id| and |security_origin| identify the output |
| 51 // device to use | 52 // device to use |
| 52 media::AudioRendererMixerInput* CreateInput( | 53 media::AudioRendererMixerInput* CreateInput( |
| 53 int source_render_frame_id, | 54 int source_render_frame_id, |
| 55 int session_id, | |
|
Henrik Grunell
2016/03/08 21:09:57
Is |session_id| optional or compulsory? Seems like
o1ka
2016/04/05 15:13:38
Done.
| |
| 54 const std::string& device_id, | 56 const std::string& device_id, |
| 55 const url::Origin& security_origin); | 57 const url::Origin& security_origin); |
| 56 | 58 |
| 57 // Returns a mixer instance based on AudioParameters; an existing one if one | 59 // Returns a mixer instance based on AudioParameters; an existing one if one |
| 58 // with the provided AudioParameters exists or a new one if not. | 60 // with the provided AudioParameters exists or a new one if not. |
| 59 media::AudioRendererMixer* GetMixer(int source_render_frame_id, | 61 media::AudioRendererMixer* GetMixer(int source_render_frame_id, |
| 60 const media::AudioParameters& params, | 62 const media::AudioParameters& params, |
| 61 const std::string& device_id, | 63 const std::string& device_id, |
| 62 const url::Origin& security_origin, | 64 const url::Origin& security_origin, |
| 63 media::OutputDeviceStatus* device_status); | 65 media::OutputDeviceStatus* device_status); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 return a.source_render_frame_id < b.source_render_frame_id; | 97 return a.source_render_frame_id < b.source_render_frame_id; |
| 96 if (a.params.channels() != b.params.channels()) | 98 if (a.params.channels() != b.params.channels()) |
| 97 return a.params.channels() < b.params.channels(); | 99 return a.params.channels() < b.params.channels(); |
| 98 | 100 |
| 99 // Ignore effects(), bits_per_sample(), format(), and frames_per_buffer(), | 101 // Ignore effects(), bits_per_sample(), format(), and frames_per_buffer(), |
| 100 // these parameters do not affect mixer reuse. All AudioRendererMixer | 102 // these parameters do not affect mixer reuse. All AudioRendererMixer |
| 101 // units disable FIFO, so frames_per_buffer() can be safely ignored. | 103 // units disable FIFO, so frames_per_buffer() can be safely ignored. |
| 102 if (a.params.channel_layout() != b.params.channel_layout()) | 104 if (a.params.channel_layout() != b.params.channel_layout()) |
| 103 return a.params.channel_layout() < b.params.channel_layout(); | 105 return a.params.channel_layout() < b.params.channel_layout(); |
| 104 | 106 |
| 107 if (media::AudioManagerBase::IsDefaultDeviceId(a.device_id) && | |
| 108 media::AudioManagerBase::IsDefaultDeviceId(b.device_id)) { | |
| 109 // Both device IDs represent the same default device => do not compare | |
| 110 // them; the default device is always authorized => ignoring security | |
| 111 // origin. | |
| 112 return false; | |
| 113 } | |
| 114 | |
| 105 if (a.device_id != b.device_id) | 115 if (a.device_id != b.device_id) |
| 106 return a.device_id < b.device_id; | 116 return (a.device_id < b.device_id); |
|
o1ka
2016/03/07 15:25:49
nit: I'll remove brackets.
o1ka
2016/04/05 15:13:38
Done.
| |
| 107 | 117 |
| 108 return a.security_origin < b.security_origin; | 118 return a.security_origin < b.security_origin; |
| 109 } | 119 } |
| 110 }; | 120 }; |
| 111 | 121 |
| 112 // Map of MixerKey to <AudioRendererMixer, Count>. Count allows | 122 // Map of MixerKey to <AudioRendererMixer, Count>. Count allows |
| 113 // AudioRendererMixerManager to keep track explicitly (v.s. RefCounted which | 123 // AudioRendererMixerManager to keep track explicitly (v.s. RefCounted which |
| 114 // is implicit) of the number of outstanding AudioRendererMixers. | 124 // is implicit) of the number of outstanding AudioRendererMixers. |
| 115 struct AudioRendererMixerReference { | 125 struct AudioRendererMixerReference { |
| 116 media::AudioRendererMixer* mixer; | 126 media::AudioRendererMixer* mixer; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 127 static media::AudioParameters GetHardwareOutputParams( | 137 static media::AudioParameters GetHardwareOutputParams( |
| 128 int render_frame_id, | 138 int render_frame_id, |
| 129 int session_id, | 139 int session_id, |
| 130 const std::string& device_id, | 140 const std::string& device_id, |
| 131 const url::Origin& security_origin); | 141 const url::Origin& security_origin); |
| 132 | 142 |
| 133 // Active mixers. | 143 // Active mixers. |
| 134 AudioRendererMixerMap mixers_; | 144 AudioRendererMixerMap mixers_; |
| 135 base::Lock mixers_lock_; | 145 base::Lock mixers_lock_; |
| 136 | 146 |
| 137 media::AudioRendererSink* sink_for_testing_; | |
| 138 | |
| 139 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerManager); | 147 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerManager); |
| 140 }; | 148 }; |
| 141 | 149 |
| 142 } // namespace content | 150 } // namespace content |
| 143 | 151 |
| 144 #endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ | 152 #endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ |
| OLD | NEW |