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 // Audio rendering unit utilizing audio output stream provided by browser | 5 // Audio rendering unit utilizing audio output stream provided by browser |
6 // process through IPC. | 6 // process through IPC. |
7 // | 7 // |
8 // Relationship of classes. | 8 // Relationship of classes. |
9 // | 9 // |
10 // AudioOutputController AudioOutputDevice | 10 // AudioOutputController AudioOutputDevice |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 namespace media { | 73 namespace media { |
74 | 74 |
75 class MEDIA_EXPORT AudioOutputDevice | 75 class MEDIA_EXPORT AudioOutputDevice |
76 : NON_EXPORTED_BASE(public AudioRendererSink), | 76 : NON_EXPORTED_BASE(public AudioRendererSink), |
77 public AudioOutputIPCDelegate, | 77 public AudioOutputIPCDelegate, |
78 NON_EXPORTED_BASE(public ScopedLoopObserver) { | 78 NON_EXPORTED_BASE(public ScopedLoopObserver) { |
79 public: | 79 public: |
80 // AudioRendererSink implementation. | 80 // AudioRendererSink implementation. |
81 virtual void Initialize(const AudioParameters& params, | 81 virtual void Initialize(const AudioParameters& params, |
82 RenderCallback* callback) OVERRIDE; | 82 RenderCallback* callback) OVERRIDE; |
| 83 virtual void InitializeIO(const AudioParameters& params, |
| 84 int input_channels, |
| 85 RenderCallback* callback) OVERRIDE; |
83 virtual void Start() OVERRIDE; | 86 virtual void Start() OVERRIDE; |
84 virtual void Stop() OVERRIDE; | 87 virtual void Stop() OVERRIDE; |
85 virtual void Play() OVERRIDE; | 88 virtual void Play() OVERRIDE; |
86 virtual void Pause(bool flush) OVERRIDE; | 89 virtual void Pause(bool flush) OVERRIDE; |
87 virtual bool SetVolume(double volume) OVERRIDE; | 90 virtual bool SetVolume(double volume) OVERRIDE; |
88 | 91 |
89 // Methods called on IO thread ---------------------------------------------- | 92 // Methods called on IO thread ---------------------------------------------- |
90 // AudioOutputIPCDelegate methods. | 93 // AudioOutputIPCDelegate methods. |
91 virtual void OnStateChanged(AudioOutputIPCDelegate::State state) OVERRIDE; | 94 virtual void OnStateChanged(AudioOutputIPCDelegate::State state) OVERRIDE; |
92 virtual void OnStreamCreated(base::SharedMemoryHandle handle, | 95 virtual void OnStreamCreated(base::SharedMemoryHandle handle, |
(...skipping 12 matching lines...) Expand all Loading... |
105 // Magic required by ref_counted.h to avoid any code deleting the object | 108 // Magic required by ref_counted.h to avoid any code deleting the object |
106 // accidentally while there are references to it. | 109 // accidentally while there are references to it. |
107 friend class base::RefCountedThreadSafe<AudioOutputDevice>; | 110 friend class base::RefCountedThreadSafe<AudioOutputDevice>; |
108 virtual ~AudioOutputDevice(); | 111 virtual ~AudioOutputDevice(); |
109 | 112 |
110 private: | 113 private: |
111 // Methods called on IO thread ---------------------------------------------- | 114 // Methods called on IO thread ---------------------------------------------- |
112 // The following methods are tasks posted on the IO thread that needs to | 115 // The following methods are tasks posted on the IO thread that needs to |
113 // be executed on that thread. They interact with AudioMessageFilter and | 116 // be executed on that thread. They interact with AudioMessageFilter and |
114 // sends IPC messages on that thread. | 117 // sends IPC messages on that thread. |
115 void CreateStreamOnIOThread(const AudioParameters& params); | 118 void CreateStreamOnIOThread(const AudioParameters& params, |
| 119 int input_channels); |
116 void PlayOnIOThread(); | 120 void PlayOnIOThread(); |
117 void PauseOnIOThread(bool flush); | 121 void PauseOnIOThread(bool flush); |
118 void ShutDownOnIOThread(); | 122 void ShutDownOnIOThread(); |
119 void SetVolumeOnIOThread(double volume); | 123 void SetVolumeOnIOThread(double volume); |
120 | 124 |
121 // MessageLoop::DestructionObserver implementation for the IO loop. | 125 // MessageLoop::DestructionObserver implementation for the IO loop. |
122 // If the IO loop dies before we do, we shut down the audio thread from here. | 126 // If the IO loop dies before we do, we shut down the audio thread from here. |
123 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; | 127 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; |
124 | 128 |
125 AudioParameters audio_parameters_; | 129 AudioParameters audio_parameters_; |
126 | 130 |
| 131 // The number of optional synchronized input channels having the same |
| 132 // sample-rate and buffer-size as specified in audio_parameters_. |
| 133 int input_channels_; |
| 134 |
127 RenderCallback* callback_; | 135 RenderCallback* callback_; |
128 | 136 |
129 // A pointer to the IPC layer that takes care of sending requests over to | 137 // A pointer to the IPC layer that takes care of sending requests over to |
130 // the AudioRendererHost. | 138 // the AudioRendererHost. |
131 AudioOutputIPC* ipc_; | 139 AudioOutputIPC* ipc_; |
132 | 140 |
133 // Our stream ID on the message filter. Only accessed on the IO thread. | 141 // Our stream ID on the message filter. Only accessed on the IO thread. |
134 // Must only be modified on the IO thread. | 142 // Must only be modified on the IO thread. |
135 int stream_id_; | 143 int stream_id_; |
136 | 144 |
(...skipping 15 matching lines...) Expand all Loading... |
152 AudioDeviceThread audio_thread_; | 160 AudioDeviceThread audio_thread_; |
153 scoped_ptr<AudioOutputDevice::AudioThreadCallback> audio_callback_; | 161 scoped_ptr<AudioOutputDevice::AudioThreadCallback> audio_callback_; |
154 | 162 |
155 DISALLOW_COPY_AND_ASSIGN(AudioOutputDevice); | 163 DISALLOW_COPY_AND_ASSIGN(AudioOutputDevice); |
156 }; | 164 }; |
157 | 165 |
158 } // namespace media | 166 } // namespace media |
159 | 167 |
160 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_ | 168 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_ |
161 | 169 |
OLD | NEW |