Commit d942e502 authored by phoglund@chromium.org's avatar phoglund@chromium.org

Will now force the volume of all input devices in the WebRTC audio test.

The WebRTC audio quality test has been relying on a particular
configuration for the input device name, but it has turned out to be
painful to maintain. Specifically, it used to require that the default
input source was named "render.monitor" to figure out which device
to force the volume to 100% on, but now it will just force the volume
on all input devices it can find on the system.

The volume is forced to 100% since PESQ will be confused if the
recording is too low in volume (or even refuse to run if the recording
is done at 0% volume, which obviously will make for a bad comparison).

BUG=

Review URL: https://chromiumcodereview.appspot.com/23562002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221251 0039d316-1c4b-4281-b951-d872f2087c98
parent da2e4a94
...@@ -72,16 +72,14 @@ base::FilePath GetTestDataDir() { ...@@ -72,16 +72,14 @@ base::FilePath GetTestDataDir() {
// 4. In pavucontrol, go to the recording tab. // 4. In pavucontrol, go to the recording tab.
// 5. For the ALSA plug-in [aplay]: ALSA Capture from, change from <x> to // 5. For the ALSA plug-in [aplay]: ALSA Capture from, change from <x> to
// <Monitor of x>, where x is whatever your primary sound device is called. // <Monitor of x>, where x is whatever your primary sound device is called.
// This test expects the device id to be render.monitor - if it's something
// else, the microphone level will not get forced to 100% appropriately.
// See ForceMicrophoneVolumeTo100% for more details. You can list the
// available monitor devices on your system by running the command
// pacmd list-sources | grep name | grep monitor.
// 6. Try launching chrome as the target user on the target machine, try // 6. Try launching chrome as the target user on the target machine, try
// playing, say, a YouTube video, and record with # arecord -f dat tmp.dat. // playing, say, a YouTube video, and record with # arecord -f dat tmp.dat.
// Verify the recording with aplay (should have recorded what you played // Verify the recording with aplay (should have recorded what you played
// from chrome). // from chrome).
// //
// Note: the volume for ALL your input devices will be forced to 100% by
// running this test on Linux.
//
// On Windows 7: // On Windows 7:
// 1. Control panel > Sound > Manage audio devices. // 1. Control panel > Sound > Manage audio devices.
// 2. In the recording tab, right-click in an empty space in the pane with the // 2. In the recording tab, right-click in an empty space in the pane with the
...@@ -266,30 +264,35 @@ class AudioRecorder { ...@@ -266,30 +264,35 @@ class AudioRecorder {
base::ProcessHandle recording_application_; base::ProcessHandle recording_application_;
}; };
void ForceMicrophoneVolumeTo100Percent() { bool ForceMicrophoneVolumeTo100Percent() {
#if defined(OS_WIN) #if defined(OS_WIN)
CommandLine command_line(GetTestDataDir().Append(kToolsPath).Append( CommandLine command_line(GetTestDataDir().Append(kToolsPath).Append(
FILE_PATH_LITERAL("force_mic_volume_max.exe"))); FILE_PATH_LITERAL("force_mic_volume_max.exe")));
#else
const std::string kRecordingDeviceId = "render.monitor";
const std::string kHundredPercentVolume = "65536";
CommandLine command_line(base::FilePath(FILE_PATH_LITERAL("pacmd")));
command_line.AppendArg("set-source-volume");
command_line.AppendArg(kRecordingDeviceId);
command_line.AppendArg(kHundredPercentVolume);
#endif
LOG(INFO) << "Running " << command_line.GetCommandLineString(); LOG(INFO) << "Running " << command_line.GetCommandLineString();
std::string result; std::string result;
if (!base::GetAppOutput(command_line, &result)) { if (!base::GetAppOutput(command_line, &result)) {
// It's hard to figure out for instance the default PA recording device name LOG(ERROR) << "Failed to set source volume: output was " << result;
// for different systems, so just warn here. Users will most often have a return false;
// reasonable mic level on their systems. }
LOG(WARNING) << "Failed to set mic volume to 100% on your system. " << #else
"The test may fail or have results distorted; please ensure that " << // Just force the volume of, say the first 5 devices. A machine will rarely
"your mic level is 100% manually."; // have more input sources than that. This is way easier than finding the
// input device we happen to be using.
for (int device_index = 0; device_index < 5; ++device_index) {
std::string result;
const std::string kHundredPercentVolume = "65536";
CommandLine command_line(base::FilePath(FILE_PATH_LITERAL("pacmd")));
command_line.AppendArg("set-source-volume");
command_line.AppendArg(base::StringPrintf("%d", device_index));
command_line.AppendArg(kHundredPercentVolume);
LOG(INFO) << "Running " << command_line.GetCommandLineString();
if (!base::GetAppOutput(command_line, &result)) {
LOG(ERROR) << "Failed to set source volume: output was " << result;
return false;
}
} }
#endif
return true;
} }
// Removes silence from beginning and end of the |input_audio_file| and writes // Removes silence from beginning and end of the |input_audio_file| and writes
...@@ -414,7 +417,7 @@ IN_PROC_BROWSER_TEST_F(WebrtcAudioQualityBrowserTest, ...@@ -414,7 +417,7 @@ IN_PROC_BROWSER_TEST_F(WebrtcAudioQualityBrowserTest,
#if defined(OS_WIN) #if defined(OS_WIN)
if (base::win::GetVersion() < base::win::VERSION_VISTA) { if (base::win::GetVersion() < base::win::VERSION_VISTA) {
// It would take work to implement this on XP; not prioritized right now. // It would take work to implement this on XP; not prioritized right now.
LOG(INFO) << "This test is not implemented for Windows XP."; LOG(ERROR) << "This test is not implemented for Windows XP.";
return; return;
} }
#endif #endif
...@@ -424,7 +427,7 @@ IN_PROC_BROWSER_TEST_F(WebrtcAudioQualityBrowserTest, ...@@ -424,7 +427,7 @@ IN_PROC_BROWSER_TEST_F(WebrtcAudioQualityBrowserTest,
ASSERT_TRUE(test_server()->Start()); ASSERT_TRUE(test_server()->Start());
ASSERT_TRUE(peerconnection_server_.Start()); ASSERT_TRUE(peerconnection_server_.Start());
ForceMicrophoneVolumeTo100Percent(); ASSERT_TRUE(ForceMicrophoneVolumeTo100Percent());
ui_test_utils::NavigateToURL( ui_test_utils::NavigateToURL(
browser(), test_server()->GetURL(kMainWebrtcTestHtmlPage)); browser(), test_server()->GetURL(kMainWebrtcTestHtmlPage));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment