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

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

Issue 9655018: Make AudioParameters a class instead of a struct (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix copyright years Created 8 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
« no previous file with comments | « media/audio/audio_input_unittest.cc ('k') | media/audio/audio_manager_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <cmath> 5 #include <cmath>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/win/scoped_com_initializer.h" 8 #include "base/win/scoped_com_initializer.h"
9 #include "media/audio/audio_io.h" 9 #include "media/audio/audio_io.h"
10 #include "media/audio/audio_manager_base.h" 10 #include "media/audio/audio_manager_base.h"
(...skipping 28 matching lines...) Expand all
39 bool HasDeviceVolumeControl(AudioInputStream* stream) { 39 bool HasDeviceVolumeControl(AudioInputStream* stream) {
40 if (!stream) 40 if (!stream)
41 return false; 41 return false;
42 42
43 return (stream->GetMaxVolume() != 0.0); 43 return (stream->GetMaxVolume() != 0.0);
44 } 44 }
45 45
46 AudioInputStream* CreateAndOpenStream(const std::string& device_id) { 46 AudioInputStream* CreateAndOpenStream(const std::string& device_id) {
47 AudioParameters::Format format = AudioParameters::AUDIO_PCM_LOW_LATENCY; 47 AudioParameters::Format format = AudioParameters::AUDIO_PCM_LOW_LATENCY;
48 ChannelLayout channel_layout = 48 ChannelLayout channel_layout =
49 (media::GetAudioInputHardwareChannelCount(device_id) == 1) ? 49 media::GetAudioInputHardwareChannelLayout(device_id);
50 CHANNEL_LAYOUT_MONO : CHANNEL_LAYOUT_STEREO;
51 int bits_per_sample = 16; 50 int bits_per_sample = 16;
52 int sample_rate = 51 int sample_rate =
53 static_cast<int>(media::GetAudioInputHardwareSampleRate(device_id)); 52 static_cast<int>(media::GetAudioInputHardwareSampleRate(device_id));
54 int samples_per_packet = 0; 53 int samples_per_packet = 0;
55 #if defined(OS_MACOSX) 54 #if defined(OS_MACOSX)
56 samples_per_packet = (sample_rate / 100); 55 samples_per_packet = (sample_rate / 100);
57 #elif defined(OS_LINUX) || defined(OS_OPENBSD) 56 #elif defined(OS_LINUX) || defined(OS_OPENBSD)
58 samples_per_packet = (sample_rate / 100); 57 samples_per_packet = (sample_rate / 100);
59 #elif defined(OS_WIN) 58 #elif defined(OS_WIN)
60 if (sample_rate == 44100) 59 if (sample_rate == 44100)
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 EXPECT_NEAR(current_volume, new_volume, 0.25 * max_volume); 150 EXPECT_NEAR(current_volume, new_volume, 0.25 * max_volume);
152 151
153 // Restores the volume to the original value. 152 // Restores the volume to the original value.
154 ais->SetVolume(original_volume); 153 ais->SetVolume(original_volume);
155 current_volume = ais->GetVolume(); 154 current_volume = ais->GetVolume();
156 EXPECT_EQ(original_volume, current_volume); 155 EXPECT_EQ(original_volume, current_volume);
157 156
158 ais->Close(); 157 ais->Close();
159 } 158 }
160 } 159 }
OLDNEW
« no previous file with comments | « media/audio/audio_input_unittest.cc ('k') | media/audio/audio_manager_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698