diff options
author | tedvessenes@gmail.com <tedvessenes@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-14 20:39:04 +0000 |
---|---|---|
committer | tedvessenes@gmail.com <tedvessenes@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-14 20:39:04 +0000 |
commit | fc83b1764f09f01012d7888d186637d476c56a7a (patch) | |
tree | 08f5058133766791ce5dbb81faa0a9cd0dbd6468 /media | |
parent | 911511f983add6d386659ac5576ef3e3a514e588 (diff) | |
download | chromium_src-fc83b1764f09f01012d7888d186637d476c56a7a.zip chromium_src-fc83b1764f09f01012d7888d186637d476c56a7a.tar.gz chromium_src-fc83b1764f09f01012d7888d186637d476c56a7a.tar.bz2 |
Convert use of int ms to TimeDelta in files owned by vrk.
R=vrk@chromium.org
BUG=108171
TEST=
Review URL: http://codereview.chromium.org/9190026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117809 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/audio/audio_input_unittest.cc | 25 | ||||
-rw-r--r-- | media/audio/audio_manager_base.cc | 7 | ||||
-rw-r--r-- | media/audio/audio_output_controller.cc | 11 | ||||
-rw-r--r-- | media/audio/audio_output_dispatcher.cc | 13 | ||||
-rw-r--r-- | media/audio/audio_output_dispatcher.h | 6 | ||||
-rw-r--r-- | media/audio/audio_output_proxy_unittest.cc | 29 | ||||
-rw-r--r-- | media/audio/fake_audio_input_stream.cc | 20 | ||||
-rw-r--r-- | media/audio/fake_audio_input_stream.h | 4 | ||||
-rw-r--r-- | media/audio/linux/alsa_input.cc | 24 | ||||
-rw-r--r-- | media/audio/linux/alsa_output.cc | 4 | ||||
-rw-r--r-- | media/audio/mac/audio_low_latency_input_mac_unittest.cc | 8 | ||||
-rw-r--r-- | media/audio/win/audio_low_latency_input_win_unittest.cc | 10 | ||||
-rw-r--r-- | media/audio/win/audio_low_latency_output_win_unittest.cc | 4 | ||||
-rw-r--r-- | media/base/media_log.cc | 2 | ||||
-rw-r--r-- | media/base/pipeline_impl_unittest.cc | 24 | ||||
-rw-r--r-- | media/filters/null_audio_renderer.cc | 10 | ||||
-rw-r--r-- | media/video/capture/fake_video_capture_device.cc | 4 | ||||
-rw-r--r-- | media/video/capture/linux/video_capture_device_linux.cc | 4 |
18 files changed, 98 insertions, 111 deletions
diff --git a/media/audio/audio_input_unittest.cc b/media/audio/audio_input_unittest.cc index b0e8509..eeea7a4 100644 --- a/media/audio/audio_input_unittest.cc +++ b/media/audio/audio_input_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -64,29 +64,6 @@ class TestInputCallback : public AudioInputStream::AudioInputCallback { int max_data_bytes_; }; -// Specializes TestInputCallback to simulate a sink that blocks for some time -// in the OnData callback. -class TestInputCallbackBlocking : public TestInputCallback { - public: - TestInputCallbackBlocking(int max_data_bytes, int block_after_callback, - int block_for_ms) - : TestInputCallback(max_data_bytes), - block_after_callback_(block_after_callback), - block_for_ms_(block_for_ms) { - } - virtual void OnData(AudioInputStream* stream, const uint8* data, - uint32 size, uint32 hardware_delay_bytes) { - // Call the base, which increments the callback_count_. - TestInputCallback::OnData(stream, data, size, hardware_delay_bytes); - if (callback_count() > block_after_callback_) - base::PlatformThread::Sleep(block_for_ms_); - } - - private: - int block_after_callback_; - int block_for_ms_; -}; - static bool CanRunAudioTests(AudioManager* audio_man) { bool has_input = audio_man->HasAudioInputDevices(); diff --git a/media/audio/audio_manager_base.cc b/media/audio/audio_manager_base.cc index 3af7f69..696dd86 100644 --- a/media/audio/audio_manager_base.cc +++ b/media/audio/audio_manager_base.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,7 +8,7 @@ #include "media/audio/audio_output_dispatcher.h" #include "media/audio/audio_output_proxy.h" -static const int kStreamCloseDelayMs = 5000; +static const int kStreamCloseDelaySeconds = 5; const char AudioManagerBase::kDefaultDeviceName[] = "Default"; const char AudioManagerBase::kDefaultDeviceId[] = "default"; @@ -58,7 +58,8 @@ AudioOutputStream* AudioManagerBase::MakeAudioOutputStreamProxy( scoped_refptr<AudioOutputDispatcher>& dispatcher = output_dispatchers_[params]; if (!dispatcher) - dispatcher = new AudioOutputDispatcher(this, params, kStreamCloseDelayMs); + dispatcher = new AudioOutputDispatcher( + this, params, base::TimeDelta::FromSeconds(kStreamCloseDelaySeconds)); return new AudioOutputProxy(dispatcher); } diff --git a/media/audio/audio_output_controller.cc b/media/audio/audio_output_controller.cc index 4eb0556..9f6d7da 100644 --- a/media/audio/audio_output_controller.cc +++ b/media/audio/audio_output_controller.cc @@ -204,7 +204,7 @@ void AudioOutputController::DoPlay() { FROM_HERE, base::Bind(&AudioOutputController::PollAndStartIfDataReady, weak_this_.GetWeakPtr()), - kPollPauseInMilliseconds); + base::TimeDelta::FromMilliseconds(kPollPauseInMilliseconds)); } else { StartStream(); } @@ -232,7 +232,7 @@ void AudioOutputController::PollAndStartIfDataReady() { FROM_HERE, base::Bind(&AudioOutputController::PollAndStartIfDataReady, weak_this_.GetWeakPtr()), - kPollPauseInMilliseconds); + base::TimeDelta::FromMilliseconds(kPollPauseInMilliseconds)); } } @@ -378,12 +378,13 @@ void AudioOutputController::WaitTillDataReady() { if (LowLatencyMode() && !sync_reader_->DataReady()) { // In the different place we use different mechanism to poll, get max // polling delay from constants used there. - const int kMaxPollingDelayMs = kPollNumAttempts * kPollPauseInMilliseconds; + const base::TimeDelta kMaxPollingDelay = base::TimeDelta::FromMilliseconds( + kPollNumAttempts * kPollPauseInMilliseconds); Time start_time = Time::Now(); do { - base::PlatformThread::Sleep(1); + base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); } while (!sync_reader_->DataReady() && - (Time::Now() - start_time).InMilliseconds() < kMaxPollingDelayMs); + Time::Now() - start_time < kMaxPollingDelay); } } diff --git a/media/audio/audio_output_dispatcher.cc b/media/audio/audio_output_dispatcher.cc index 35c9b55..8e40277 100644 --- a/media/audio/audio_output_dispatcher.cc +++ b/media/audio/audio_output_dispatcher.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,16 +12,17 @@ AudioOutputDispatcher::AudioOutputDispatcher( AudioManager* audio_manager, const AudioParameters& params, - int close_delay_ms) + base::TimeDelta close_delay) : audio_manager_(audio_manager), message_loop_(audio_manager->GetMessageLoop()), params_(params), - pause_delay_milliseconds_(2 * params.samples_per_packet * - base::Time::kMillisecondsPerSecond / params.sample_rate), + pause_delay_(base::TimeDelta::FromMilliseconds( + 2 * params.samples_per_packet * + base::Time::kMillisecondsPerSecond / params.sample_rate)), paused_proxies_(0), ALLOW_THIS_IN_INITIALIZER_LIST(weak_this_(this)), close_timer_(FROM_HERE, - base::TimeDelta::FromMilliseconds(close_delay_ms), + close_delay, weak_this_.GetWeakPtr(), &AudioOutputDispatcher::ClosePendingStreams) { DCHECK_EQ(MessageLoop::current(), message_loop_); @@ -79,7 +80,7 @@ void AudioOutputDispatcher::StreamStopped(AudioOutputStream* stream) { FROM_HERE, base::Bind(&AudioOutputDispatcher::StopStreamTask, weak_this_.GetWeakPtr()), - pause_delay_milliseconds_); + pause_delay_); } void AudioOutputDispatcher::StopStreamTask() { diff --git a/media/audio/audio_output_dispatcher.h b/media/audio/audio_output_dispatcher.h index 5602d2a..08e6893 100644 --- a/media/audio/audio_output_dispatcher.h +++ b/media/audio/audio_output_dispatcher.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -42,7 +42,7 @@ class MEDIA_EXPORT AudioOutputDispatcher // the audio device is closed. AudioOutputDispatcher(AudioManager* audio_manager, const AudioParameters& params, - int close_delay_ms); + base::TimeDelta close_delay); ~AudioOutputDispatcher(); // Called by AudioOutputProxy when the stream is closed. Opens a new @@ -96,7 +96,7 @@ class MEDIA_EXPORT AudioOutputDispatcher MessageLoop* message_loop_; AudioParameters params_; - int64 pause_delay_milliseconds_; + base::TimeDelta pause_delay_; size_t paused_proxies_; typedef std::list<AudioOutputStream*> AudioOutputStreamList; AudioOutputStreamList idle_streams_; diff --git a/media/audio/audio_output_proxy_unittest.cc b/media/audio/audio_output_proxy_unittest.cc index 436a0ba..b2ff1a9 100644 --- a/media/audio/audio_output_proxy_unittest.cc +++ b/media/audio/audio_output_proxy_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,7 +17,7 @@ using ::testing::Return; static const int kTestCloseDelayMs = 100; // Used in the test where we don't want a stream to be closed unexpectedly. -static const int kTestBigCloseDelayMs = 1000 * 1000; +static const int kTestBigCloseDelaySeconds = 1000; class MockAudioOutputStream : public AudioOutputStream { public: @@ -71,7 +71,7 @@ class AudioOutputProxyTest : public testing::Test { EXPECT_CALL(*manager, GetMessageLoop()) .WillRepeatedly(Return(&message_loop_)); manager_ = manager; - InitDispatcher(kTestCloseDelayMs); + InitDispatcher(base::TimeDelta::FromMilliseconds(kTestCloseDelayMs)); } virtual void TearDown() { @@ -83,14 +83,14 @@ class AudioOutputProxyTest : public testing::Test { message_loop_.RunAllPending(); } - void InitDispatcher(int close_delay_ms) { + void InitDispatcher(base::TimeDelta close_delay) { AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO, 44100, 16, 1024); - dispatcher_ = new AudioOutputDispatcher(&manager(), params, close_delay_ms); + dispatcher_ = new AudioOutputDispatcher(&manager(), params, close_delay); // Necessary to know how long the dispatcher will wait before posting // StopStreamTask. - pause_delay_milliseconds_ = dispatcher_->pause_delay_milliseconds_; + pause_delay_ = dispatcher_->pause_delay_; } MockAudioManager& manager() { @@ -99,7 +99,7 @@ class AudioOutputProxyTest : public testing::Test { MessageLoop message_loop_; scoped_refptr<AudioOutputDispatcher> dispatcher_; - int64 pause_delay_milliseconds_; + base::TimeDelta pause_delay_; scoped_refptr<MockAudioManager> manager_; MockAudioSourceCallback callback_; }; @@ -140,7 +140,8 @@ TEST_F(AudioOutputProxyTest, CreateAndWait) { EXPECT_TRUE(proxy->Open()); // Simulate a delay. - base::PlatformThread::Sleep(kTestCloseDelayMs * 2); + base::PlatformThread::Sleep( + base::TimeDelta::FromMilliseconds(kTestCloseDelayMs) * 2); message_loop_.RunAllPending(); // Verify expectation before calling Close(). @@ -199,11 +200,12 @@ TEST_F(AudioOutputProxyTest, CloseAfterStop) { proxy->Stop(); // Wait for StreamStopped() to post StopStreamTask(). - base::PlatformThread::Sleep(pause_delay_milliseconds_ * 2); + base::PlatformThread::Sleep(pause_delay_ * 2); message_loop_.RunAllPending(); // Wait for the close timer to fire. - base::PlatformThread::Sleep(kTestCloseDelayMs * 2); + base::PlatformThread::Sleep( + base::TimeDelta::FromMilliseconds(kTestCloseDelayMs) * 2); message_loop_.RunAllPending(); // Verify expectation before calling Close(). @@ -237,7 +239,7 @@ TEST_F(AudioOutputProxyTest, TwoStreams_OnePlaying) { MockAudioOutputStream stream1; MockAudioOutputStream stream2; - InitDispatcher(kTestBigCloseDelayMs); + InitDispatcher(base::TimeDelta::FromSeconds(kTestBigCloseDelaySeconds)); EXPECT_CALL(manager(), MakeAudioOutputStream(_)) .WillOnce(Return(&stream1)) @@ -277,7 +279,7 @@ TEST_F(AudioOutputProxyTest, TwoStreams_BothPlaying) { MockAudioOutputStream stream1; MockAudioOutputStream stream2; - InitDispatcher(kTestBigCloseDelayMs); + InitDispatcher(base::TimeDelta::FromSeconds(kTestBigCloseDelaySeconds)); EXPECT_CALL(manager(), MakeAudioOutputStream(_)) .WillOnce(Return(&stream1)) @@ -350,7 +352,8 @@ TEST_F(AudioOutputProxyTest, StartFailed) { EXPECT_TRUE(proxy->Open()); // Simulate a delay. - base::PlatformThread::Sleep(kTestCloseDelayMs * 2); + base::PlatformThread::Sleep( + base::TimeDelta::FromMilliseconds(kTestCloseDelayMs) * 2); message_loop_.RunAllPending(); // Verify expectation before calling Close(). diff --git a/media/audio/fake_audio_input_stream.cc b/media/audio/fake_audio_input_stream.cc index 8ed02de..f0f5c25 100644 --- a/media/audio/fake_audio_input_stream.cc +++ b/media/audio/fake_audio_input_stream.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,8 +19,8 @@ FakeAudioInputStream::FakeAudioInputStream(const AudioParameters& params) buffer_size_((params.channels * params.bits_per_sample * params.samples_per_packet) / 8), thread_("FakeAudioRecordingThread"), - callback_interval_ms_((params.samples_per_packet * 1000) / - params.sample_rate) { + callback_interval_(base::TimeDelta::FromMilliseconds( + (params.samples_per_packet * 1000) / params.sample_rate)) { // This object is ref counted (so that it can be used with Thread, PostTask) // but the caller expects a plain pointer. So we take a reference here and // will Release() ourselves in Close(). @@ -43,7 +43,7 @@ void FakeAudioInputStream::Start(AudioInputCallback* callback) { thread_.message_loop()->PostDelayedTask( FROM_HERE, base::Bind(&FakeAudioInputStream::DoCallback, this), - callback_interval_ms_); + callback_interval_); } void FakeAudioInputStream::DoCallback() { @@ -51,19 +51,19 @@ void FakeAudioInputStream::DoCallback() { callback_->OnData(this, buffer_.get(), buffer_size_, buffer_size_); Time now = Time::Now(); - int64 next_callback_ms = (last_callback_time_ + - TimeDelta::FromMilliseconds(callback_interval_ms_ * 2) - - now).InMilliseconds(); + base::TimeDelta next_callback_time = + last_callback_time_ + callback_interval_ * 2 - now; + // If we are falling behind, try to catch up as much as we can in the next // callback. - if (next_callback_ms < 0) - next_callback_ms = 0; + if (next_callback_time < base::TimeDelta()) + next_callback_time = base::TimeDelta(); last_callback_time_ = now; thread_.message_loop()->PostDelayedTask( FROM_HERE, base::Bind(&FakeAudioInputStream::DoCallback, this), - next_callback_ms); + next_callback_time); } void FakeAudioInputStream::Stop() { diff --git a/media/audio/fake_audio_input_stream.h b/media/audio/fake_audio_input_stream.h index a89aada..7f1d38d 100644 --- a/media/audio/fake_audio_input_stream.h +++ b/media/audio/fake_audio_input_stream.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -41,7 +41,7 @@ class FakeAudioInputStream int buffer_size_; base::Thread thread_; base::Time last_callback_time_; - int callback_interval_ms_; + base::TimeDelta callback_interval_; DISALLOW_COPY_AND_ASSIGN(FakeAudioInputStream); }; diff --git a/media/audio/linux/alsa_input.cc b/media/audio/linux/alsa_input.cc index 1e677ba..2e9a217 100644 --- a/media/audio/linux/alsa_input.cc +++ b/media/audio/linux/alsa_input.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -104,13 +104,13 @@ void AlsaPcmInputStream::Start(AudioInputCallback* callback) { // We start reading data half |packet_duration_ms_| later than when the // packet might have got filled, to accommodate some delays in the audio // driver. This could also give us a smooth read sequence going forward. - int64 delay_ms = packet_duration_ms_ + packet_duration_ms_ / 2; - next_read_time_ = base::Time::Now() + base::TimeDelta::FromMilliseconds( - delay_ms); + base::TimeDelta delay = base::TimeDelta::FromMilliseconds( + packet_duration_ms_ + packet_duration_ms_ / 2); + next_read_time_ = base::Time::Now() + delay; MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&AlsaPcmInputStream::ReadAudio, weak_factory_.GetWeakPtr()), - delay_ms); + delay); audio_manager_->IncreaseActiveInputStreamCount(); } @@ -175,7 +175,8 @@ void AlsaPcmInputStream::ReadAudio() { read_callback_behind_schedule_ = false; } - uint32 next_check_time = packet_duration_ms_ / 2; + base::TimeDelta next_check_time = base::TimeDelta::FromMilliseconds( + packet_duration_ms_ / 2); MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&AlsaPcmInputStream::ReadAudio, weak_factory_.GetWeakPtr()), @@ -203,20 +204,21 @@ void AlsaPcmInputStream::ReadAudio() { next_read_time_ += base::TimeDelta::FromMilliseconds( packet_duration_ms_ * num_packets_read); - int64 delay_ms = (next_read_time_ - base::Time::Now()).InMilliseconds(); - if (delay_ms < 0) { + base::TimeDelta delay = next_read_time_ - base::Time::Now(); + if (delay < base::TimeDelta()) { LOG(WARNING) << "Audio read callback behind schedule by " - << (packet_duration_ms_ - delay_ms) << " (ms)."; + << (packet_duration_ms_ - delay.InMilliseconds()) + << " (ms)."; // Read callback is behind schedule. Assuming there is data pending in // the soundcard, invoke the read callback immediate in order to catch up. read_callback_behind_schedule_ = true; - delay_ms = 0; + delay = base::TimeDelta(); } MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&AlsaPcmInputStream::ReadAudio, weak_factory_.GetWeakPtr()), - delay_ms); + delay); } void AlsaPcmInputStream::Stop() { diff --git a/media/audio/linux/alsa_output.cc b/media/audio/linux/alsa_output.cc index d924cd6..ef872c0 100644 --- a/media/audio/linux/alsa_output.cc +++ b/media/audio/linux/alsa_output.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -607,7 +607,7 @@ void AlsaPcmOutputStream::ScheduleNextWrite(bool source_exhausted) { manager_->GetMessageLoop()->PostDelayedTask(FROM_HERE, base::Bind(&AlsaPcmOutputStream::WriteTask, weak_factory_.GetWeakPtr()), - next_fill_time_ms); + base::TimeDelta::FromMilliseconds(next_fill_time_ms)); } } } diff --git a/media/audio/mac/audio_low_latency_input_mac_unittest.cc b/media/audio/mac/audio_low_latency_input_mac_unittest.cc index 7b32b19..b7be3f4 100644 --- a/media/audio/mac/audio_low_latency_input_mac_unittest.cc +++ b/media/audio/mac/audio_low_latency_input_mac_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -227,7 +227,7 @@ TEST_F(MacAudioInputTest, AUAudioInputStreamVerifyMonoRecording) { .Times(Between(5, 10)); ais->Start(&sink); - base::PlatformThread::Sleep(TestTimeouts::tiny_timeout_ms()); + base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); ais->Stop(); // Verify that the sink receieves OnClose() call when calling Close(). @@ -261,7 +261,7 @@ TEST_F(MacAudioInputTest, AUAudioInputStreamVerifyStereoRecording) { .Times(Between(5, 10)); ais->Start(&sink); - base::PlatformThread::Sleep(TestTimeouts::tiny_timeout_ms()); + base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); ais->Stop(); // Verify that the sink receieves OnClose() call when calling Close(). @@ -290,7 +290,7 @@ TEST_F(MacAudioInputTest, DISABLED_AUAudioInputStreamRecordToFile) { WriteToFileAudioSink file_sink(file_name); fprintf(stderr, " >> Speak into the mic while recording...\n"); ais->Start(&file_sink); - base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); + base::PlatformThread::Sleep(TestTimeouts::action_timeout()); ais->Stop(); fprintf(stderr, " >> Recording has stopped.\n"); ais->Close(); diff --git a/media/audio/win/audio_low_latency_input_win_unittest.cc b/media/audio/win/audio_low_latency_input_win_unittest.cc index 28b2e13..0808844 100644 --- a/media/audio/win/audio_low_latency_input_win_unittest.cc +++ b/media/audio/win/audio_low_latency_input_win_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -297,7 +297,7 @@ TEST(WinAudioInputTest, WASAPIAudioInputStreamTestPacketSizes) { .Times(Between(5, 10)); ais->Start(&sink); - base::PlatformThread::Sleep(TestTimeouts::tiny_timeout_ms()); + base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); ais->Stop(); // Store current packet size (to be used in the subsequent tests). @@ -318,7 +318,7 @@ TEST(WinAudioInputTest, WASAPIAudioInputStreamTestPacketSizes) { ais, NotNull(), bytes_per_packet, Gt(bytes_per_packet))) .Times(Between(5, 10)); ais->Start(&sink); - base::PlatformThread::Sleep(2 * TestTimeouts::tiny_timeout_ms()); + base::PlatformThread::Sleep(2 * TestTimeouts::tiny_timeout()); ais->Stop(); EXPECT_CALL(sink, OnClose(ais)) @@ -336,7 +336,7 @@ TEST(WinAudioInputTest, WASAPIAudioInputStreamTestPacketSizes) { ais, NotNull(), bytes_per_packet, Gt(bytes_per_packet))) .Times(Between(2 * 5, 2 * 10)); ais->Start(&sink); - base::PlatformThread::Sleep(TestTimeouts::tiny_timeout_ms()); + base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); ais->Stop(); EXPECT_CALL(sink, OnClose(ais)) @@ -366,7 +366,7 @@ TEST(WinAudioInputTest, DISABLED_WASAPIAudioInputStreamRecordToFile) { WriteToFileAudioSink file_sink(file_name); fprintf(stderr, " >> Speak into the mic while recording...\n"); ais->Start(&file_sink); - base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); + base::PlatformThread::Sleep(TestTimeouts::action_timeout()); ais->Stop(); fprintf(stderr, " >> Recording has stopped.\n"); ais->Close(); 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 d979073..9cf3b0b 100644 --- a/media/audio/win/audio_low_latency_output_win_unittest.cc +++ b/media/audio/win/audio_low_latency_output_win_unittest.cc @@ -523,7 +523,6 @@ TEST(WinAudioOutputTest, DISABLED_WASAPIAudioOutputStreamReadFromFile) { return; } ReadFromFileAudioSource file_source(file_name); - int file_duration_ms = kFileDurationMs; LOG(INFO) << "File name : " << file_name.c_str(); LOG(INFO) << "Sample rate: " << aosw.sample_rate(); @@ -531,7 +530,8 @@ TEST(WinAudioOutputTest, DISABLED_WASAPIAudioOutputStreamReadFromFile) { LOG(INFO) << ">> Listen to the file while playing..."; aos->Start(&file_source); - base::PlatformThread::Sleep(file_duration_ms); + base::PlatformThread::Sleep( + base::TimeDelta::FromMilliseconds(kFileDurationMs)); aos->Stop(); LOG(INFO) << ">> File playout has stopped."; diff --git a/media/base/media_log.cc b/media/base/media_log.cc index d9ac529..2312942 100644 --- a/media/base/media_log.cc +++ b/media/base/media_log.cc @@ -239,7 +239,7 @@ void MediaLog::QueueStatisticsUpdatedEvent(PipelineStatistics stats) { MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&media::MediaLog::AddStatisticsUpdatedEvent, this), - 500); + base::TimeDelta::FromMilliseconds(500)); } } diff --git a/media/base/pipeline_impl_unittest.cc b/media/base/pipeline_impl_unittest.cc index 73b62b5..3ded0e7 100644 --- a/media/base/pipeline_impl_unittest.cc +++ b/media/base/pipeline_impl_unittest.cc @@ -873,32 +873,34 @@ TEST_F(PipelineImplTest, StartTimeIsNonZero) { class FlexibleCallbackRunner : public base::DelegateSimpleThread::Delegate { public: - FlexibleCallbackRunner(int delayInMs, PipelineStatus status, + FlexibleCallbackRunner(base::TimeDelta delay, PipelineStatus status, const PipelineStatusCB& callback) - : delayInMs_(delayInMs), status_(status), callback_(callback) { - if (delayInMs_ < 0) { + : delay_(delay), + status_(status), + callback_(callback) { + if (delay_ < base::TimeDelta()) { callback_.Run(status_); return; } } virtual void Run() { - if (delayInMs_ < 0) return; - base::PlatformThread::Sleep(delayInMs_); + if (delay_ < base::TimeDelta()) return; + base::PlatformThread::Sleep(delay_); callback_.Run(status_); } private: - int delayInMs_; + base::TimeDelta delay_; PipelineStatus status_; PipelineStatusCB callback_; }; -void TestPipelineStatusNotification(int delayInMs) { +void TestPipelineStatusNotification(base::TimeDelta delay) { PipelineStatusNotification note; // Arbitrary error value we expect to fish out of the notification after the // callback is fired. const PipelineStatus expected_error = PIPELINE_ERROR_URL_NOT_FOUND; - FlexibleCallbackRunner runner(delayInMs, expected_error, note.Callback()); + FlexibleCallbackRunner runner(delay, expected_error, note.Callback()); base::DelegateSimpleThread thread(&runner, "FlexibleCallbackRunner"); thread.Start(); note.Wait(); @@ -908,18 +910,18 @@ void TestPipelineStatusNotification(int delayInMs) { // Test that in-line callback (same thread, no yield) works correctly. TEST(PipelineStatusNotificationTest, InlineCallback) { - TestPipelineStatusNotification(-1); + TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(-1)); } // Test that different-thread, no-delay callback works correctly. TEST(PipelineStatusNotificationTest, ImmediateCallback) { - TestPipelineStatusNotification(0); + TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); } // Test that different-thread, some-delay callback (the expected common case) // works correctly. TEST(PipelineStatusNotificationTest, DelayedCallback) { - TestPipelineStatusNotification(20); + TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); } } // namespace media diff --git a/media/filters/null_audio_renderer.cc b/media/filters/null_audio_renderer.cc index d4689aa..bb93db2 100644 --- a/media/filters/null_audio_renderer.cc +++ b/media/filters/null_audio_renderer.cc @@ -57,7 +57,7 @@ void NullAudioRenderer::OnStop() { } void NullAudioRenderer::FillBufferTask() { - int64 sleep_in_milliseconds = 0; + base::TimeDelta delay; // Only consume buffers when actually playing. if (GetPlaybackRate() > 0.0f) { @@ -67,18 +67,18 @@ void NullAudioRenderer::FillBufferTask() { true); // Calculate our sleep duration, taking playback rate into consideration. - sleep_in_milliseconds = - bytes / (bytes_per_millisecond_ * GetPlaybackRate()); + delay = base::TimeDelta::FromMilliseconds( + bytes / (bytes_per_millisecond_ * GetPlaybackRate())); } else { // If paused, sleep for 10 milliseconds before polling again. - sleep_in_milliseconds = 10; + delay = base::TimeDelta::FromMilliseconds(10); } // Sleep for at least one millisecond so we don't spin the CPU. MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&NullAudioRenderer::FillBufferTask, this), - std::max(sleep_in_milliseconds, static_cast<int64>(1))); + std::max(delay, base::TimeDelta::FromMilliseconds(1))); } } // namespace media diff --git a/media/video/capture/fake_video_capture_device.cc b/media/video/capture/fake_video_capture_device.cc index a74b4d3..7f1f6e5 100644 --- a/media/video/capture/fake_video_capture_device.cc +++ b/media/video/capture/fake_video_capture_device.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -125,7 +125,7 @@ void FakeVideoCaptureDevice::OnCaptureTask() { FROM_HERE, base::Bind(&FakeVideoCaptureDevice::OnCaptureTask, base::Unretained(this)), - kFakeCaptureTimeoutMs); + base::TimeDelta::FromMilliseconds(kFakeCaptureTimeoutMs)); } } // namespace media diff --git a/media/video/capture/linux/video_capture_device_linux.cc b/media/video/capture/linux/video_capture_device_linux.cc index c495cec..6bc1a3a 100644 --- a/media/video/capture/linux/video_capture_device_linux.cc +++ b/media/video/capture/linux/video_capture_device_linux.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -351,7 +351,7 @@ void VideoCaptureDeviceLinux::OnCaptureTask() { FROM_HERE, base::Bind(&VideoCaptureDeviceLinux::OnCaptureTask, base::Unretained(this)), - kCaptureSelectWaitMs); + base::TimeDelta::FromMilliseconds(kCaptureSelectWaitMs)); } // Check if the driver have filled a buffer. |