diff options
author | fbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-04 22:25:18 +0000 |
---|---|---|
committer | fbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-04 22:25:18 +0000 |
commit | 3ee84160f356ad78f48639b4e26eebee9a88b9c1 (patch) | |
tree | 41cdcce0762674b9eb5893d0585673d91bea53e2 /media/audio/win | |
parent | 3da33567fb3c69351d74ccb11d884e4ea9f9a21e (diff) | |
download | chromium_src-3ee84160f356ad78f48639b4e26eebee9a88b9c1.zip chromium_src-3ee84160f356ad78f48639b4e26eebee9a88b9c1.tar.gz chromium_src-3ee84160f356ad78f48639b4e26eebee9a88b9c1.tar.bz2 |
SetVolume and GetVolume take one volume instead of separate left and right volumes.
BUG=26660
TEST=no visible difference. Make sure volume still works. Code size should go down marginally.
Review URL: http://codereview.chromium.org/357004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31018 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/win')
-rw-r--r-- | media/audio/win/audio_output_win_unittest.cc | 49 | ||||
-rw-r--r-- | media/audio/win/waveout_output_win.cc | 11 | ||||
-rw-r--r-- | media/audio/win/waveout_output_win.h | 4 |
3 files changed, 29 insertions, 35 deletions
diff --git a/media/audio/win/audio_output_win_unittest.cc b/media/audio/win/audio_output_win_unittest.cc index 38a32f8..33d016d 100644 --- a/media/audio/win/audio_output_win_unittest.cc +++ b/media/audio/win/audio_output_win_unittest.cc @@ -303,7 +303,7 @@ TEST(WinAudioTest, PCMWaveStreamTripleBuffer) { EXPECT_GT(test_triple_buffer.callback_count(), kNumBuffers); EXPECT_FALSE(test_triple_buffer.had_error()); oas->Stop(); - ::Sleep(1000); + ::Sleep(500); oas->Close(); } @@ -325,11 +325,11 @@ TEST(WinAudioTest, PCMWaveSlowSource) { // The test parameters cause a callback every 32 ms and the source is // sleeping for 90 ms, so it is guaranteed that we run out of ready buffers. oas->Start(&test_laggy); - ::Sleep(1000); + ::Sleep(500); EXPECT_GT(test_laggy.callback_count(), 2); EXPECT_FALSE(test_laggy.had_error()); oas->Stop(); - ::Sleep(1000); + ::Sleep(500); oas->Close(); } @@ -353,9 +353,9 @@ TEST(WinAudioTest, PCMWaveStreamPlaySlowLoop) { size_t bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2; EXPECT_TRUE(oas->Open(bytes_100_ms)); - oas->SetVolume(1.0, 1.0); + oas->SetVolume(1.0); - for (int ix = 0; ix != 25; ++ix) { + for (int ix = 0; ix != 5; ++ix) { oas->Start(&source); ::Sleep(10); oas->Stop(); @@ -364,7 +364,7 @@ TEST(WinAudioTest, PCMWaveStreamPlaySlowLoop) { } -// This test produces actual audio for 1.5 seconds on the default wave +// This test produces actual audio for .5 seconds on the default wave // device at 44.1K s/sec. Parameters have been chosen carefully so you should // not hear pops or noises while the sound is playing. TEST(WinAudioTest, PCMWaveStreamPlay200HzTone44Kss) { @@ -384,14 +384,14 @@ TEST(WinAudioTest, PCMWaveStreamPlay200HzTone44Kss) { size_t bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2; EXPECT_TRUE(oas->Open(bytes_100_ms)); - oas->SetVolume(1.0, 1.0); + oas->SetVolume(1.0); oas->Start(&source); - ::Sleep(1500); + ::Sleep(500); oas->Stop(); oas->Close(); } -// This test produces actual audio for for 1.5 seconds on the default wave +// This test produces actual audio for for .5 seconds on the default wave // device at 22K s/sec. Parameters have been chosen carefully so you should // not hear pops or noises while the sound is playing. The audio also should // sound with a lower volume than PCMWaveStreamPlay200HzTone44Kss. @@ -413,18 +413,15 @@ TEST(WinAudioTest, PCMWaveStreamPlay200HzTone22Kss) { EXPECT_TRUE(oas->Open(bytes_100_ms)); - oas->SetVolume(0.5, 0.5); + oas->SetVolume(0.5); oas->Start(&source); - ::Sleep(1500); + ::Sleep(500); // Test that the volume is within the set limits. - double left_volume = 0.0; - double right_volume = 0.0; - oas->GetVolume(&left_volume, &right_volume); - EXPECT_LT(left_volume, 0.51); - EXPECT_GT(left_volume, 0.49); - EXPECT_LT(right_volume, 0.51); - EXPECT_GT(right_volume, 0.49); + double volume = 0.0; + oas->GetVolume(&volume); + EXPECT_LT(volume, 0.51); + EXPECT_GT(volume, 0.49); oas->Stop(); oas->Close(); } @@ -479,14 +476,14 @@ TEST(WinAudioTest, PushSourceFile16KHz) { } // Play a little bit more of the file. - ::Sleep(4000); + ::Sleep(500); oas->Stop(); oas->Close(); } // This test is to make sure an AudioOutputStream can be started after it was -// stopped. You will here two 1.5 seconds wave signal separated by 0.5 seconds +// stopped. You will here two .5 seconds wave signal separated by 0.5 seconds // of silence. TEST(WinAudioTest, PCMWaveStreamPlayTwice200HzTone44Kss) { if (IsRunningHeadless()) @@ -505,19 +502,19 @@ TEST(WinAudioTest, PCMWaveStreamPlayTwice200HzTone44Kss) { size_t bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2; EXPECT_TRUE(oas->Open(bytes_100_ms)); - oas->SetVolume(1.0, 1.0); + oas->SetVolume(1.0); - // Play the wave for 1.5 seconds. + // Play the wave for .5 seconds. oas->Start(&source); - ::Sleep(1500); + ::Sleep(500); oas->Stop(); // Sleep to give silence after stopping the AudioOutputStream. - ::Sleep(500); + ::Sleep(250); - // Start again and play for 1.5 seconds. + // Start again and play for .5 seconds. oas->Start(&source); - ::Sleep(1500); + ::Sleep(500); oas->Stop(); oas->Close(); diff --git a/media/audio/win/waveout_output_win.cc b/media/audio/win/waveout_output_win.cc index 2411527..0611da1 100644 --- a/media/audio/win/waveout_output_win.cc +++ b/media/audio/win/waveout_output_win.cc @@ -215,19 +215,16 @@ void PCMWaveOutAudioOutputStream::Close() { manager_->ReleaseStream(this); } -void PCMWaveOutAudioOutputStream::SetVolume(double left_level, - double ) { +void PCMWaveOutAudioOutputStream::SetVolume(double volume) { if (!waveout_) return; - volume_ = static_cast<float>(left_level); + volume_ = static_cast<float>(volume); } -void PCMWaveOutAudioOutputStream::GetVolume(double* left_level, - double* right_level) { +void PCMWaveOutAudioOutputStream::GetVolume(double* volume) { if (!waveout_) return; - *left_level = volume_; - *right_level = volume_; + *volume = volume_; } void PCMWaveOutAudioOutputStream::HandleError(MMRESULT error) { diff --git a/media/audio/win/waveout_output_win.h b/media/audio/win/waveout_output_win.h index 4f090ba..d965d9f 100644 --- a/media/audio/win/waveout_output_win.h +++ b/media/audio/win/waveout_output_win.h @@ -38,8 +38,8 @@ class PCMWaveOutAudioOutputStream : public AudioOutputStream { virtual void Close(); virtual void Start(AudioSourceCallback* callback); virtual void Stop(); - virtual void SetVolume(double left_level, double right_level); - virtual void GetVolume(double* left_level, double* right_level); + virtual void SetVolume(double volume); + virtual void GetVolume(double* volume); // Sends a buffer to the audio driver for playback. void QueueNextPacket(WAVEHDR* buffer); |