Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(618)

Unified Diff: content/browser/speech/audio_buffer.cc

Issue 9861019: Speech refactoring: Turned AudioChunk into a refcounted class (CL1.4) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed according to Hans review. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/speech/audio_buffer.h ('k') | content/browser/speech/audio_encoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/speech/audio_buffer.cc
diff --git a/content/browser/speech/audio_buffer.cc b/content/browser/speech/audio_buffer.cc
index 5b887d74c333ddd7d7ace8f4e8c27f2c83e246ef..ef49004e1e3c61f3f926c26ac35bdf4f12b46dea 100644
--- a/content/browser/speech/audio_buffer.cc
+++ b/content/browser/speech/audio_buffer.cc
@@ -52,19 +52,18 @@ AudioBuffer::~AudioBuffer() {
}
void AudioBuffer::Enqueue(const uint8* data, size_t length) {
- AudioChunk* chunk = new AudioChunk(data, length, bytes_per_sample_);
- chunks_.push_back(chunk);
+ chunks_.push_back(new AudioChunk(data, length, bytes_per_sample_));
}
-scoped_ptr<AudioChunk> AudioBuffer::DequeueSingleChunk() {
+scoped_refptr<AudioChunk> AudioBuffer::DequeueSingleChunk() {
DCHECK(!chunks_.empty());
- AudioChunk* chunk = *chunks_.begin();
- chunks_.weak_erase(chunks_.begin());
- return scoped_ptr<AudioChunk>(chunk);
+ scoped_refptr<AudioChunk> chunk(chunks_.front());
+ chunks_.pop_front();
+ return chunk;
}
-scoped_ptr<AudioChunk> AudioBuffer::DequeueAll() {
- AudioChunk* chunk = new AudioChunk(bytes_per_sample_);
+scoped_refptr<AudioChunk> AudioBuffer::DequeueAll() {
+ scoped_refptr<AudioChunk> chunk(new AudioChunk(bytes_per_sample_));
size_t resulting_length = 0;
ChunksContainer::const_iterator it;
// In order to improve performance, calulate in advance the total length
@@ -77,11 +76,11 @@ scoped_ptr<AudioChunk> AudioBuffer::DequeueAll() {
chunk->data_string_.append((*it)->data_string_);
}
Clear();
- return scoped_ptr<AudioChunk>(chunk);
+ return chunk;
}
void AudioBuffer::Clear() {
- chunks_.erase(chunks_.begin(), chunks_.end());
+ chunks_.clear();
}
bool AudioBuffer::IsEmpty() const {
« no previous file with comments | « content/browser/speech/audio_buffer.h ('k') | content/browser/speech/audio_encoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698