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

Unified Diff: webrtc/modules/audio_device/fine_audio_buffer.cc

Issue 2706923006: Now using rtc::Buffer in FineAudioBuffer (Closed)
Patch Set: Created 3 years, 10 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 | « webrtc/modules/audio_device/fine_audio_buffer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_device/fine_audio_buffer.cc
diff --git a/webrtc/modules/audio_device/fine_audio_buffer.cc b/webrtc/modules/audio_device/fine_audio_buffer.cc
index c0ee15e6630e14a20d7fcc5c6cf84836392818c9..d5671a7b8e69439e949f4528ecf255724ff83d90 100644
--- a/webrtc/modules/audio_device/fine_audio_buffer.cc
+++ b/webrtc/modules/audio_device/fine_audio_buffer.cc
@@ -36,10 +36,8 @@ FineAudioBuffer::FineAudioBuffer(AudioDeviceBuffer* device_buffer,
5 * (desired_frame_size_bytes + bytes_per_10_ms_)),
record_cached_bytes_(0),
record_read_pos_(0),
- record_write_pos_(0) {
+ record_buffer_(0, required_record_buffer_size_bytes_) {
playout_cache_buffer_.reset(new int8_t[bytes_per_10_ms_]);
- record_cache_buffer_.reset(new int8_t[required_record_buffer_size_bytes_]);
- memset(record_cache_buffer_.get(), 0, required_record_buffer_size_bytes_);
}
FineAudioBuffer::~FineAudioBuffer() {}
@@ -60,8 +58,7 @@ void FineAudioBuffer::ResetPlayout() {
void FineAudioBuffer::ResetRecord() {
record_cached_bytes_ = 0;
record_read_pos_ = 0;
- record_write_pos_ = 0;
- memset(record_cache_buffer_.get(), 0, required_record_buffer_size_bytes_);
+ record_buffer_.Clear();
}
void FineAudioBuffer::GetPlayoutData(int8_t* buffer) {
@@ -118,25 +115,24 @@ void FineAudioBuffer::DeliverRecordedData(const int8_t* buffer,
// Check if the temporary buffer can store the incoming buffer. If not,
// move the remaining (old) bytes to the beginning of the temporary buffer
// and start adding new samples after the old samples.
- if (record_write_pos_ + size_in_bytes > required_record_buffer_size_bytes_) {
+ if (record_buffer_.size() + size_in_bytes > record_buffer_.capacity()) {
if (record_cached_bytes_ > 0) {
- memmove(record_cache_buffer_.get(),
- record_cache_buffer_.get() + record_read_pos_,
+ memmove(record_buffer_.data(),
+ record_buffer_.data() + record_read_pos_,
record_cached_bytes_);
}
- record_write_pos_ = record_cached_bytes_;
+ record_buffer_.SetSize(record_cached_bytes_);
record_read_pos_ = 0;
}
// Add recorded samples to a temporary buffer.
- memcpy(record_cache_buffer_.get() + record_write_pos_, buffer, size_in_bytes);
- record_write_pos_ += size_in_bytes;
+ record_buffer_.AppendData(buffer, size_in_bytes);
kwiberg-webrtc 2017/02/22 15:25:39 I don't think this is quite right. .capacity() is
henrika_webrtc 2017/02/22 16:30:25 Great comments. Will fix!
record_cached_bytes_ += size_in_bytes;
// Consume samples in temporary buffer in chunks of 10ms until there is not
// enough data left. The number of remaining bytes in the cache is given by
// |record_cached_bytes_| after this while loop is done.
while (record_cached_bytes_ >= bytes_per_10_ms_) {
device_buffer_->SetRecordedBuffer(
- record_cache_buffer_.get() + record_read_pos_, samples_per_10_ms_);
+ record_buffer_.data() + record_read_pos_, samples_per_10_ms_);
device_buffer_->SetVQEData(playout_delay_ms, record_delay_ms, 0);
device_buffer_->DeliverRecordedData();
// Read next chunk of 10ms data.
« no previous file with comments | « webrtc/modules/audio_device/fine_audio_buffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698