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

Side by Side Diff: media/audio/audio_input_device.cc

Issue 510913005: Add native log and uma stat when all input shared memory buffers are full (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/audio/audio_input_device.h" 5 #include "media/audio/audio_input_device.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 uint8* ptr = static_cast<uint8*>(shared_memory_.memory()); 302 uint8* ptr = static_cast<uint8*>(shared_memory_.memory());
303 ptr += current_segment_id_ * segment_length_; 303 ptr += current_segment_id_ * segment_length_;
304 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr); 304 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr);
305 // Usually this will be equal but in the case of low sample rate (e.g. 8kHz, 305 // Usually this will be equal but in the case of low sample rate (e.g. 8kHz,
306 // the buffer may be bigger (on mac at least)). 306 // the buffer may be bigger (on mac at least)).
307 DCHECK_GE(buffer->params.size, 307 DCHECK_GE(buffer->params.size,
308 segment_length_ - sizeof(AudioInputBufferParameters)); 308 segment_length_ - sizeof(AudioInputBufferParameters));
309 double volume = buffer->params.volume; 309 double volume = buffer->params.volume;
310 bool key_pressed = buffer->params.key_pressed; 310 bool key_pressed = buffer->params.key_pressed;
311 311
312 // Reset the size of the buffer to 0 to notify the browser that
313 // the buffer has been consumed.
314 buffer->params.size = 0;
tommi (sloooow) - chröme 2014/08/29 09:16:43 do we have unit tests?
no longer working on chromium 2014/08/29 11:15:20 Unfortunately we don't have unittest for this shar
315
312 // Use pre-allocated audio bus wrapping existing block of shared memory. 316 // Use pre-allocated audio bus wrapping existing block of shared memory.
313 media::AudioBus* audio_bus = audio_buses_[current_segment_id_]; 317 media::AudioBus* audio_bus = audio_buses_[current_segment_id_];
314 318
315 // Deliver captured data to the client in floating point format 319 // Deliver captured data to the client in floating point format
316 // and update the audio-delay measurement. 320 // and update the audio-delay measurement.
317 int audio_delay_milliseconds = pending_data / bytes_per_ms_; 321 int audio_delay_milliseconds = pending_data / bytes_per_ms_;
318 capture_callback_->Capture( 322 capture_callback_->Capture(
319 audio_bus, audio_delay_milliseconds, volume, key_pressed); 323 audio_bus, audio_delay_milliseconds, volume, key_pressed);
320 324
321 if (++current_segment_id_ >= total_segments_) 325 if (++current_segment_id_ >= total_segments_)
322 current_segment_id_ = 0; 326 current_segment_id_ = 0;
323 } 327 }
324 328
325 } // namespace media 329 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698