diff options
author | enal@chromium.org <enal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-24 18:02:04 +0000 |
---|---|---|
committer | enal@chromium.org <enal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-24 18:02:04 +0000 |
commit | e6b05e8c5d2d8cc56d6f6c238ff7cf674d05c4b6 (patch) | |
tree | a4ad67abf8535066886876d55533f83a6d80f4e3 | |
parent | cd187678ad319a37e01acc91e80d0ebc419cecc4 (diff) | |
download | chromium_src-e6b05e8c5d2d8cc56d6f6c238ff7cf674d05c4b6.zip chromium_src-e6b05e8c5d2d8cc56d6f6c238ff7cf674d05c4b6.tar.gz chromium_src-e6b05e8c5d2d8cc56d6f6c238ff7cf674d05c4b6.tar.bz2 |
Remove unused parameter "stream" from all variants of OnMoreData().
(Also fixing some minor lint errors...)
Review URL: http://codereview.chromium.org/10184011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133726 0039d316-1c4b-4281-b951-d872f2087c98
25 files changed, 79 insertions, 89 deletions
diff --git a/media/audio/android/audio_track_output_android.cc b/media/audio/android/audio_track_output_android.cc index 7342750..2905f6b 100644 --- a/media/audio/android/audio_track_output_android.cc +++ b/media/audio/android/audio_track_output_android.cc @@ -4,6 +4,8 @@ #include "media/audio/android/audio_track_output_android.h" +#include <algorithm> // std::min + #include "base/android/jni_android.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" @@ -288,7 +290,6 @@ void AudioTrackOutputStream::FillAudioBufferTask() { // Fill the internal buffer first. if (!data_buffer_->data_len()) { uint32 src_data_size = source_callback_->OnMoreData( - this, data_buffer_->GetWritableBuffer(), data_buffer_->buffer_size(), AudioBuffersState()); diff --git a/media/audio/android/opensles_output.cc b/media/audio/android/opensles_output.cc index 3464135..23d7eb5 100644 --- a/media/audio/android/opensles_output.cc +++ b/media/audio/android/opensles_output.cc @@ -252,7 +252,6 @@ void OpenSLESOutputStream::FillBufferQueue() { // TODO(xians): Get an accurate delay estimation. uint32 hardware_delay = buffer_size_bytes_; size_t num_filled_bytes = callback_->OnMoreData( - this, audio_data_[active_queue_], buffer_size_bytes_, AudioBuffersState(0, hardware_delay)); diff --git a/media/audio/audio_io.h b/media/audio/audio_io.h index cb83576..8487214 100644 --- a/media/audio/audio_io.h +++ b/media/audio/audio_io.h @@ -65,9 +65,9 @@ class MEDIA_EXPORT AudioOutputStream { // platform and format specific. // |buffers_state| contains current state of the buffers, and can be used // by the source to calculate delay. - virtual uint32 OnMoreData( - AudioOutputStream* stream, uint8* dest, uint32 max_size, - AudioBuffersState buffers_state) = 0; + virtual uint32 OnMoreData(uint8* dest, + uint32 max_size, + AudioBuffersState buffers_state) = 0; // There was an error while playing a buffer. Audio source cannot be // destroyed yet. No direct action needed by the AudioStream, but it is diff --git a/media/audio/audio_low_latency_input_output_unittest.cc b/media/audio/audio_low_latency_input_output_unittest.cc index 8d501ca..1ee4c40 100644 --- a/media/audio/audio_low_latency_input_output_unittest.cc +++ b/media/audio/audio_low_latency_input_output_unittest.cc @@ -218,8 +218,8 @@ class FullDuplexAudioSinkSource virtual void OnError(AudioInputStream* stream, int code) OVERRIDE {} // AudioOutputStream::AudioSourceCallback. - virtual uint32 OnMoreData(AudioOutputStream* stream, - uint8* dest, uint32 max_size, + virtual uint32 OnMoreData(uint8* dest, + uint32 max_size, AudioBuffersState buffers_state) OVERRIDE { base::AutoLock lock(lock_); diff --git a/media/audio/audio_output_controller.cc b/media/audio/audio_output_controller.cc index f5646f2..c136432 100644 --- a/media/audio/audio_output_controller.cc +++ b/media/audio/audio_output_controller.cc @@ -276,9 +276,9 @@ void AudioOutputController::DoReportError(int code) { handler_->OnError(this, code); } -uint32 AudioOutputController::OnMoreData( - AudioOutputStream* stream, uint8* dest, - uint32 max_size, AudioBuffersState buffers_state) { +uint32 AudioOutputController::OnMoreData(uint8* dest, + uint32 max_size, + AudioBuffersState buffers_state) { TRACE_EVENT0("audio", "AudioOutputController::OnMoreData"); { diff --git a/media/audio/audio_output_controller.h b/media/audio/audio_output_controller.h index 09878c6..3c969ff 100644 --- a/media/audio/audio_output_controller.h +++ b/media/audio/audio_output_controller.h @@ -147,8 +147,7 @@ class MEDIA_EXPORT AudioOutputController /////////////////////////////////////////////////////////////////////////// // AudioSourceCallback methods. - virtual uint32 OnMoreData(AudioOutputStream* stream, - uint8* dest, + virtual uint32 OnMoreData(uint8* dest, uint32 max_size, AudioBuffersState buffers_state) OVERRIDE; virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE; diff --git a/media/audio/audio_output_mixer.cc b/media/audio/audio_output_mixer.cc index d091672..c4537d1 100644 --- a/media/audio/audio_output_mixer.cc +++ b/media/audio/audio_output_mixer.cc @@ -145,8 +145,7 @@ void AudioOutputMixer::ClosePhysicalStream() { } // AudioSourceCallback implementation. -uint32 AudioOutputMixer::OnMoreData(AudioOutputStream* stream, - uint8* dest, +uint32 AudioOutputMixer::OnMoreData(uint8* dest, uint32 max_size, AudioBuffersState buffers_state) { max_size = std::min(max_size, @@ -169,7 +168,6 @@ uint32 AudioOutputMixer::OnMoreData(AudioOutputStream* stream, bool first_stream = true; uint8* actual_dest = dest; for (ProxyMap::iterator it = proxies_.begin(); it != proxies_.end(); ++it) { - AudioOutputProxy* stream_proxy = it->first; ProxyData* proxy_data = &it->second; // TODO(enal): We don't know |pending _bytes| for individual stream, and we // should give that value to individual stream's OnMoreData(). I believe it @@ -184,7 +182,6 @@ uint32 AudioOutputMixer::OnMoreData(AudioOutputStream* stream, // Note: there is no way we can deduce hardware_delay_bytes for the // particular proxy stream. Use zero instead. uint32 actual_size = proxy_data->audio_source_callback->OnMoreData( - stream_proxy, actual_dest, max_size, AudioBuffersState(pending_bytes, 0)); diff --git a/media/audio/audio_output_mixer.h b/media/audio/audio_output_mixer.h index ae94b5f..532f27e 100644 --- a/media/audio/audio_output_mixer.h +++ b/media/audio/audio_output_mixer.h @@ -43,8 +43,7 @@ class MEDIA_EXPORT AudioOutputMixer virtual void Shutdown() OVERRIDE; // AudioSourceCallback interface. - virtual uint32 OnMoreData(AudioOutputStream* stream, - uint8* dest, + virtual uint32 OnMoreData(uint8* dest, uint32 max_size, AudioBuffersState buffers_state) OVERRIDE; virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE; diff --git a/media/audio/audio_output_proxy_unittest.cc b/media/audio/audio_output_proxy_unittest.cc index a3adbac..674c200 100644 --- a/media/audio/audio_output_proxy_unittest.cc +++ b/media/audio/audio_output_proxy_unittest.cc @@ -71,8 +71,7 @@ class MockAudioManager : public AudioManager { class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback { public: - MOCK_METHOD4(OnMoreData, uint32(AudioOutputStream* stream, - uint8* dest, uint32 max_size, + MOCK_METHOD3(OnMoreData, uint32(uint8* dest, uint32 max_size, AudioBuffersState buffers_state)); MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code)); }; diff --git a/media/audio/fake_audio_output_stream.cc b/media/audio/fake_audio_output_stream.cc index 686ccde..aaa6158 100644 --- a/media/audio/fake_audio_output_stream.cc +++ b/media/audio/fake_audio_output_stream.cc @@ -38,7 +38,7 @@ FakeAudioOutputStream* FakeAudioOutputStream::GetCurrentFakeStream() { void FakeAudioOutputStream::Start(AudioSourceCallback* callback) { callback_ = callback; memset(buffer_.get(), 0, bytes_per_buffer_); - callback_->OnMoreData(this, buffer_.get(), bytes_per_buffer_, + callback_->OnMoreData(buffer_.get(), bytes_per_buffer_, AudioBuffersState(0, 0)); } diff --git a/media/audio/linux/alsa_output.cc b/media/audio/linux/alsa_output.cc index 9ed2df0..ce301ce 100644 --- a/media/audio/linux/alsa_output.cc +++ b/media/audio/linux/alsa_output.cc @@ -385,7 +385,7 @@ void AlsaPcmOutputStream::BufferPacket(bool* source_exhausted) { // that aren't large enough to make a frame. Without this, packet writing // may stall because the last few bytes in the packet may never get used by // WritePacket. - DCHECK(packet_size % bytes_per_frame_ == 0); + DCHECK_EQ(0u, packet_size % bytes_per_frame_); packet_size = (packet_size / bytes_per_frame_) * bytes_per_frame_; if (should_downmix_) { @@ -792,7 +792,7 @@ uint32 AlsaPcmOutputStream::RunDataCallback(uint8* dest, TRACE_EVENT0("audio", "AlsaPcmOutputStream::RunDataCallback"); if (source_callback_) - return source_callback_->OnMoreData(this, dest, max_size, buffers_state); + return source_callback_->OnMoreData(dest, max_size, buffers_state); return 0; } diff --git a/media/audio/linux/alsa_output_unittest.cc b/media/audio/linux/alsa_output_unittest.cc index be605c1..4b314ce 100644 --- a/media/audio/linux/alsa_output_unittest.cc +++ b/media/audio/linux/alsa_output_unittest.cc @@ -69,8 +69,7 @@ class MockAlsaWrapper : public AlsaWrapper { class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback { public: - MOCK_METHOD4(OnMoreData, uint32(AudioOutputStream* stream, - uint8* dest, uint32 max_size, + MOCK_METHOD3(OnMoreData, uint32(uint8* dest, uint32 max_size, AudioBuffersState buffers_state)); MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code)); }; @@ -440,8 +439,7 @@ TEST_F(AlsaPcmOutputStreamTest, StartStop) { EXPECT_CALL(mock_alsa_wrapper_, PcmDelay(kFakeHandle, _)) .Times(2) .WillRepeatedly(DoAll(SetArgumentPointee<1>(0), Return(0))); - EXPECT_CALL(mock_callback, - OnMoreData(test_stream, _, kTestPacketSize, _)) + EXPECT_CALL(mock_callback, OnMoreData(_, kTestPacketSize, _)) .Times(2) .WillOnce(Return(kTestPacketSize)) .WillOnce(Return(0)); @@ -559,8 +557,7 @@ TEST_F(AlsaPcmOutputStreamTest, BufferPacket) { .WillRepeatedly(Return(0)); // Buffer is full. // Return a partially filled packet. - EXPECT_CALL(mock_callback, - OnMoreData(test_stream, _, _, _)) + EXPECT_CALL(mock_callback, OnMoreData(_, _, _)) .WillOnce(Return(10)); bool source_exhausted; @@ -586,7 +583,7 @@ TEST_F(AlsaPcmOutputStreamTest, BufferPacket_Negative) { .WillOnce(DoAll(SetArgumentPointee<1>(-1), Return(0))); EXPECT_CALL(mock_alsa_wrapper_, PcmAvailUpdate(_)) .WillRepeatedly(Return(0)); // Buffer is full. - EXPECT_CALL(mock_callback, OnMoreData(test_stream, _, _, _)) + EXPECT_CALL(mock_callback, OnMoreData(_, _, _)) .WillOnce(Return(10)); bool source_exhausted; @@ -611,7 +608,7 @@ TEST_F(AlsaPcmOutputStreamTest, BufferPacket_Underrun) { EXPECT_CALL(mock_alsa_wrapper_, PcmAvailUpdate(_)) .WillRepeatedly(Return(0)); // Buffer is full. EXPECT_CALL(mock_callback, - OnMoreData(test_stream, _, _, AllOf( + OnMoreData(_, _, AllOf( Field(&AudioBuffersState::pending_bytes, 0), Field(&AudioBuffersState::hardware_delay_bytes, 0)))) .WillOnce(Return(10)); diff --git a/media/audio/linux/cras_output.cc b/media/audio/linux/cras_output.cc index 28a991b..4de1256 100644 --- a/media/audio/linux/cras_output.cc +++ b/media/audio/linux/cras_output.cc @@ -267,7 +267,7 @@ uint32 CrasOutputStream::Render(size_t frames, uint32 frames_latency = latency_usec * frame_rate_ / 1000000; uint32 bytes_latency = frames_latency * bytes_per_frame; - uint32 rendered = source_callback_->OnMoreData(this, buffer, + uint32 rendered = source_callback_->OnMoreData(buffer, frames * bytes_per_frame, AudioBuffersState(0, bytes_latency)); return rendered / bytes_per_frame; @@ -276,7 +276,7 @@ uint32 CrasOutputStream::Render(size_t frames, void CrasOutputStream::NotifyStreamError(int err) { // This will remove the stream from the client. if (state_ == kIsClosed || state_ == kInError) - return; // Don't care about error if we aren't using it. + return; // Don't care about error if we aren't using it. TransitionTo(kInError); if (source_callback_) source_callback_->OnError(this, err); diff --git a/media/audio/linux/cras_output_unittest.cc b/media/audio/linux/cras_output_unittest.cc index 08f441d..5996808 100644 --- a/media/audio/linux/cras_output_unittest.cc +++ b/media/audio/linux/cras_output_unittest.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <string> + #include "media/audio/linux/audio_manager_linux.h" #include "media/audio/linux/cras_output.h" #include "testing/gmock/include/gmock/gmock.h" @@ -17,8 +19,7 @@ namespace media { class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback { public: - MOCK_METHOD4(OnMoreData, uint32(AudioOutputStream* stream, - uint8* dest, uint32 max_size, + MOCK_METHOD3(OnMoreData, uint32(uint8* dest, uint32 max_size, AudioBuffersState buffers_state)); MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code)); }; @@ -120,7 +121,7 @@ struct cras_client* const CrasOutputStreamTest::kFakeClient = TEST_F(CrasOutputStreamTest, ConstructedState) { // Should support mono. - CrasOutputStream *test_stream = CreateStream(CHANNEL_LAYOUT_MONO); + CrasOutputStream* test_stream = CreateStream(CHANNEL_LAYOUT_MONO); EXPECT_EQ(CrasOutputStream::kCreated, test_stream->state()); test_stream->Close(); @@ -154,7 +155,7 @@ TEST_F(CrasOutputStreamTest, ConstructedState) { } TEST_F(CrasOutputStreamTest, OpenClose) { - CrasOutputStream *test_stream = CreateStream(CHANNEL_LAYOUT_MONO); + CrasOutputStream* test_stream = CreateStream(CHANNEL_LAYOUT_MONO); // Open the stream. ASSERT_TRUE(test_stream->Open()); EXPECT_EQ(CrasOutputStream::kIsOpened, test_stream->state()); @@ -164,7 +165,7 @@ TEST_F(CrasOutputStreamTest, OpenClose) { } TEST_F(CrasOutputStreamTest, StartFailBeforeOpen) { - CrasOutputStream *test_stream = CreateStream(CHANNEL_LAYOUT_MONO); + CrasOutputStream* test_stream = CreateStream(CHANNEL_LAYOUT_MONO); MockAudioSourceCallback mock_callback; test_stream->Start(&mock_callback); @@ -172,7 +173,7 @@ TEST_F(CrasOutputStreamTest, StartFailBeforeOpen) { } TEST_F(CrasOutputStreamTest, StartStop) { - CrasOutputStream *test_stream = CreateStream(CHANNEL_LAYOUT_MONO); + CrasOutputStream* test_stream = CreateStream(CHANNEL_LAYOUT_MONO); MockAudioSourceCallback mock_callback; // Open the stream. @@ -192,7 +193,7 @@ TEST_F(CrasOutputStreamTest, StartStop) { } TEST_F(CrasOutputStreamTest, RenderFrames) { - CrasOutputStream *test_stream = CreateStream(CHANNEL_LAYOUT_MONO); + CrasOutputStream* test_stream = CreateStream(CHANNEL_LAYOUT_MONO); MockAudioSourceCallback mock_callback; const uint32 amount_rendered_return = 2048; @@ -201,7 +202,7 @@ TEST_F(CrasOutputStreamTest, RenderFrames) { EXPECT_EQ(CrasOutputStream::kIsOpened, test_stream->state()); // Render Callback. - EXPECT_CALL(mock_callback, OnMoreData(test_stream, _, + EXPECT_CALL(mock_callback, OnMoreData(_, kTestFramesPerPacket * kTestBytesPerFrame, _)) .WillRepeatedly(Return(amount_rendered_return)); diff --git a/media/audio/mac/audio_low_latency_output_mac.cc b/media/audio/mac/audio_low_latency_output_mac.cc index b1f15dd..d9127f8 100644 --- a/media/audio/mac/audio_low_latency_output_mac.cc +++ b/media/audio/mac/audio_low_latency_output_mac.cc @@ -227,7 +227,7 @@ OSStatus AUAudioOutputStream::Render(UInt32 number_of_frames, uint32 hardware_pending_bytes = static_cast<uint32> ((playout_latency_frames + 0.5) * format_.mBytesPerFrame); uint32 filled = source_->OnMoreData( - this, audio_data, buffer.mDataByteSize, + audio_data, buffer.mDataByteSize, AudioBuffersState(0, hardware_pending_bytes)); // Handle channel order for 5.1 audio. diff --git a/media/audio/mac/audio_output_mac.cc b/media/audio/mac/audio_output_mac.cc index 8328a01..761750f 100644 --- a/media/audio/mac/audio_output_mac.cc +++ b/media/audio/mac/audio_output_mac.cc @@ -407,7 +407,7 @@ void PCMQueueOutAudioOutputStream::RenderCallback(void* p_this, uint32 capacity = buffer->mAudioDataBytesCapacity; // TODO(sergeyu): Specify correct hardware delay for AudioBuffersState. uint32 filled = source->OnMoreData( - audio_stream, reinterpret_cast<uint8*>(buffer->mAudioData), capacity, + reinterpret_cast<uint8*>(buffer->mAudioData), capacity, AudioBuffersState(audio_stream->pending_bytes_, 0)); // In order to keep the callback running, we need to provide a positive amount diff --git a/media/audio/mac/audio_output_mac_unittest.cc b/media/audio/mac/audio_output_mac_unittest.cc index 0724883..bc0a7ce 100644 --- a/media/audio/mac/audio_output_mac_unittest.cc +++ b/media/audio/mac/audio_output_mac_unittest.cc @@ -24,7 +24,7 @@ namespace media { class MockAudioSource : public AudioOutputStream::AudioSourceCallback { public: - MOCK_METHOD4(OnMoreData, uint32(AudioOutputStream* stream, uint8* dest, + MOCK_METHOD3(OnMoreData, uint32(uint8* dest, uint32 max_size, AudioBuffersState buffers_state)); MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code)); @@ -41,7 +41,7 @@ TEST(MacAudioTest, SineWaveAudio16MonoTest) { // TODO(cpu): Put the real test when the mock renderer is ported. uint16 buffer[samples] = { 0xffff }; - source.OnMoreData(NULL, reinterpret_cast<uint8*>(buffer), sizeof(buffer), + source.OnMoreData(reinterpret_cast<uint8*>(buffer), sizeof(buffer), AudioBuffersState(0, 0)); EXPECT_EQ(0, buffer[0]); EXPECT_EQ(5126, buffer[1]); @@ -131,8 +131,9 @@ TEST(MacAudioTest, PCMWaveStreamPlay200HzTone22KssMono) { } // Custom action to clear a memory buffer. -static void ClearBuffer(AudioOutputStream* stream, uint8* dest, - uint32 max_size, AudioBuffersState buffers_state) { +static void ClearBuffer(uint8* dest, + uint32 max_size, + AudioBuffersState buffers_state) { memset(dest, 0, max_size); } @@ -157,18 +158,18 @@ TEST(MacAudioTest, PCMWaveStreamPendingBytes) { // And then we will try to provide zero data so the amount of pending bytes // will go down and eventually read zero. InSequence s; - EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, + EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms, Field(&AudioBuffersState::pending_bytes, 0))) .WillOnce(DoAll(Invoke(&ClearBuffer), Return(bytes_100_ms))); - EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, + EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms, Field(&AudioBuffersState::pending_bytes, bytes_100_ms))) .WillOnce(DoAll(Invoke(&ClearBuffer), Return(bytes_100_ms))); - EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, + EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms, Field(&AudioBuffersState::pending_bytes, bytes_100_ms))) .WillOnce(Return(0)); - EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, _)) + EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms, _)) .Times(AnyNumber()) .WillRepeatedly(Return(0)); diff --git a/media/audio/pulse/pulse_output.cc b/media/audio/pulse/pulse_output.cc index 651d1f7..df4b5be 100644 --- a/media/audio/pulse/pulse_output.cc +++ b/media/audio/pulse/pulse_output.cc @@ -424,7 +424,7 @@ void PulseAudioOutputStream::GetVolume(double* volume) { uint32 PulseAudioOutputStream::RunDataCallback( uint8* dest, uint32 max_size, AudioBuffersState buffers_state) { if (source_callback_) - return source_callback_->OnMoreData(this, dest, max_size, buffers_state); + return source_callback_->OnMoreData(dest, max_size, buffers_state); return 0; } diff --git a/media/audio/simple_sources.cc b/media/audio/simple_sources.cc index 8b85961..e18f208 100644 --- a/media/audio/simple_sources.cc +++ b/media/audio/simple_sources.cc @@ -4,8 +4,8 @@ #include "media/audio/simple_sources.h" -#include <algorithm> #include <math.h> +#include <algorithm> #include "base/basictypes.h" #include "base/logging.h" @@ -32,8 +32,7 @@ SineWaveAudioSource::SineWaveAudioSource(Format format, int channels, // The implementation could be more efficient if a lookup table is constructed // but it is efficient enough for our simple needs. uint32 SineWaveAudioSource::OnMoreData( - AudioOutputStream* stream, uint8* dest, uint32 max_size, - AudioBuffersState audio_buffers) { + uint8* dest, uint32 max_size, AudioBuffersState audio_buffers) { const double kTwoPi = 2.0 * 3.141592653589; double f = freq_ / sample_freq_; int16* sin_tbl = reinterpret_cast<int16*>(dest); @@ -67,8 +66,7 @@ PushSource::PushSource() PushSource::~PushSource() { } uint32 PushSource::OnMoreData( - AudioOutputStream* stream, uint8* dest, uint32 max_size, - AudioBuffersState buffers_state) { + uint8* dest, uint32 max_size, AudioBuffersState buffers_state) { return buffer_.Read(dest, max_size); } diff --git a/media/audio/simple_sources.h b/media/audio/simple_sources.h index fa06857..6c66b64 100644 --- a/media/audio/simple_sources.h +++ b/media/audio/simple_sources.h @@ -29,8 +29,7 @@ class MEDIA_EXPORT SineWaveAudioSource // Implementation of AudioSourceCallback. virtual uint32 OnMoreData( - AudioOutputStream* stream, uint8* dest, uint32 max_size, - AudioBuffersState audio_buffers) OVERRIDE; + uint8* dest, uint32 max_size, AudioBuffersState audio_buffers) OVERRIDE; virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE; protected: @@ -74,8 +73,7 @@ class MEDIA_EXPORT PushSource virtual uint32 UnProcessedBytes() OVERRIDE; // Implementation of AudioSourceCallback. - virtual uint32 OnMoreData(AudioOutputStream* stream, - uint8* dest, + virtual uint32 OnMoreData(uint8* dest, uint32 max_size, AudioBuffersState buffers_state) OVERRIDE; virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE; diff --git a/media/audio/simple_sources_unittest.cc b/media/audio/simple_sources_unittest.cc index 1e19fd8..74d19f2 100644 --- a/media/audio/simple_sources_unittest.cc +++ b/media/audio/simple_sources_unittest.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <algorithm> // std::min + #include "base/logging.h" #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" @@ -51,7 +53,7 @@ TEST(SimpleSourcesTest, PushSourceSmallerWrite) { // Read everything from the push source. for (uint32 i = 0; i < kDataSize; i += kReadSize) { uint32 size = std::min(kDataSize - i , kReadSize); - EXPECT_EQ(size, push_source.OnMoreData(NULL, read_data.get(), size, + EXPECT_EQ(size, push_source.OnMoreData(read_data.get(), size, AudioBuffersState())); EXPECT_EQ(0, memcmp(data.get() + i, read_data.get(), size)); } diff --git a/media/audio/win/audio_low_latency_output_win.cc b/media/audio/win/audio_low_latency_output_win.cc index ec0fcd2..0ac8e17 100644 --- a/media/audio/win/audio_low_latency_output_win.cc +++ b/media/audio/win/audio_low_latency_output_win.cc @@ -440,7 +440,7 @@ void WASAPIAudioOutputStream::Run() { // the delay between the usage of the delay value and the time // of generation. uint32 num_filled_bytes = source_->OnMoreData( - this, audio_data, packet_size_bytes_, + audio_data, packet_size_bytes_, AudioBuffersState(0, audio_delay_bytes)); // Perform in-place, software-volume adjustments. diff --git a/media/audio/win/audio_low_latency_output_win_unittest.cc b/media/audio/win/audio_low_latency_output_win_unittest.cc index f90ce65..85d6f5f 100644 --- a/media/audio/win/audio_low_latency_output_win_unittest.cc +++ b/media/audio/win/audio_low_latency_output_win_unittest.cc @@ -53,8 +53,7 @@ MATCHER_P(HasValidDelay, value, "") { class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback { public: - MOCK_METHOD4(OnMoreData, uint32(AudioOutputStream* stream, - uint8* dest, + MOCK_METHOD3(OnMoreData, uint32(uint8* dest, uint32 max_size, AudioBuffersState buffers_state)); MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code)); @@ -103,8 +102,7 @@ class ReadFromFileAudioSource : public AudioOutputStream::AudioSourceCallback { } // AudioOutputStream::AudioSourceCallback implementation. - virtual uint32 OnMoreData(AudioOutputStream* stream, - uint8* dest, + virtual uint32 OnMoreData(uint8* dest, uint32 max_size, AudioBuffersState buffers_state) { // Store time difference between two successive callbacks in an array. @@ -400,7 +398,7 @@ TEST(WinAudioOutputTest, WASAPIAudioOutputStreamTestPacketSizeInMilliseconds) { AudioBuffersState state(0, bytes_per_packet); // Wait for the first callback and verify its parameters. - EXPECT_CALL(source, OnMoreData(aos, NotNull(), bytes_per_packet, + EXPECT_CALL(source, OnMoreData(NotNull(), bytes_per_packet, HasValidDelay(state))) .WillOnce( DoAll( @@ -442,7 +440,7 @@ TEST(WinAudioOutputTest, WASAPIAudioOutputStreamTestPacketSizeInSamples) { AudioBuffersState state(0, bytes_per_packet); // Wait for the first callback and verify its parameters. - EXPECT_CALL(source, OnMoreData(aos, NotNull(), bytes_per_packet, + EXPECT_CALL(source, OnMoreData(NotNull(), bytes_per_packet, HasValidDelay(state))) .WillOnce( DoAll( @@ -488,7 +486,7 @@ TEST(WinAudioOutputTest, WASAPIAudioOutputStreamTestMono) { // Set up expected minimum delay estimation. AudioBuffersState state(0, bytes_per_packet); - EXPECT_CALL(source, OnMoreData(aos, NotNull(), bytes_per_packet, + EXPECT_CALL(source, OnMoreData(NotNull(), bytes_per_packet, HasValidDelay(state))) .WillOnce( DoAll( diff --git a/media/audio/win/audio_output_win_unittest.cc b/media/audio/win/audio_output_win_unittest.cc index 11b5693..4066643 100644 --- a/media/audio/win/audio_output_win_unittest.cc +++ b/media/audio/win/audio_output_win_unittest.cc @@ -45,8 +45,9 @@ class TestSourceBasic : public AudioOutputStream::AudioSourceCallback { had_error_(0) { } // AudioSourceCallback::OnMoreData implementation: - virtual uint32 OnMoreData(AudioOutputStream* stream, uint8* dest, - uint32 max_size, AudioBuffersState buffers_state) { + virtual uint32 OnMoreData(uint8* dest, + uint32 max_size, + AudioBuffersState buffers_state) { ++callback_count_; // Touch the first byte to make sure memory is good. if (max_size) @@ -86,11 +87,11 @@ class TestSourceTripleBuffer : public TestSourceBasic { buffer_address_[2] = NULL; } // Override of TestSourceBasic::OnMoreData. - virtual uint32 OnMoreData(AudioOutputStream* stream, - uint8* dest, uint32 max_size, + virtual uint32 OnMoreData(uint8* dest, + uint32 max_size, AudioBuffersState buffers_state) { // Call the base, which increments the callback_count_. - TestSourceBasic::OnMoreData(stream, dest, max_size, buffers_state); + TestSourceBasic::OnMoreData(dest, max_size, buffers_state); if (callback_count() % kNumBuffers == 2) { set_error(!CompareExistingIfNotNULL(2, dest)); } else if (callback_count() % kNumBuffers == 1) { @@ -123,11 +124,11 @@ class TestSourceLaggy : public TestSourceBasic { TestSourceLaggy(int laggy_after_buffer, int lag_in_ms) : laggy_after_buffer_(laggy_after_buffer), lag_in_ms_(lag_in_ms) { } - virtual uint32 OnMoreData(AudioOutputStream* stream, - uint8* dest, uint32 max_size, + virtual uint32 OnMoreData(uint8* dest, + uint32 max_size, AudioBuffersState buffers_state) { // Call the base, which increments the callback_count_. - TestSourceBasic::OnMoreData(stream, dest, max_size, buffers_state); + TestSourceBasic::OnMoreData(dest, max_size, buffers_state); if (callback_count() > kNumBuffers) { ::Sleep(lag_in_ms_); } @@ -140,7 +141,7 @@ class TestSourceLaggy : public TestSourceBasic { class MockAudioSource : public AudioOutputStream::AudioSourceCallback { public: - MOCK_METHOD4(OnMoreData, uint32(AudioOutputStream* stream, uint8* dest, + MOCK_METHOD3(OnMoreData, uint32(uint8* dest, uint32 max_size, AudioBuffersState buffers_state)); MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code)); @@ -605,28 +606,28 @@ TEST(WinAudioTest, PCMWaveStreamPendingBytes) { // new one. And then we will try to provide zero data so the amount of // pending bytes will go down and eventually read zero. InSequence s; - EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, + EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms, Field(&AudioBuffersState::pending_bytes, 0))) .WillOnce(Return(bytes_100_ms)); - EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, + EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms, Field(&AudioBuffersState::pending_bytes, bytes_100_ms))) .WillOnce(Return(bytes_100_ms)); - EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, + EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms, Field(&AudioBuffersState::pending_bytes, 2 * bytes_100_ms))) .WillOnce(Return(bytes_100_ms)); - EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, + EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms, Field(&AudioBuffersState::pending_bytes, 2 * bytes_100_ms))) .Times(AnyNumber()) .WillRepeatedly(Return(0)); - EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, + EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms, Field(&AudioBuffersState::pending_bytes, bytes_100_ms))) .Times(AnyNumber()) .WillRepeatedly(Return(0)); - EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, + EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms, Field(&AudioBuffersState::pending_bytes, 0))) .Times(AnyNumber()) .WillRepeatedly(Return(0)); @@ -648,8 +649,8 @@ class SyncSocketSource : public AudioOutputStream::AudioSourceCallback { } // AudioSourceCallback::OnMoreData implementation: - virtual uint32 OnMoreData(AudioOutputStream* stream, - uint8* dest, uint32 max_size, + virtual uint32 OnMoreData(uint8* dest, + uint32 max_size, AudioBuffersState buffers_state) { socket_->Send(&buffers_state, sizeof(buffers_state)); uint32 got = socket_->Receive(dest, max_size); @@ -684,7 +685,7 @@ DWORD __stdcall SyncSocketThread(void* context) { uint8* buffer = new uint8[kTwoSecBytes]; SineWaveAudioSource sine(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1, ctx.sine_freq, ctx.sample_rate); - sine.OnMoreData(NULL, buffer, kTwoSecBytes, AudioBuffersState()); + sine.OnMoreData(buffer, kTwoSecBytes, AudioBuffersState()); AudioBuffersState buffers_state; int times = 0; diff --git a/media/audio/win/waveout_output_win.cc b/media/audio/win/waveout_output_win.cc index 3cae68c..248992c 100644 --- a/media/audio/win/waveout_output_win.cc +++ b/media/audio/win/waveout_output_win.cc @@ -346,7 +346,7 @@ void PCMWaveOutAudioOutputStream::QueueNextPacket(WAVEHDR *buffer) { format_.Format.nChannels; // TODO(sergeyu): Specify correct hardware delay for AudioBuffersState. uint32 used = callback_->OnMoreData( - this, reinterpret_cast<uint8*>(buffer->lpData), buffer_size_, + reinterpret_cast<uint8*>(buffer->lpData), buffer_size_, AudioBuffersState(scaled_pending_bytes, 0)); if (used <= buffer_size_) { buffer->dwBufferLength = used * format_.Format.nChannels / channels_; |