Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Low-latency audio rendering unit utilizing audio output stream provided | 5 // Low-latency audio rendering unit utilizing audio output stream provided |
| 6 // by browser process through IPC. | 6 // by browser process through IPC. |
| 7 // | 7 // |
| 8 // Relationship of classes. | 8 // Relationship of classes. |
| 9 // | 9 // |
| 10 // AudioOutputController AudioDevice | 10 // AudioOutputController AudioDevice |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 // Sets the playback volume, with range [0.0, 1.0] inclusive. | 94 // Sets the playback volume, with range [0.0, 1.0] inclusive. |
| 95 // Returns |true| on success. | 95 // Returns |true| on success. |
| 96 bool SetVolume(double volume); | 96 bool SetVolume(double volume); |
| 97 | 97 |
| 98 // Gets the playback volume, with range [0.0, 1.0] inclusive. | 98 // Gets the playback volume, with range [0.0, 1.0] inclusive. |
| 99 void GetVolume(double* volume); | 99 void GetVolume(double* volume); |
| 100 | 100 |
| 101 double sample_rate() const { return sample_rate_; } | 101 double sample_rate() const { return sample_rate_; } |
| 102 size_t buffer_size() const { return buffer_size_; } | 102 size_t buffer_size() const { return buffer_size_; } |
| 103 | 103 |
| 104 static double GetAudioHardwareSampleRate(); | |
| 105 static size_t GetAudioHardwareBufferSize(); | |
| 106 | |
| 107 // Methods called on IO thread ---------------------------------------------- | 104 // Methods called on IO thread ---------------------------------------------- |
| 108 // AudioMessageFilter::Delegate methods, called by AudioMessageFilter. | 105 // AudioMessageFilter::Delegate methods, called by AudioMessageFilter. |
| 109 virtual void OnRequestPacket(AudioBuffersState buffers_state); | 106 virtual void OnRequestPacket(AudioBuffersState buffers_state); |
| 110 virtual void OnStateChanged(AudioStreamState state); | 107 virtual void OnStateChanged(AudioStreamState state); |
| 111 virtual void OnCreated(base::SharedMemoryHandle handle, uint32 length); | 108 virtual void OnCreated(base::SharedMemoryHandle handle, uint32 length); |
| 112 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, | 109 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, |
| 113 base::SyncSocket::Handle socket_handle, | 110 base::SyncSocket::Handle socket_handle, |
| 114 uint32 length); | 111 uint32 length); |
| 115 virtual void OnVolume(double volume); | 112 virtual void OnVolume(double volume); |
| 116 | 113 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 int32 stream_id_; | 165 int32 stream_id_; |
| 169 | 166 |
| 170 // Data transfer between browser and render process uses a combination | 167 // Data transfer between browser and render process uses a combination |
| 171 // of sync sockets and shared memory to provide lowest possible latency. | 168 // of sync sockets and shared memory to provide lowest possible latency. |
| 172 scoped_ptr<base::SharedMemory> shared_memory_; | 169 scoped_ptr<base::SharedMemory> shared_memory_; |
| 173 scoped_ptr<base::SyncSocket> socket_; | 170 scoped_ptr<base::SyncSocket> socket_; |
| 174 | 171 |
| 175 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDevice); | 172 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDevice); |
| 176 }; | 173 }; |
| 177 | 174 |
| 175 // Contains static methods to query hardware properties from the browser | |
|
henrika (OOO until Aug 14)
2011/11/17 12:27:44
Namespace perhaps?
| |
| 176 // process. Values are cached to avoid unnecessary round trips, but the cache | |
| 177 // can be cleared if needed (currently only used by tests). | |
| 178 class CONTENT_EXPORT AudioHardware { | |
| 179 public: | |
| 180 static double GetOutputSampleRate(); | |
| 181 static double GetInputSampleRate(); | |
| 182 static size_t GetOutputBufferSize(); | |
| 183 | |
| 184 // Forces the next call to any of the Get functions to query the hardware | |
| 185 // and repopulate the cache. | |
| 186 static void ResetCache(); | |
| 187 | |
| 188 private: | |
| 189 static double output_sample_rate_; | |
| 190 static double input_sample_rate_; | |
| 191 static size_t output_buffer_size_; | |
| 192 | |
| 193 // This class doesn't support construction. | |
| 194 DISALLOW_COPY_AND_ASSIGN(AudioHardware); | |
| 195 }; | |
| 196 | |
| 178 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_H_ | 197 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_H_ |
| OLD | NEW |