summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-03 01:16:50 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-03 01:16:50 +0000
commit675e47130ddf0b5bd8ab6d450c403b8f8a700b77 (patch)
tree9a261b77a4bd4fadcddf4e710b915a206c2e7218 /media
parentc8460fb06137d6cd925da0abd6069e8fed9804ba (diff)
downloadchromium_src-675e47130ddf0b5bd8ab6d450c403b8f8a700b77.zip
chromium_src-675e47130ddf0b5bd8ab6d450c403b8f8a700b77.tar.gz
chromium_src-675e47130ddf0b5bd8ab6d450c403b8f8a700b77.tar.bz2
Refactored queue of audio_renderer_base to use scoped_refptr
-Changed typedef declaration for queue to deque of scoped_refptr to Buffers-Eliminated now unnecessary calls to AddRef() and Release()Original patch by kylep@google.comhttp://codereview.chromium.org/118122 Review URL: http://codereview.chromium.org/118147 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17458 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/filters/audio_renderer_base.cc10
-rw-r--r--media/filters/audio_renderer_base.h2
2 files changed, 3 insertions, 9 deletions
diff --git a/media/filters/audio_renderer_base.cc b/media/filters/audio_renderer_base.cc
index d838981..5f51646 100644
--- a/media/filters/audio_renderer_base.cc
+++ b/media/filters/audio_renderer_base.cc
@@ -35,10 +35,7 @@ void AudioRendererBase::Stop() {
OnStop();
AutoLock auto_lock(lock_);
- while (!queue_.empty()) {
- queue_.front()->Release();
- queue_.pop_front();
- }
+ queue_.clear();
stopped_ = true;
}
@@ -52,7 +49,6 @@ void AudioRendererBase::Seek(base::TimeDelta time) {
// TODO(hclam): we should preform prerolling again after each seek to avoid
// glitch or clicking of audio.
while (!queue_.empty()) {
- queue_.front()->Release();
queue_.pop_front();
ScheduleRead();
}
@@ -76,7 +72,6 @@ void AudioRendererBase::OnReadComplete(Buffer* buffer_in) {
{
AutoLock auto_lock(lock_);
if (!stopped_) {
- buffer_in->AddRef();
queue_.push_back(buffer_in);
DCHECK(queue_.size() <= max_queue_size_);
}
@@ -110,7 +105,7 @@ size_t AudioRendererBase::FillBuffer(uint8* dest, size_t dest_len,
// Loop until the buffer has been filled.
while (dest_len > 0 && !queue_.empty()) {
- Buffer* buffer = queue_.front();
+ scoped_refptr<Buffer> buffer = queue_.front();
// Determine how much to copy.
const uint8* data = buffer->GetData() + data_offset_;
@@ -169,7 +164,6 @@ size_t AudioRendererBase::FillBuffer(uint8* dest, size_t dest_len,
// Dequeue the buffer.
queue_.pop_front();
- buffer->Release();
++buffers_released;
// Reset our offset into the front buffer.
diff --git a/media/filters/audio_renderer_base.h b/media/filters/audio_renderer_base.h
index a772853..cb2d5f8 100644
--- a/media/filters/audio_renderer_base.h
+++ b/media/filters/audio_renderer_base.h
@@ -84,7 +84,7 @@ class AudioRendererBase : public AudioRenderer {
size_t max_queue_size_;
// Queued audio data.
- typedef std::deque<Buffer*> BufferQueue;
+ typedef std::deque< scoped_refptr<Buffer> > BufferQueue;
BufferQueue queue_;
Lock lock_;