Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: media/audio/audio_util.cc

Issue 6721015: Add WebKit API to retrieve the audio hardware sample-rate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // Software adjust volume of samples, allows each audio stream its own 5 // Software adjust volume of samples, allows each audio stream its own
6 // volume without impacting master volume for chrome and other applications. 6 // volume without impacting master volume for chrome and other applications.
7 7
8 // Implemented as templates to allow 8, 16 and 32 bit implementations. 8 // Implemented as templates to allow 8, 16 and 32 bit implementations.
9 // 8 bit is unsigned and biased by 128. 9 // 8 bit is unsigned and biased by 128.
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "media/audio/audio_util.h" 13 #include "media/audio/audio_util.h"
14 #if defined(OS_MACOSX)
15 #include "media/audio/mac/audio_low_latency_output_mac.h"
16 #endif
14 17
15 namespace media { 18 namespace media {
16 19
17 // TODO(fbarchard): Convert to intrinsics for better efficiency. 20 // TODO(fbarchard): Convert to intrinsics for better efficiency.
18 template<class Fixed> 21 template<class Fixed>
19 static int ScaleChannel(int channel, int volume) { 22 static int ScaleChannel(int channel, int volume) {
20 return static_cast<int>((static_cast<Fixed>(channel) * volume) >> 16); 23 return static_cast<int>((static_cast<Fixed>(channel) * volume) >> 16);
21 } 24 }
22 25
23 template<class Format, class Fixed, int bias> 26 template<class Format, class Fixed, int bias>
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 if (sample < -32768.0) 215 if (sample < -32768.0)
213 sample = -32768.0; 216 sample = -32768.0;
214 else if (sample > 32767.0) 217 else if (sample > 32767.0)
215 sample = 32767.0; 218 sample = 32767.0;
216 219
217 destination[j * channels + i] = static_cast<int16>(sample); 220 destination[j * channels + i] = static_cast<int16>(sample);
218 } 221 }
219 } 222 }
220 } 223 }
221 224
225 double GetAudioHardwareSampleRate()
226 {
scherkus (not reviewing) 2011/03/23 04:57:57 nit: chromium style has brackets go on the functio
227 #if defined(OS_MACOSX)
228 // Hardware sample-rate on the Mac can be configured, so we must query.
scherkus (not reviewing) 2011/03/23 04:57:57 nit: two space indent
229 return AUAudioOutputStream::HardwareSampleRate();
230 #else
231 // Hardware for Windows and Linux is nearly always 48KHz.
232 // TODO(crogers) : return correct value in rare non-48KHz cases.
scherkus (not reviewing) 2011/03/23 04:57:57 this isn't quite true... in fact chrome os was shi
233 return 48000.0;
234 #endif
235 }
236
222 } // namespace media 237 } // namespace media
OLDNEW
« content/renderer/renderer_webkitclient_impl.cc ('K') | « media/audio/audio_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698