Commit 5e03452a authored by rnk@google.com's avatar rnk@google.com

Call close_timer_.Reset() from StopStreamTask.

There is a race here if ClosePendingStreams() is called before StopStreamTask.
The stream added to idle_streams_ will stay there forever unless we reset the
timer.

This test fails when run locally under tsan and on the drmemory bots here:
http://build.chromium.org/p/chromium.fyi/builders/Windows%20Tests%20%28DrMemory%20Win%207%29/builds/1402/steps/memory%20test%3A%20media

BUG=105124

Review URL: http://codereview.chromium.org/8680009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111545 0039d316-1c4b-4281-b951-d872f2087c98
parent 613a3986
......@@ -69,7 +69,6 @@ void AudioOutputDispatcher::StreamStopped(AudioOutputStream* stream) {
paused_proxies_++;
pausing_streams_.push_front(stream);
close_timer_.Reset();
// Don't recycle stream until two buffers worth of time has elapsed.
message_loop_->PostDelayedTask(
......@@ -84,6 +83,7 @@ void AudioOutputDispatcher::StopStreamTask() {
AudioOutputStream* stream = pausing_streams_.back();
pausing_streams_.pop_back();
idle_streams_.push_back(stream);
close_timer_.Reset();
}
void AudioOutputDispatcher::StreamClosed() {
......
......@@ -85,10 +85,15 @@ class AudioOutputProxyTest : public testing::Test {
AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR,
CHANNEL_LAYOUT_STEREO, 44100, 16, 1024);
dispatcher_ = new AudioOutputDispatcher(&manager_, params, close_delay_ms);
// Necessary to know how long the dispatcher will wait before posting
// StopStreamTask.
pause_delay_milliseconds_ = dispatcher_->pause_delay_milliseconds_;
}
MessageLoop message_loop_;
scoped_refptr<AudioOutputDispatcher> dispatcher_;
int64 pause_delay_milliseconds_;
MockAudioManager manager_;
MockAudioSourceCallback callback_;
};
......@@ -187,9 +192,12 @@ TEST_F(AudioOutputProxyTest, CloseAfterStop) {
proxy->Start(&callback_);
proxy->Stop();
// Simulate a delay.
// Wait for StreamStopped() to post StopStreamTask().
base::PlatformThread::Sleep(pause_delay_milliseconds_ * 2);
message_loop_.RunAllPending();
base::PlatformThread::Sleep(kTestCloseDelayMs * 10);
// Wait for the close timer to fire.
base::PlatformThread::Sleep(kTestCloseDelayMs * 2);
message_loop_.RunAllPending();
// Verify expectation before calling Close().
......@@ -336,7 +344,7 @@ TEST_F(AudioOutputProxyTest, StartFailed) {
EXPECT_TRUE(proxy->Open());
// Simulate a delay.
base::PlatformThread::Sleep(kTestCloseDelayMs);
base::PlatformThread::Sleep(kTestCloseDelayMs * 2);
message_loop_.RunAllPending();
// Verify expectation before calling Close().
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment