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

Side by Side Diff: webrtc/modules/audio_device/android/audio_manager_unittest.cc

Issue 1316523002: Convert channel counts to size_t. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Fix compile Created 4 years, 11 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 PRINT("%sLow latency output support: %s\n", kTag, 75 PRINT("%sLow latency output support: %s\n", kTag,
76 audio_manager()->IsLowLatencyPlayoutSupported() ? "Yes" : "No"); 76 audio_manager()->IsLowLatencyPlayoutSupported() ? "Yes" : "No");
77 } 77 }
78 78
79 TEST_F(AudioManagerTest, ShowAudioParameterInfo) { 79 TEST_F(AudioManagerTest, ShowAudioParameterInfo) {
80 const bool low_latency_out = audio_manager()->IsLowLatencyPlayoutSupported(); 80 const bool low_latency_out = audio_manager()->IsLowLatencyPlayoutSupported();
81 PRINT("PLAYOUT:\n"); 81 PRINT("PLAYOUT:\n");
82 PRINT("%saudio layer: %s\n", kTag, 82 PRINT("%saudio layer: %s\n", kTag,
83 low_latency_out ? "Low latency OpenSL" : "Java/JNI based AudioTrack"); 83 low_latency_out ? "Low latency OpenSL" : "Java/JNI based AudioTrack");
84 PRINT("%ssample rate: %d Hz\n", kTag, playout_parameters_.sample_rate()); 84 PRINT("%ssample rate: %d Hz\n", kTag, playout_parameters_.sample_rate());
85 PRINT("%schannels: %d\n", kTag, playout_parameters_.channels()); 85 PRINT("%schannels: %" PRIuS "\n", kTag, playout_parameters_.channels());
86 PRINT("%sframes per buffer: %" PRIuS " <=> %.2f ms\n", kTag, 86 PRINT("%sframes per buffer: %" PRIuS " <=> %.2f ms\n", kTag,
87 playout_parameters_.frames_per_buffer(), 87 playout_parameters_.frames_per_buffer(),
88 playout_parameters_.GetBufferSizeInMilliseconds()); 88 playout_parameters_.GetBufferSizeInMilliseconds());
89 PRINT("RECORD: \n"); 89 PRINT("RECORD: \n");
90 PRINT("%saudio layer: %s\n", kTag, "Java/JNI based AudioRecord"); 90 PRINT("%saudio layer: %s\n", kTag, "Java/JNI based AudioRecord");
91 PRINT("%ssample rate: %d Hz\n", kTag, record_parameters_.sample_rate()); 91 PRINT("%ssample rate: %d Hz\n", kTag, record_parameters_.sample_rate());
92 PRINT("%schannels: %d\n", kTag, record_parameters_.channels()); 92 PRINT("%schannels: %" PRIuS "\n", kTag, record_parameters_.channels());
93 PRINT("%sframes per buffer: %" PRIuS " <=> %.2f ms\n", kTag, 93 PRINT("%sframes per buffer: %" PRIuS " <=> %.2f ms\n", kTag,
94 record_parameters_.frames_per_buffer(), 94 record_parameters_.frames_per_buffer(),
95 record_parameters_.GetBufferSizeInMilliseconds()); 95 record_parameters_.GetBufferSizeInMilliseconds());
96 } 96 }
97 97
98 // Add device-specific information to the test for logging purposes. 98 // Add device-specific information to the test for logging purposes.
99 TEST_F(AudioManagerTest, ShowDeviceInfo) { 99 TEST_F(AudioManagerTest, ShowDeviceInfo) {
100 BuildInfo build_info; 100 BuildInfo build_info;
101 PRINT("%smodel: %s\n", kTag, build_info.GetDeviceModel().c_str()); 101 PRINT("%smodel: %s\n", kTag, build_info.GetDeviceModel().c_str());
102 PRINT("%sbrand: %s\n", kTag, build_info.GetBrand().c_str()); 102 PRINT("%sbrand: %s\n", kTag, build_info.GetBrand().c_str());
103 PRINT("%smanufacturer: %s\n", 103 PRINT("%smanufacturer: %s\n",
104 kTag, build_info.GetDeviceManufacturer().c_str()); 104 kTag, build_info.GetDeviceManufacturer().c_str());
105 } 105 }
106 106
107 // Add Android build information to the test for logging purposes. 107 // Add Android build information to the test for logging purposes.
108 TEST_F(AudioManagerTest, ShowBuildInfo) { 108 TEST_F(AudioManagerTest, ShowBuildInfo) {
109 BuildInfo build_info; 109 BuildInfo build_info;
110 PRINT("%sbuild release: %s\n", kTag, build_info.GetBuildRelease().c_str()); 110 PRINT("%sbuild release: %s\n", kTag, build_info.GetBuildRelease().c_str());
111 PRINT("%sbuild id: %s\n", kTag, build_info.GetAndroidBuildId().c_str()); 111 PRINT("%sbuild id: %s\n", kTag, build_info.GetAndroidBuildId().c_str());
112 PRINT("%sbuild type: %s\n", kTag, build_info.GetBuildType().c_str()); 112 PRINT("%sbuild type: %s\n", kTag, build_info.GetBuildType().c_str());
113 PRINT("%sSDK version: %s\n", kTag, build_info.GetSdkVersion().c_str()); 113 PRINT("%sSDK version: %s\n", kTag, build_info.GetSdkVersion().c_str());
114 } 114 }
115 115
116 // Basic test of the AudioParameters class using default construction where 116 // Basic test of the AudioParameters class using default construction where
117 // all members are set to zero. 117 // all members are set to zero.
118 TEST_F(AudioManagerTest, AudioParametersWithDefaultConstruction) { 118 TEST_F(AudioManagerTest, AudioParametersWithDefaultConstruction) {
119 AudioParameters params; 119 AudioParameters params;
120 EXPECT_FALSE(params.is_valid()); 120 EXPECT_FALSE(params.is_valid());
121 EXPECT_EQ(0, params.sample_rate()); 121 EXPECT_EQ(0, params.sample_rate());
122 EXPECT_EQ(0, params.channels()); 122 EXPECT_EQ(0U, params.channels());
123 EXPECT_EQ(0U, params.frames_per_buffer()); 123 EXPECT_EQ(0U, params.frames_per_buffer());
124 EXPECT_EQ(0U, params.frames_per_10ms_buffer()); 124 EXPECT_EQ(0U, params.frames_per_10ms_buffer());
125 EXPECT_EQ(0U, params.GetBytesPerFrame()); 125 EXPECT_EQ(0U, params.GetBytesPerFrame());
126 EXPECT_EQ(0U, params.GetBytesPerBuffer()); 126 EXPECT_EQ(0U, params.GetBytesPerBuffer());
127 EXPECT_EQ(0U, params.GetBytesPer10msBuffer()); 127 EXPECT_EQ(0U, params.GetBytesPer10msBuffer());
128 EXPECT_EQ(0.0f, params.GetBufferSizeInMilliseconds()); 128 EXPECT_EQ(0.0f, params.GetBufferSizeInMilliseconds());
129 } 129 }
130 130
131 // Basic test of the AudioParameters class using non default construction. 131 // Basic test of the AudioParameters class using non default construction.
132 TEST_F(AudioManagerTest, AudioParametersWithNonDefaultConstruction) { 132 TEST_F(AudioManagerTest, AudioParametersWithNonDefaultConstruction) {
133 const int kSampleRate = 48000; 133 const int kSampleRate = 48000;
134 const int kChannels = 1; 134 const size_t kChannels = 1;
135 const size_t kFramesPerBuffer = 480; 135 const size_t kFramesPerBuffer = 480;
136 const size_t kFramesPer10msBuffer = 480; 136 const size_t kFramesPer10msBuffer = 480;
137 const size_t kBytesPerFrame = 2; 137 const size_t kBytesPerFrame = 2;
138 const float kBufferSizeInMs = 10.0f; 138 const float kBufferSizeInMs = 10.0f;
139 AudioParameters params(kSampleRate, kChannels, kFramesPerBuffer); 139 AudioParameters params(kSampleRate, kChannels, kFramesPerBuffer);
140 EXPECT_TRUE(params.is_valid()); 140 EXPECT_TRUE(params.is_valid());
141 EXPECT_EQ(kSampleRate, params.sample_rate()); 141 EXPECT_EQ(kSampleRate, params.sample_rate());
142 EXPECT_EQ(kChannels, params.channels()); 142 EXPECT_EQ(kChannels, params.channels());
143 EXPECT_EQ(kFramesPerBuffer, params.frames_per_buffer()); 143 EXPECT_EQ(kFramesPerBuffer, params.frames_per_buffer());
144 EXPECT_EQ(static_cast<size_t>(kSampleRate / 100), 144 EXPECT_EQ(static_cast<size_t>(kSampleRate / 100),
145 params.frames_per_10ms_buffer()); 145 params.frames_per_10ms_buffer());
146 EXPECT_EQ(kBytesPerFrame, params.GetBytesPerFrame()); 146 EXPECT_EQ(kBytesPerFrame, params.GetBytesPerFrame());
147 EXPECT_EQ(kBytesPerFrame * kFramesPerBuffer, params.GetBytesPerBuffer()); 147 EXPECT_EQ(kBytesPerFrame * kFramesPerBuffer, params.GetBytesPerBuffer());
148 EXPECT_EQ(kBytesPerFrame * kFramesPer10msBuffer, 148 EXPECT_EQ(kBytesPerFrame * kFramesPer10msBuffer,
149 params.GetBytesPer10msBuffer()); 149 params.GetBytesPer10msBuffer());
150 EXPECT_EQ(kBufferSizeInMs, params.GetBufferSizeInMilliseconds()); 150 EXPECT_EQ(kBufferSizeInMs, params.GetBufferSizeInMilliseconds());
151 } 151 }
152 152
153 } // namespace webrtc 153 } // namespace webrtc
154 154
OLDNEW
« no previous file with comments | « webrtc/modules/audio_device/android/audio_manager.cc ('k') | webrtc/modules/audio_device/android/audio_record_jni.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698