diff options
22 files changed, 116 insertions, 144 deletions
diff --git a/chrome/browser/renderer_host/audio_renderer_host.cc b/chrome/browser/renderer_host/audio_renderer_host.cc index 7ea64e7..a5425be 100644 --- a/chrome/browser/renderer_host/audio_renderer_host.cc +++ b/chrome/browser/renderer_host/audio_renderer_host.cc @@ -211,12 +211,12 @@ void AudioRendererHost::IPCAudioSource::Close() { state_ = kClosed; } -void AudioRendererHost::IPCAudioSource::SetVolume(double left, double right) { +void AudioRendererHost::IPCAudioSource::SetVolume(double volume) { // TODO(hclam): maybe send an error message back to renderer if this object // is in a wrong state. if (!stream_) return; - stream_->SetVolume(left, right); + stream_->SetVolume(volume); } void AudioRendererHost::IPCAudioSource::GetVolume() { @@ -224,10 +224,10 @@ void AudioRendererHost::IPCAudioSource::GetVolume() { // is in a wrong state. if (!stream_) return; - double left_channel, right_channel; - stream_->GetVolume(&left_channel, &right_channel); + double volume; + stream_->GetVolume(&volume); host_->Send(new ViewMsg_NotifyAudioStreamVolume(route_id_, stream_id_, - left_channel, right_channel)); + volume)); } size_t AudioRendererHost::IPCAudioSource::OnMoreData(AudioOutputStream* stream, @@ -315,12 +315,12 @@ void AudioRendererHost::IPCAudioSource::SubmitPacketRequest_Locked() { } void AudioRendererHost::IPCAudioSource::SubmitPacketRequest(AutoLock* alock) { - if (alock) { - SubmitPacketRequest_Locked(); - } else { - AutoLock auto_lock(lock_); - SubmitPacketRequest_Locked(); - } + if (alock) { + SubmitPacketRequest_Locked(); + } else { + AutoLock auto_lock(lock_); + SubmitPacketRequest_Locked(); + } } void AudioRendererHost::IPCAudioSource::StartBuffering() { @@ -465,11 +465,11 @@ void AudioRendererHost::OnCloseStream(const IPC::Message& msg, int stream_id) { } void AudioRendererHost::OnSetVolume(const IPC::Message& msg, int stream_id, - double left_channel, double right_channel) { + double volume) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); IPCAudioSource* source = Lookup(msg.routing_id(), stream_id); if (source) { - source->SetVolume(left_channel, right_channel); + source->SetVolume(volume); } else { SendErrorMessage(msg.routing_id(), stream_id); } diff --git a/chrome/browser/renderer_host/audio_renderer_host.h b/chrome/browser/renderer_host/audio_renderer_host.h index a1549dd..49c05c8 100644 --- a/chrome/browser/renderer_host/audio_renderer_host.h +++ b/chrome/browser/renderer_host/audio_renderer_host.h @@ -191,7 +191,7 @@ class AudioRendererHost // Sets the volume of the audio output stream. There's no IPC messages // sent back to the renderer upon success and failure. - void SetVolume(double left, double right); + void SetVolume(double volume); // Gets the volume of the audio output stream. // ViewMsg_NotifyAudioStreamVolume is sent back to renderer with volume @@ -299,8 +299,7 @@ class AudioRendererHost // ViewMsg_NotifyAudioStreamStateChanged with // AudioOutputStream::AUDIO_STREAM_ERROR is sent back to renderer if the // required IPCAudioSource is not found. - void OnSetVolume(const IPC::Message& msg, int stream_id, - double left_channel, double right_channel); + void OnSetVolume(const IPC::Message& msg, int stream_id, double volume); // Gets the volume of the stream specified, delegates to corresponding // IPCAudioSource::GetVolume(), see the method for more details. diff --git a/chrome/browser/renderer_host/audio_renderer_host_unittest.cc b/chrome/browser/renderer_host/audio_renderer_host_unittest.cc index c904a70..b4d70cd 100644 --- a/chrome/browser/renderer_host/audio_renderer_host_unittest.cc +++ b/chrome/browser/renderer_host/audio_renderer_host_unittest.cc @@ -49,8 +49,8 @@ class MockAudioRendererHost : public AudioRendererHost { void(int routing_id, int stream_id, ViewMsg_AudioStreamState state)); - MOCK_METHOD4(OnStreamVolume, - void(int routing_id, int stream_id, double left, double right)); + MOCK_METHOD3(OnStreamVolume, + void(int routing_id, int stream_id, double volume)); base::SharedMemory* shared_memory() { return shared_memory_.get(); } @@ -101,9 +101,8 @@ class MockAudioRendererHost : public AudioRendererHost { OnStreamStateChanged(msg.routing_id(), stream_id, state); } - void OnStreamVolume(const IPC::Message& msg, int stream_id, - double left, double right) { - OnStreamVolume(msg.routing_id(), stream_id, left, right); + void OnStreamVolume(const IPC::Message& msg, int stream_id, double volume) { + OnStreamVolume(msg.routing_id(), stream_id, volume); } scoped_ptr<base::SharedMemory> shared_memory_; diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 2ff15ed..38694f3 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -620,10 +620,9 @@ IPC_BEGIN_MESSAGES(View) int /* stream id */, ViewMsg_AudioStreamState /* new state */) - IPC_MESSAGE_ROUTED3(ViewMsg_NotifyAudioStreamVolume, + IPC_MESSAGE_ROUTED2(ViewMsg_NotifyAudioStreamVolume, int /* stream id */, - double /* left channel */, - double /* right channel */) + double /* volume */) // Notification that a move or resize renderer's containing window has // started. @@ -1675,10 +1674,9 @@ IPC_BEGIN_MESSAGES(ViewHost) // Set audio volume of the stream specified by (render_view_id, stream_id). // TODO(hclam): change this to vector if we have channel numbers other than 2. - IPC_MESSAGE_ROUTED3(ViewHostMsg_SetAudioVolume, + IPC_MESSAGE_ROUTED2(ViewHostMsg_SetAudioVolume, int /* stream_id */, - double /* left_channel */, - double /* right_channel */) + double /* volume */) // A renderer sends this message when an extension process starts an API // request. The browser will always respond with a ViewMsg_ExtensionResponse. diff --git a/chrome/renderer/audio_message_filter.cc b/chrome/renderer/audio_message_filter.cc index ae73988..d5cd323 100644 --- a/chrome/renderer/audio_message_filter.cc +++ b/chrome/renderer/audio_message_filter.cc @@ -94,15 +94,14 @@ void AudioMessageFilter::OnStreamStateChanged(int stream_id, delegate->OnStateChanged(state); } -void AudioMessageFilter::OnStreamVolume(int stream_id, - double left, double right) { +void AudioMessageFilter::OnStreamVolume(int stream_id, double volume) { Delegate* delegate = delegates_.Lookup(stream_id); if (!delegate) { DLOG(WARNING) << "Got audio stream event for a non-existent or removed" " audio renderer."; return; } - delegate->OnVolume(left, right); + delegate->OnVolume(volume); } int32 AudioMessageFilter::AddDelegate(Delegate* delegate) { diff --git a/chrome/renderer/audio_message_filter.h b/chrome/renderer/audio_message_filter.h index 04ff699..7516a68 100644 --- a/chrome/renderer/audio_message_filter.h +++ b/chrome/renderer/audio_message_filter.h @@ -31,10 +31,10 @@ class AudioMessageFilter : public IPC::ChannelProxy::MessageFilter { // Called when notification of stream volume is received from the browser // process. - virtual void OnVolume(double left, double right) = 0; + virtual void OnVolume(double volume) = 0; }; - AudioMessageFilter(int32 route_id); + explicit AudioMessageFilter(int32 route_id); ~AudioMessageFilter(); // Add a delegate to the map and return id of the entry. @@ -71,7 +71,7 @@ class AudioMessageFilter : public IPC::ChannelProxy::MessageFilter { void OnStreamStateChanged(int stream_id, ViewMsg_AudioStreamState state); // Notification of volume property of an audio output stream. - void OnStreamVolume(int stream_id, double left, double right); + void OnStreamVolume(int stream_id, double volume); // A map of stream ids to delegates. IDMap<Delegate> delegates_; @@ -85,4 +85,5 @@ class AudioMessageFilter : public IPC::ChannelProxy::MessageFilter { DISALLOW_COPY_AND_ASSIGN(AudioMessageFilter); }; -#endif // CHROME_RENDERER_AUDIO_MESSAGE_FITLER_H_ +#endif // CHROME_RENDERER_AUDIO_MESSAGE_FILTER_H_ + diff --git a/chrome/renderer/audio_message_filter_unittest.cc b/chrome/renderer/audio_message_filter_unittest.cc index ee60ffa..878b284 100644 --- a/chrome/renderer/audio_message_filter_unittest.cc +++ b/chrome/renderer/audio_message_filter_unittest.cc @@ -34,10 +34,9 @@ class MockAudioDelegate : public AudioMessageFilter::Delegate { length_ = length; } - virtual void OnVolume(double left, double right) { + virtual void OnVolume(double volume) { volume_received_ = true; - left_ = left; - right_ = right; + volume_ = volume; } void Reset() { @@ -53,8 +52,7 @@ class MockAudioDelegate : public AudioMessageFilter::Delegate { length_ = 0; volume_received_ = false; - left_ = 0; - right_ = 0; + volume_ = 0; } bool request_packet_received() { return request_packet_received_; } @@ -69,8 +67,7 @@ class MockAudioDelegate : public AudioMessageFilter::Delegate { size_t length() { return length_; } bool volume_received() { return volume_received_; } - double left() { return left_; } - double right() { return right_; } + double volume() { return volume_; } private: bool request_packet_received_; @@ -85,8 +82,7 @@ class MockAudioDelegate : public AudioMessageFilter::Delegate { size_t length_; bool volume_received_; - double left_; - double right_; + double volume_; DISALLOW_COPY_AND_ASSIGN(MockAudioDelegate); }; @@ -139,15 +135,12 @@ TEST(AudioMessageFilterTest, Basic) { delegate.Reset(); // ViewMsg_NotifyAudioStreamVolume - const double kLeftVolume = 1.0; - const double kRightVolume = 2.0; + const double kVolume = 1.0; EXPECT_FALSE(delegate.volume_received()); filter->OnMessageReceived( - ViewMsg_NotifyAudioStreamVolume(kRouteId, stream_id, - kLeftVolume, kRightVolume)); + ViewMsg_NotifyAudioStreamVolume(kRouteId, stream_id, kVolume)); EXPECT_TRUE(delegate.volume_received()); - EXPECT_EQ(kLeftVolume, delegate.left()); - EXPECT_EQ(kRightVolume, delegate.right()); + EXPECT_EQ(kVolume, delegate.volume()); delegate.Reset(); message_loop.RunAllPending(); diff --git a/chrome/renderer/media/audio_renderer_impl.cc b/chrome/renderer/media/audio_renderer_impl.cc index d144457..dfca1be 100644 --- a/chrome/renderer/media/audio_renderer_impl.cc +++ b/chrome/renderer/media/audio_renderer_impl.cc @@ -147,10 +147,9 @@ void AudioRendererImpl::SetVolume(float volume) { AutoLock auto_lock(lock_); if (stopped_) return; - // TODO(hclam): change this to multichannel if possible. io_loop_->PostTask(FROM_HERE, NewRunnableMethod( - this, &AudioRendererImpl::OnSetVolume, volume, volume)); + this, &AudioRendererImpl::OnSetVolume, volume)); } void AudioRendererImpl::OnCreated(base::SharedMemoryHandle handle, @@ -211,7 +210,7 @@ void AudioRendererImpl::OnStateChanged(ViewMsg_AudioStreamState state) { } } -void AudioRendererImpl::OnVolume(double left, double right) { +void AudioRendererImpl::OnVolume(double volume) { // TODO(hclam): decide whether we need to report the current volume to // pipeline. } @@ -259,13 +258,13 @@ void AudioRendererImpl::OnDestroy() { filter_->Send(new ViewHostMsg_CloseAudioStream(0, stream_id_)); } -void AudioRendererImpl::OnSetVolume(double left, double right) { +void AudioRendererImpl::OnSetVolume(double volume) { DCHECK(MessageLoop::current() == io_loop_); AutoLock auto_lock(lock_); if (stopped_) return; - filter_->Send(new ViewHostMsg_SetAudioVolume(0, stream_id_, left, right)); + filter_->Send(new ViewHostMsg_SetAudioVolume(0, stream_id_, volume)); } void AudioRendererImpl::OnNotifyPacketReady() { diff --git a/chrome/renderer/media/audio_renderer_impl.h b/chrome/renderer/media/audio_renderer_impl.h index 489bc60..aec60e7 100644 --- a/chrome/renderer/media/audio_renderer_impl.h +++ b/chrome/renderer/media/audio_renderer_impl.h @@ -120,7 +120,7 @@ class AudioRendererImpl : public media::AudioRendererBase, const base::Time& message_timestamp); void OnStateChanged(ViewMsg_AudioStreamState state); void OnCreated(base::SharedMemoryHandle handle, size_t length); - void OnVolume(double left, double right); + void OnVolume(double volume); // Methods called on pipeline thread ---------------------------------------- // media::MediaFilter implementation. @@ -159,7 +159,7 @@ class AudioRendererImpl : public media::AudioRendererBase, size_t packet_size, size_t buffer_capacity); void OnPlay(); void OnPause(); - void OnSetVolume(double left, double right); + void OnSetVolume(double volume); void OnNotifyPacketReady(); void OnDestroy(); diff --git a/media/audio/audio_output.h b/media/audio/audio_output.h index e6a1ee5..29712bf 100644 --- a/media/audio/audio_output.h +++ b/media/audio/audio_output.h @@ -91,13 +91,11 @@ class AudioOutputStream { // might have locked audio data that is processing. virtual void Stop() = 0; - // Sets the relative volume, with range [0.0, 1.0] inclusive. For mono audio - // sources the volume must be the same in both channels. - virtual void SetVolume(double left_level, double right_level) = 0; + // Sets the relative volume, with range [0.0, 1.0] inclusive. + virtual void SetVolume(double volume) = 0; - // Gets the relative volume, with range [0.0, 1.0] inclusive. For mono audio - // sources the level is returned in both channels. - virtual void GetVolume(double* left_level, double* right_level) = 0; + // Gets the relative volume, with range [0.0, 1.0] inclusive. + virtual void GetVolume(double* volume) = 0; // Close the stream. This also generates AudioSourceCallback::OnClose(). // After calling this method, the object should not be used anymore. @@ -113,11 +111,11 @@ class AudioOutputStream { class AudioManager { public: enum Format { - AUDIO_PCM_LINEAR = 0, // Pulse code modulation means 'raw' amplitude - // samples. - AUDIO_PCM_DELTA, // Delta-encoded pulse code modulation. - AUDIO_MOCK, // Creates a dummy AudioOutputStream object. - AUDIO_LAST_FORMAT // Only used for validation of format. + AUDIO_PCM_LINEAR = 0, // Pulse code modulation means 'raw' amplitude + // samples. + AUDIO_PCM_DELTA, // Delta-encoded pulse code modulation. + AUDIO_MOCK, // Creates a dummy AudioOutputStream object. + AUDIO_LAST_FORMAT // Only used for validation of format. }; // Telephone quality sample rate, mostly for speech-only audio. diff --git a/media/audio/fake_audio_output_stream.cc b/media/audio/fake_audio_output_stream.cc index af69a2f..cd57719 100644 --- a/media/audio/fake_audio_output_stream.cc +++ b/media/audio/fake_audio_output_stream.cc @@ -39,14 +39,12 @@ void FakeAudioOutputStream::Start(AudioSourceCallback* callback) { void FakeAudioOutputStream::Stop() { } -void FakeAudioOutputStream::SetVolume(double left_level, double right_level) { - left_volume_ = left_level; - right_volume_ = right_level; +void FakeAudioOutputStream::SetVolume(double volume) { + volume_ = volume; } -void FakeAudioOutputStream::GetVolume(double* left_level, double* right_level) { - *left_level = left_volume_; - *right_level = right_volume_; +void FakeAudioOutputStream::GetVolume(double* volume) { + *volume = volume_; } void FakeAudioOutputStream::Close() { @@ -59,8 +57,7 @@ void FakeAudioOutputStream::Close() { } FakeAudioOutputStream::FakeAudioOutputStream() - : left_volume_(0), - right_volume_(0), + : volume_(0), callback_(NULL), packet_size_(0) { } diff --git a/media/audio/fake_audio_output_stream.h b/media/audio/fake_audio_output_stream.h index 0cab082..5c7da82 100644 --- a/media/audio/fake_audio_output_stream.h +++ b/media/audio/fake_audio_output_stream.h @@ -22,13 +22,12 @@ class FakeAudioOutputStream : public AudioOutputStream { virtual bool Open(size_t packet_size); 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); virtual void Close(); char* buffer() { return buffer_.get(); } - double left_volume() { return left_volume_; } - double right_volume() { return right_volume_; } + double volume() { return volume_; } private: FakeAudioOutputStream(); @@ -38,8 +37,7 @@ class FakeAudioOutputStream : public AudioOutputStream { static bool has_created_fake_stream_; static FakeAudioOutputStream* last_fake_stream_; - double left_volume_; - double right_volume_; + double volume_; AudioSourceCallback* callback_; scoped_array<char> buffer_; size_t packet_size_; @@ -48,3 +46,4 @@ class FakeAudioOutputStream : public AudioOutputStream { }; #endif // MEDIA_AUDIO_FAKE_AUDIO_OUTPUT_STREAM_H_ + diff --git a/media/audio/linux/alsa_output.cc b/media/audio/linux/alsa_output.cc index 51da10d..f6091a8 100644 --- a/media/audio/linux/alsa_output.cc +++ b/media/audio/linux/alsa_output.cc @@ -350,16 +350,16 @@ void AlsaPcmOutputStream::Stop() { shared_data_.TransitionTo(kIsStopped); } -void AlsaPcmOutputStream::SetVolume(double left_level, double right_level) { +void AlsaPcmOutputStream::SetVolume(double volume) { DCHECK_EQ(MessageLoop::current(), client_thread_loop_); - shared_data_.set_volume(static_cast<float>(left_level)); + shared_data_.set_volume(static_cast<float>(volume)); } -void AlsaPcmOutputStream::GetVolume(double* left_level, double* right_level) { +void AlsaPcmOutputStream::GetVolume(double* volume) { DCHECK_EQ(MessageLoop::current(), client_thread_loop_); - *left_level = *right_level = shared_data_.volume(); + *volume = shared_data_.volume(); } void AlsaPcmOutputStream::OpenTask(size_t packet_size) { diff --git a/media/audio/linux/alsa_output.h b/media/audio/linux/alsa_output.h index 5bdaa1b..58d9ea0 100644 --- a/media/audio/linux/alsa_output.h +++ b/media/audio/linux/alsa_output.h @@ -82,8 +82,8 @@ class AlsaPcmOutputStream : 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); private: friend class AlsaPcmOutputStreamTest; diff --git a/media/audio/linux/audio_manager_linux.cc b/media/audio/linux/audio_manager_linux.cc index 9d395e8..b3d21f5 100644 --- a/media/audio/linux/audio_manager_linux.cc +++ b/media/audio/linux/audio_manager_linux.cc @@ -14,6 +14,7 @@ namespace { + AudioManagerLinux* g_audio_manager = NULL; } // namespace @@ -75,8 +76,10 @@ void AudioManagerLinux::UnMuteAll() { } void AudioManagerLinux::ReleaseStream(AlsaPcmOutputStream* stream) { - AutoLock l(lock_); - active_streams_.erase(stream); + if (stream) { + AutoLock l(lock_); + active_streams_.erase(stream); + } } // TODO(ajwong): Collapse this with the windows version. diff --git a/media/audio/mac/audio_output_mac.cc b/media/audio/mac/audio_output_mac.cc index 42e80a1..24dc86b 100644 --- a/media/audio/mac/audio_output_mac.cc +++ b/media/audio/mac/audio_output_mac.cc @@ -146,25 +146,22 @@ void PCMQueueOutAudioOutputStream::Stop() { HandleError(err); } -void PCMQueueOutAudioOutputStream::SetVolume(double left_level, - double ) { +void PCMQueueOutAudioOutputStream::SetVolume(double volume) { if (!audio_queue_) return; - volume_ = static_cast<float>(left_level); + volume_ = static_cast<float>(volume); OSStatus err = AudioQueueSetParameter(audio_queue_, kAudioQueueParam_Volume, - left_level); + volume); if (err != noErr) { HandleError(err); } } -void PCMQueueOutAudioOutputStream::GetVolume(double* left_level, - double* right_level) { +void PCMQueueOutAudioOutputStream::GetVolume(double* volume) { if (!audio_queue_) return; - *left_level = volume_; - *right_level = volume_; + *volume = volume_; } // Reorder PCM from AAC layout to Core Audio layout. diff --git a/media/audio/mac/audio_output_mac.h b/media/audio/mac/audio_output_mac.h index 14afff7..10fc229 100644 --- a/media/audio/mac/audio_output_mac.h +++ b/media/audio/mac/audio_output_mac.h @@ -33,8 +33,8 @@ class PCMQueueOutAudioOutputStream : 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); private: // The audio is double buffered. diff --git a/media/audio/mac/audio_output_mac_unittest.cc b/media/audio/mac/audio_output_mac_unittest.cc index a517e95..985ca45 100644 --- a/media/audio/mac/audio_output_mac_unittest.cc +++ b/media/audio/mac/audio_output_mac_unittest.cc @@ -92,19 +92,15 @@ TEST(MacAudioTest, PCMWaveStreamPlay200HzTone44KssMono) { EXPECT_TRUE(oas->Open(bytes_100_ms)); - oas->SetVolume(0.5, 0.5); + oas->SetVolume(0.5); oas->Start(&source); usleep(1500000); // 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(); } 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); diff --git a/media/filters/audio_renderer_impl.cc b/media/filters/audio_renderer_impl.cc index c8c445c..0f6c4a9 100644 --- a/media/filters/audio_renderer_impl.cc +++ b/media/filters/audio_renderer_impl.cc @@ -47,7 +47,7 @@ void AudioRendererImpl::SetPlaybackRate(float rate) { void AudioRendererImpl::SetVolume(float volume) { if (stream_) - stream_->SetVolume(volume, volume); + stream_->SetVolume(volume); } size_t AudioRendererImpl::OnMoreData(AudioOutputStream* stream, void* dest_void, |