volume_test.cc revision 8d63d0ee70d27439fd153af7093a6be390686efe
112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org/* 212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org * 412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org * Use of this source code is governed by a BSD-style license 512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org * that can be found in the LICENSE file in the root of the source 612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org * tree. An additional intellectual property rights grant can be found 712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org * in the file PATENTS. All contributing project authors may 812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org * be found in the AUTHORS file in the root of the source tree. 912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org */ 1012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 11956aa7e0874f2e08c335a82a2c32f400fac8b031pbos@webrtc.org#include "webrtc/voice_engine/test/auto_test/fixtures/after_streaming_fixture.h" 1212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 1308d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.orgnamespace { 1408d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.org 1508d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.orgvoid ExpectVolumeNear(int expected, int actual) { 1608d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.org // The hardware volume may be more coarsely quantized than [0, 255], so 1708d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.org // it is not always reasonable to expect to get exactly what we set. This 1808d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.org // allows for some error. 1908d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.org const int kMaxVolumeError = 10; 2008d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.org EXPECT_NEAR(expected, actual, kMaxVolumeError); 2108d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.org EXPECT_GE(actual, 0); 2208d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.org EXPECT_LE(actual, 255); 2308d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.org} 2408d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.org 2508d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.org} // namespace 2608d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.org 2712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgclass VolumeTest : public AfterStreamingFixture { 2812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org}; 2912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 3016fcb247b24a924c5cad05ed320957cd8cb145c4andrew@webrtc.org// TODO(phoglund): a number of tests are disabled here on Linux, all pending 3116fcb247b24a924c5cad05ed320957cd8cb145c4andrew@webrtc.org// investigation in 3216fcb247b24a924c5cad05ed320957cd8cb145c4andrew@webrtc.org// http://code.google.com/p/webrtc/issues/detail?id=367 3316fcb247b24a924c5cad05ed320957cd8cb145c4andrew@webrtc.org 3416fcb247b24a924c5cad05ed320957cd8cb145c4andrew@webrtc.orgTEST_F(VolumeTest, DefaultSpeakerVolumeIsAtMost255) { 3512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org unsigned int volume = 1000; 3612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetSpeakerVolume(volume)); 3712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_LE(volume, 255u); 3812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org} 3912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 40589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.orgTEST_F(VolumeTest, SetVolumeBeforePlayoutWorks) { 41589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org // This is a rather specialized test, intended to exercise some PulseAudio 42589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org // code. However, these conditions should be satisfied on any platform. 43589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org unsigned int original_volume = 0; 44589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetSpeakerVolume(original_volume)); 45589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org Sleep(1000); 46589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org 47589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetSpeakerVolume(200)); 48589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org unsigned int volume; 49589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetSpeakerVolume(volume)); 5008d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.org ExpectVolumeNear(200u, volume); 51589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org 52589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org PausePlaying(); 53589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org ResumePlaying(); 54589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetSpeakerVolume(volume)); 55589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org // Ensure the volume has not changed after resuming playout. 5608d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.org ExpectVolumeNear(200u, volume); 57589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org 58589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org PausePlaying(); 59589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetSpeakerVolume(100)); 60589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org ResumePlaying(); 61589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org // Ensure the volume set while paused is retained. 62589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetSpeakerVolume(volume)); 6308d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.org ExpectVolumeNear(100u, volume); 64589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org 65589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetSpeakerVolume(original_volume)); 66589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org} 67589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org 6812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, ManualSetVolumeWorks) { 6912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org unsigned int original_volume = 0; 7012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetSpeakerVolume(original_volume)); 7112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org Sleep(1000); 7212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 7312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org TEST_LOG("Setting speaker volume to 0 out of 255.\n"); 7412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetSpeakerVolume(0)); 75589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org unsigned int volume; 76589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetSpeakerVolume(volume)); 7708d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.org ExpectVolumeNear(0u, volume); 7812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org Sleep(1000); 7912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 8012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org TEST_LOG("Setting speaker volume to 100 out of 255.\n"); 8112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetSpeakerVolume(100)); 82589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetSpeakerVolume(volume)); 8308d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.org ExpectVolumeNear(100u, volume); 8412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org Sleep(1000); 8512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 8612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org // Set the volume to 255 very briefly so we don't blast the poor user 8712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org // listening to this. This is just to test the call succeeds. 8812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetSpeakerVolume(255)); 89589673f1cbef93921900a835de52d05ad4f3a0e2andrew@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetSpeakerVolume(volume)); 9008d660f08e7fb18c614729996da36b13b6f77bf3andrew@webrtc.org ExpectVolumeNear(255u, volume); 9112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 9212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org TEST_LOG("Setting speaker volume to the original %d out of 255.\n", 9312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org original_volume); 9412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetSpeakerVolume(original_volume)); 9512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org Sleep(1000); 9612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org} 9712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 988d63d0ee70d27439fd153af7093a6be390686efebjornv@webrtc.orgTEST_F(VolumeTest, DefaultMicrophoneVolumeIsAtMost255) { 9912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org unsigned int volume = 1000; 1008d63d0ee70d27439fd153af7093a6be390686efebjornv@webrtc.org if (voe_volume_control_->GetMicVolume(volume) == 0) 1018d63d0ee70d27439fd153af7093a6be390686efebjornv@webrtc.org EXPECT_LE(volume, 255u); 1028d63d0ee70d27439fd153af7093a6be390686efebjornv@webrtc.org else 1038d63d0ee70d27439fd153af7093a6be390686efebjornv@webrtc.org EXPECT_EQ(1000u, volume); 10412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org} 10512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 10616fcb247b24a924c5cad05ed320957cd8cb145c4andrew@webrtc.orgTEST_F(VolumeTest, DISABLED_ON_LINUX( 10716fcb247b24a924c5cad05ed320957cd8cb145c4andrew@webrtc.org ManualRequiresMicrophoneCanSetMicrophoneVolumeWithAcgOff)) { 10812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org SwitchToManualMicrophone(); 10912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_apm_->SetAgcStatus(false)); 11012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 11112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org unsigned int original_volume = 0; 11212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetMicVolume(original_volume)); 11312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 11412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org TEST_LOG("Setting microphone volume to 0.\n"); 11512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetMicVolume(channel_)); 11612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org Sleep(1000); 11712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org TEST_LOG("Setting microphone volume to 255.\n"); 11812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetMicVolume(255)); 11912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org Sleep(1000); 12012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org TEST_LOG("Setting microphone volume back to saved value.\n"); 12112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetMicVolume(original_volume)); 12212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org Sleep(1000); 12312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org} 12412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 12512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, ChannelScalingIsOneByDefault) { 12678088c2f3673dc104e2fc133c92583aa21d43e0ephoglund@webrtc.org float scaling = -1.0f; 12712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 12812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetChannelOutputVolumeScaling( 12912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org channel_, scaling)); 13078088c2f3673dc104e2fc133c92583aa21d43e0ephoglund@webrtc.org EXPECT_FLOAT_EQ(1.0f, scaling); 13112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org} 13212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 13312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, ManualCanSetChannelScaling) { 13412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetChannelOutputVolumeScaling( 13578088c2f3673dc104e2fc133c92583aa21d43e0ephoglund@webrtc.org channel_, 0.1f)); 13612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 13778088c2f3673dc104e2fc133c92583aa21d43e0ephoglund@webrtc.org float scaling = 1.0f; 13812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetChannelOutputVolumeScaling( 13912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org channel_, scaling)); 14012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 14178088c2f3673dc104e2fc133c92583aa21d43e0ephoglund@webrtc.org EXPECT_FLOAT_EQ(0.1f, scaling); 14212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 14312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org TEST_LOG("Channel scaling set to 0.1: audio should be barely audible.\n"); 14412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org Sleep(2000); 14512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org} 14612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 14712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, InputMutingIsNotEnabledByDefault) { 14812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org bool is_muted = true; 14912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetInputMute(channel_, is_muted)); 15012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_FALSE(is_muted); 15112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org} 15212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 15316fcb247b24a924c5cad05ed320957cd8cb145c4andrew@webrtc.orgTEST_F(VolumeTest, DISABLED_ON_LINUX(ManualInputMutingMutesMicrophone)) { 15412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org SwitchToManualMicrophone(); 15512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 15612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org // Enable muting. 15712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetInputMute(channel_, true)); 15812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org bool is_muted = false; 15912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetInputMute(channel_, is_muted)); 16012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_TRUE(is_muted); 16112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 16212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org TEST_LOG("Muted: talk into microphone and verify you can't hear yourself.\n"); 16312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org Sleep(2000); 16412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 16512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org // Test that we can disable muting. 16612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetInputMute(channel_, false)); 16712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetInputMute(channel_, is_muted)); 16812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_FALSE(is_muted); 16912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 17012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org TEST_LOG("Unmuted: talk into microphone and verify you can hear yourself.\n"); 17112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org Sleep(2000); 17212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org} 17312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 17416fcb247b24a924c5cad05ed320957cd8cb145c4andrew@webrtc.orgTEST_F(VolumeTest, DISABLED_ON_LINUX(SystemInputMutingIsNotEnabledByDefault)) { 17512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org bool is_muted = true; 17612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetSystemInputMute(is_muted)); 17712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_FALSE(is_muted); 17812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org} 17912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 18016fcb247b24a924c5cad05ed320957cd8cb145c4andrew@webrtc.orgTEST_F(VolumeTest, DISABLED_ON_LINUX(ManualSystemInputMutingMutesMicrophone)) { 18112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org SwitchToManualMicrophone(); 18212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 18312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org // Enable system input muting. 18412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetSystemInputMute(true)); 18512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org bool is_muted = false; 18612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetSystemInputMute(is_muted)); 18712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_TRUE(is_muted); 18812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 18912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org TEST_LOG("Muted: talk into microphone and verify you can't hear yourself.\n"); 19012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org Sleep(2000); 19112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 19212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org // Test that we can disable system input muting. 19312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetSystemInputMute(false)); 19412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetSystemInputMute(is_muted)); 19512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_FALSE(is_muted); 19612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 19712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org TEST_LOG("Unmuted: talk into microphone and verify you can hear yourself.\n"); 19812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org Sleep(2000); 19912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org} 20012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 2011c75918302412de8e8b922e9619e803b24f840f7phoglund@webrtc.orgTEST_F(VolumeTest, DISABLED_ON_LINUX(SystemOutputMutingIsNotEnabledByDefault)) { 20212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org bool is_muted = true; 20312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetSystemOutputMute(is_muted)); 20412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_FALSE(is_muted); 20512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org} 20612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 20712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, ManualSystemOutputMutingMutesOutput) { 20812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org // Enable muting. 20912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetSystemOutputMute(true)); 21012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org bool is_muted = false; 21112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetSystemOutputMute(is_muted)); 21212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_TRUE(is_muted); 21312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 21412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org TEST_LOG("Muted: you should hear no audio.\n"); 21512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org Sleep(2000); 21612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 21712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org // Test that we can disable muting. 21812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetSystemOutputMute(false)); 21912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetSystemOutputMute(is_muted)); 22012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_FALSE(is_muted); 22112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 22212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org TEST_LOG("Unmuted: you should hear audio.\n"); 22312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org Sleep(2000); 22412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org} 22512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 22612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, ManualTestInputAndOutputLevels) { 22712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org SwitchToManualMicrophone(); 22812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 22912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org TEST_LOG("Speak and verify that the following levels look right:\n"); 23012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org for (int i = 0; i < 5; i++) { 23112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org Sleep(1000); 23212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org unsigned int input_level = 0; 23312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org unsigned int output_level = 0; 23412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org unsigned int input_level_full_range = 0; 23512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org unsigned int output_level_full_range = 0; 23612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 23712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetSpeechInputLevel( 23812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org input_level)); 23912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetSpeechOutputLevel( 24012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org channel_, output_level)); 24112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetSpeechInputLevelFullRange( 24212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org input_level_full_range)); 24312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetSpeechOutputLevelFullRange( 24412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org channel_, output_level_full_range)); 24512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 24612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org TEST_LOG(" warped levels (0-9) : in=%5d, out=%5d\n", 24712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org input_level, output_level); 24812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org TEST_LOG(" linear levels (0-32768): in=%5d, out=%5d\n", 24912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org input_level_full_range, output_level_full_range); 25012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org } 25112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org} 25212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 25312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, ChannelsAreNotPannedByDefault) { 25412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org float left = -1.0; 25512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org float right = -1.0; 25612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 25712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetOutputVolumePan(channel_, left, right)); 25812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_FLOAT_EQ(1.0, left); 25912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_FLOAT_EQ(1.0, right); 26012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org} 26112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 26212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, ManualTestChannelPanning) { 26312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org TEST_LOG("Panning left.\n"); 26478088c2f3673dc104e2fc133c92583aa21d43e0ephoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetOutputVolumePan(channel_, 0.8f, 0.1f)); 26512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org Sleep(1000); 26612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 26712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org TEST_LOG("Back to center.\n"); 26878088c2f3673dc104e2fc133c92583aa21d43e0ephoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetOutputVolumePan(channel_, 1.0f, 1.0f)); 26912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org Sleep(1000); 27012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 27112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org TEST_LOG("Panning right.\n"); 27278088c2f3673dc104e2fc133c92583aa21d43e0ephoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->SetOutputVolumePan(channel_, 0.1f, 0.8f)); 27312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org Sleep(1000); 27412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 27512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org // To finish, verify that the getter works. 27678088c2f3673dc104e2fc133c92583aa21d43e0ephoglund@webrtc.org float left = 0.0f; 27778088c2f3673dc104e2fc133c92583aa21d43e0ephoglund@webrtc.org float right = 0.0f; 27812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org 27912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org EXPECT_EQ(0, voe_volume_control_->GetOutputVolumePan(channel_, left, right)); 28078088c2f3673dc104e2fc133c92583aa21d43e0ephoglund@webrtc.org EXPECT_FLOAT_EQ(0.1f, left); 28178088c2f3673dc104e2fc133c92583aa21d43e0ephoglund@webrtc.org EXPECT_FLOAT_EQ(0.8f, right); 28212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org} 283