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 // Implementation of AudioOutputStream for Windows using Windows Core Audio | 5 // Implementation of AudioOutputStream for Windows using Windows Core Audio |
6 // WASAPI for low latency rendering. | 6 // WASAPI for low latency rendering. |
7 // | 7 // |
8 // Overview of operation and performance: | 8 // Overview of operation and performance: |
9 // | 9 // |
10 // - An object of WASAPIAudioOutputStream is created by the AudioManager | 10 // - An object of WASAPIAudioOutputStream is created by the AudioManager |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 WASAPIAudioOutputStream(AudioManagerWin* manager, | 124 WASAPIAudioOutputStream(AudioManagerWin* manager, |
125 const std::string& device_id, | 125 const std::string& device_id, |
126 const AudioParameters& params, | 126 const AudioParameters& params, |
127 ERole device_role); | 127 ERole device_role); |
128 | 128 |
129 // The dtor is typically called by the AudioManager only and it is usually | 129 // The dtor is typically called by the AudioManager only and it is usually |
130 // triggered by calling AudioOutputStream::Close(). | 130 // triggered by calling AudioOutputStream::Close(). |
131 virtual ~WASAPIAudioOutputStream(); | 131 virtual ~WASAPIAudioOutputStream(); |
132 | 132 |
133 // Implementation of AudioOutputStream. | 133 // Implementation of AudioOutputStream. |
134 virtual bool Open() OVERRIDE; | 134 virtual bool Open() override; |
135 virtual void Start(AudioSourceCallback* callback) OVERRIDE; | 135 virtual void Start(AudioSourceCallback* callback) override; |
136 virtual void Stop() OVERRIDE; | 136 virtual void Stop() override; |
137 virtual void Close() OVERRIDE; | 137 virtual void Close() override; |
138 virtual void SetVolume(double volume) OVERRIDE; | 138 virtual void SetVolume(double volume) override; |
139 virtual void GetVolume(double* volume) OVERRIDE; | 139 virtual void GetVolume(double* volume) override; |
140 | 140 |
141 // Retrieves the sample rate the audio engine uses for its internal | 141 // Retrieves the sample rate the audio engine uses for its internal |
142 // processing/mixing of shared-mode streams. To fetch the settings for the | 142 // processing/mixing of shared-mode streams. To fetch the settings for the |
143 // default device, pass an empty string as the |device_id|. | 143 // default device, pass an empty string as the |device_id|. |
144 static int HardwareSampleRate(const std::string& device_id); | 144 static int HardwareSampleRate(const std::string& device_id); |
145 | 145 |
146 // Returns AUDCLNT_SHAREMODE_EXCLUSIVE if --enable-exclusive-mode is used | 146 // Returns AUDCLNT_SHAREMODE_EXCLUSIVE if --enable-exclusive-mode is used |
147 // as command-line flag and AUDCLNT_SHAREMODE_SHARED otherwise (default). | 147 // as command-line flag and AUDCLNT_SHAREMODE_SHARED otherwise (default). |
148 static AUDCLNT_SHAREMODE GetShareMode(); | 148 static AUDCLNT_SHAREMODE GetShareMode(); |
149 | 149 |
150 bool started() const { return render_thread_.get() != NULL; } | 150 bool started() const { return render_thread_.get() != NULL; } |
151 | 151 |
152 private: | 152 private: |
153 // DelegateSimpleThread::Delegate implementation. | 153 // DelegateSimpleThread::Delegate implementation. |
154 virtual void Run() OVERRIDE; | 154 virtual void Run() override; |
155 | 155 |
156 // Core part of the thread loop which controls the actual rendering. | 156 // Core part of the thread loop which controls the actual rendering. |
157 // Checks available amount of space in the endpoint buffer and reads | 157 // Checks available amount of space in the endpoint buffer and reads |
158 // data from the client to fill up the buffer without causing audio | 158 // data from the client to fill up the buffer without causing audio |
159 // glitches. | 159 // glitches. |
160 bool RenderAudioFromSource(UINT64 device_frequency); | 160 bool RenderAudioFromSource(UINT64 device_frequency); |
161 | 161 |
162 // Called when the device will be opened in exclusive mode and use the | 162 // Called when the device will be opened in exclusive mode and use the |
163 // application specified format. | 163 // application specified format. |
164 // TODO(henrika): rewrite and move to CoreAudioUtil when removing flag | 164 // TODO(henrika): rewrite and move to CoreAudioUtil when removing flag |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 scoped_ptr<AudioBus> audio_bus_; | 240 scoped_ptr<AudioBus> audio_bus_; |
241 | 241 |
242 base::win::ScopedComPtr<IAudioClock> audio_clock_; | 242 base::win::ScopedComPtr<IAudioClock> audio_clock_; |
243 | 243 |
244 DISALLOW_COPY_AND_ASSIGN(WASAPIAudioOutputStream); | 244 DISALLOW_COPY_AND_ASSIGN(WASAPIAudioOutputStream); |
245 }; | 245 }; |
246 | 246 |
247 } // namespace media | 247 } // namespace media |
248 | 248 |
249 #endif // MEDIA_AUDIO_WIN_AUDIO_LOW_LATENCY_OUTPUT_WIN_H_ | 249 #endif // MEDIA_AUDIO_WIN_AUDIO_LOW_LATENCY_OUTPUT_WIN_H_ |
OLD | NEW |