Chromium Code Reviews| Index: media/audio/audio_input_device.cc |
| diff --git a/media/audio/audio_input_device.cc b/media/audio/audio_input_device.cc |
| index 9f46b55a1b9f365facd573b5f0783cd15f9923af..f9541f16b24f5728de32d2446171e51df2df7095 100644 |
| --- a/media/audio/audio_input_device.cc |
| +++ b/media/audio/audio_input_device.cc |
| @@ -39,6 +39,7 @@ class AudioInputDevice::AudioThreadCallback |
| private: |
| int current_segment_id_; |
| + uint32 last_buffer_id_; |
| ScopedVector<media::AudioBus> audio_buses_; |
| CaptureCallback* capture_callback_; |
| @@ -272,6 +273,7 @@ AudioInputDevice::AudioThreadCallback::AudioThreadCallback( |
| : AudioDeviceThread::Callback(audio_parameters, memory, memory_length, |
| total_segments), |
| current_segment_id_(0), |
| + last_buffer_id_(UINT32_MAX), |
| capture_callback_(capture_callback) { |
| } |
| @@ -294,6 +296,8 @@ void AudioInputDevice::AudioThreadCallback::MapSharedMemory() { |
| } |
| void AudioInputDevice::AudioThreadCallback::Process(uint32 pending_data) { |
| + CHECK_EQ(current_segment_id_, static_cast<int>(pending_data)); |
| + |
| // The shared memory represents parameters, size of the data buffer and the |
| // actual data buffer containing audio data. Map the memory into this |
| // structure and parse out parameters and the data area. |
| @@ -306,13 +310,22 @@ void AudioInputDevice::AudioThreadCallback::Process(uint32 pending_data) { |
| segment_length_ - sizeof(AudioInputBufferParameters)); |
| double volume = buffer->params.volume; |
| bool key_pressed = buffer->params.key_pressed; |
| + uint32 hardware_delay_bytes = buffer->params.hardware_delay_bytes; |
|
tommi (sloooow) - chröme
2015/08/14 09:56:21
nit: are these temporaries necessary?
Henrik Grunell
2015/08/14 12:38:32
Good point, removed all of them.
|
| + uint32 buffer_id = buffer->params.id; |
| + |
| + // Verify correct sequence. |
| + if (last_buffer_id_ == UINT32_MAX) |
|
DaleCurtis
2015/08/13 22:00:49
Again, shouldn't be necessary since overflow is de
Henrik Grunell
2015/08/14 12:38:32
Done.
|
| + CHECK_EQ(0u, buffer_id); |
| + else |
| + CHECK_EQ(last_buffer_id_ + 1, buffer_id); |
| + last_buffer_id_ = buffer_id; |
| // Use pre-allocated audio bus wrapping existing block of shared memory. |
| media::AudioBus* audio_bus = audio_buses_[current_segment_id_]; |
| // Deliver captured data to the client in floating point format |
| // and update the audio-delay measurement. |
| - int audio_delay_milliseconds = pending_data / bytes_per_ms_; |
| + int audio_delay_milliseconds = hardware_delay_bytes / bytes_per_ms_; |
| capture_callback_->Capture( |
| audio_bus, audio_delay_milliseconds, volume, key_pressed); |