summaryrefslogtreecommitdiff
path: root/media/base/sinc_resampler.cc
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2013-10-18 15:46:22 +0100
committerTorne (Richard Coles) <torne@google.com>2013-10-18 15:46:22 +0100
commit4e180b6a0b4720a9b8e9e959a882386f690f08ff (patch)
tree788435d09362885908ba5ba9ef868b852ca82c0b /media/base/sinc_resampler.cc
parent1179b92b08db0c652a0cf003ab4d89b31ce3610f (diff)
downloadchromium_org-4e180b6a0b4720a9b8e9e959a882386f690f08ff.tar.gz
Merge from Chromium at DEPS revision 228962
This commit was generated by merge_to_master.py. Change-Id: I23bd7d7766f213fd52f28ae5e1ecc6ae9df905ea
Diffstat (limited to 'media/base/sinc_resampler.cc')
-rw-r--r--media/base/sinc_resampler.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/media/base/sinc_resampler.cc b/media/base/sinc_resampler.cc
index 5566f64ce8..82168dbc64 100644
--- a/media/base/sinc_resampler.cc
+++ b/media/base/sinc_resampler.cc
@@ -153,7 +153,8 @@ SincResampler::SincResampler(double io_sample_rate_ratio,
input_buffer_(static_cast<float*>(
base::AlignedAlloc(sizeof(float) * input_buffer_size_, 16))),
r1_(input_buffer_.get()),
- r2_(input_buffer_.get() + kKernelSize / 2) {
+ r2_(input_buffer_.get() + kKernelSize / 2),
+ currently_resampling_(0) {
CHECK_GT(request_frames_, 0);
Flush();
CHECK_GT(block_size_, kKernelSize)
@@ -169,7 +170,10 @@ SincResampler::SincResampler(double io_sample_rate_ratio,
InitializeKernel();
}
-SincResampler::~SincResampler() {}
+SincResampler::~SincResampler() {
+ // TODO(dalecurtis): Remove debugging for http://crbug.com/295278
+ CHECK(base::AtomicRefCountIsZero(&currently_resampling_));
+}
void SincResampler::UpdateRegions(bool second_load) {
// Setup various region pointers in the buffer (see diagram above). If we're
@@ -252,6 +256,8 @@ void SincResampler::SetRatio(double io_sample_rate_ratio) {
}
void SincResampler::Resample(int frames, float* destination) {
+ base::AtomicRefCountInc(&currently_resampling_);
+
int remaining_frames = frames;
// Step (1) -- Prime the input buffer at the start of the input stream.
@@ -305,8 +311,10 @@ void SincResampler::Resample(int frames, float* destination) {
// Advance the virtual index.
virtual_source_idx_ += current_io_ratio;
- if (!--remaining_frames)
+ if (!--remaining_frames) {
+ CHECK(!base::AtomicRefCountDec(&currently_resampling_));
return;
+ }
}
// Wrap back around to the start.
@@ -323,6 +331,8 @@ void SincResampler::Resample(int frames, float* destination) {
// Step (5) -- Refresh the buffer with more input.
read_cb_.Run(request_frames_, r0_);
}
+
+ CHECK(!base::AtomicRefCountDec(&currently_resampling_));
}
#undef CONVOLVE_FUNC
@@ -332,6 +342,7 @@ int SincResampler::ChunkSize() const {
}
void SincResampler::Flush() {
+ CHECK(base::AtomicRefCountIsZero(&currently_resampling_));
virtual_source_idx_ = 0;
buffer_primed_ = false;
memset(input_buffer_.get(), 0,