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 #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 Loading... |
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 Loading... |
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 } |
OLD | NEW |