Index: media/audio/audio_output_dispatcher.cc |
diff --git a/media/audio/audio_output_dispatcher.cc b/media/audio/audio_output_dispatcher.cc |
index 3f9d848a2c9d1762155e7062aee36f479d6563d0..8ecad1656a9416a535484eaf0c2109fa1d3b37a1 100644 |
--- a/media/audio/audio_output_dispatcher.cc |
+++ b/media/audio/audio_output_dispatcher.cc |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2011 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. |
@@ -61,7 +61,22 @@ AudioOutputStream* AudioOutputDispatcher::StreamStarted() { |
void AudioOutputDispatcher::StreamStopped(AudioOutputStream* stream) { |
DCHECK_EQ(MessageLoop::current(), message_loop_); |
+ |
paused_proxies_++; |
+ |
+ idle_streams_.push_front(stream); |
Sergey Ulanov
2011/04/09 07:02:05
Looks to me that we may leak streams that are in i
|
+ |
+ // Don't recycle stream until two buffers worth of time has elapsed |
Sergey Ulanov
2011/04/09 07:02:05
nit: period at the end of the comment.
|
+ message_loop_->PostDelayedTask(FROM_HERE, NewRunnableMethod( |
+ this, &AudioOutputDispatcher::StopStreamTask), |
+ 2 * params_.samples_per_packet * 1000 / params_.sample_rate); |
Sergey Ulanov
2011/04/09 07:02:05
nit: This line is not indented properly. I would m
Sergey Ulanov
2011/04/09 07:02:05
nit: replace 1000 with Time::kMillisecondsPerSecon
scherkus (not reviewing)
2011/04/11 22:32:33
it looks like you can pre-calculate this since par
|
+} |
+ |
+void AudioOutputDispatcher::StopStreamTask() { |
+ if (idle_streams_.empty()) |
+ return; |
+ AudioOutputStream* stream = idle_streams_.back(); |
+ idle_streams_.pop_back(); |
streams_.push_back(stream); |
close_timer_.Reset(); |
} |