diff options
Diffstat (limited to 'chromium/media/base/sinc_resampler.cc')
-rw-r--r-- | chromium/media/base/sinc_resampler.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/chromium/media/base/sinc_resampler.cc b/chromium/media/base/sinc_resampler.cc index 5566f64ce86..82168dbc64a 100644 --- a/chromium/media/base/sinc_resampler.cc +++ b/chromium/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(¤tly_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(¤tly_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(¤tly_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(¤tly_resampling_)); } #undef CONVOLVE_FUNC @@ -332,6 +342,7 @@ int SincResampler::ChunkSize() const { } void SincResampler::Flush() { + CHECK(base::AtomicRefCountIsZero(¤tly_resampling_)); virtual_source_idx_ = 0; buffer_primed_ = false; memset(input_buffer_.get(), 0, |