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

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

Issue 2146513002: More tracing for audio rendering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: actual code Created 4 years, 4 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_output_resampler.h" 5 #include "media/audio/audio_output_resampler.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 const int input_bytes_per_frame_; 65 const int input_bytes_per_frame_;
66 66
67 // Handles resampling, buffering, and channel mixing between input and output 67 // Handles resampling, buffering, and channel mixing between input and output
68 // parameters. 68 // parameters.
69 AudioConverter audio_converter_; 69 AudioConverter audio_converter_;
70 70
71 // True if OnError() was ever called. Should only be read if the underlying 71 // True if OnError() was ever called. Should only be read if the underlying
72 // stream has been stopped. 72 // stream has been stopped.
73 bool error_occurred_; 73 bool error_occurred_;
74 74
75 // Information about input and output buffer sizes to be traced.
76 const int input_buffer_size_;
77 const int output_buffer_size_;
78
75 DISALLOW_COPY_AND_ASSIGN(OnMoreDataConverter); 79 DISALLOW_COPY_AND_ASSIGN(OnMoreDataConverter);
76 }; 80 };
77 81
78 // Record UMA statistics for hardware output configuration. 82 // Record UMA statistics for hardware output configuration.
79 static void RecordStats(const AudioParameters& output_params) { 83 static void RecordStats(const AudioParameters& output_params) {
80 // Note the 'PRESUBMIT_IGNORE_UMA_MAX's below, these silence the PRESUBMIT.py 84 // Note the 'PRESUBMIT_IGNORE_UMA_MAX's below, these silence the PRESUBMIT.py
81 // check for uma enum max usage, since we're abusing UMA_HISTOGRAM_ENUMERATION 85 // check for uma enum max usage, since we're abusing UMA_HISTOGRAM_ENUMERATION
82 // to report a discrete value. 86 // to report a discrete value.
83 UMA_HISTOGRAM_ENUMERATION( 87 UMA_HISTOGRAM_ENUMERATION(
84 "Media.HardwareAudioBitsPerChannel", 88 "Media.HardwareAudioBitsPerChannel",
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 DCHECK(callbacks_.empty()); 345 DCHECK(callbacks_.empty());
342 } 346 }
343 347
344 OnMoreDataConverter::OnMoreDataConverter(const AudioParameters& input_params, 348 OnMoreDataConverter::OnMoreDataConverter(const AudioParameters& input_params,
345 const AudioParameters& output_params) 349 const AudioParameters& output_params)
346 : io_ratio_(static_cast<double>(input_params.GetBytesPerSecond()) / 350 : io_ratio_(static_cast<double>(input_params.GetBytesPerSecond()) /
347 output_params.GetBytesPerSecond()), 351 output_params.GetBytesPerSecond()),
348 source_callback_(nullptr), 352 source_callback_(nullptr),
349 input_bytes_per_frame_(input_params.GetBytesPerFrame()), 353 input_bytes_per_frame_(input_params.GetBytesPerFrame()),
350 audio_converter_(input_params, output_params, false), 354 audio_converter_(input_params, output_params, false),
351 error_occurred_(false) {} 355 error_occurred_(false),
356 input_buffer_size_(input_params.frames_per_buffer()),
357 output_buffer_size_(output_params.frames_per_buffer()) {}
352 358
353 OnMoreDataConverter::~OnMoreDataConverter() { 359 OnMoreDataConverter::~OnMoreDataConverter() {
354 // Ensure Stop() has been called so we don't end up with an AudioOutputStream 360 // Ensure Stop() has been called so we don't end up with an AudioOutputStream
355 // calling back into OnMoreData() after destruction. 361 // calling back into OnMoreData() after destruction.
356 CHECK(!source_callback_); 362 CHECK(!source_callback_);
357 } 363 }
358 364
359 void OnMoreDataConverter::Start( 365 void OnMoreDataConverter::Start(
360 AudioOutputStream::AudioSourceCallback* callback) { 366 AudioOutputStream::AudioSourceCallback* callback) {
361 CHECK(!source_callback_); 367 CHECK(!source_callback_);
362 source_callback_ = callback; 368 source_callback_ = callback;
363 369
364 // While AudioConverter can handle multiple inputs, we're using it only with 370 // While AudioConverter can handle multiple inputs, we're using it only with
365 // a single input currently. Eventually this may be the basis for a browser 371 // a single input currently. Eventually this may be the basis for a browser
366 // side mixer. 372 // side mixer.
367 audio_converter_.AddInput(this); 373 audio_converter_.AddInput(this);
368 } 374 }
369 375
370 void OnMoreDataConverter::Stop() { 376 void OnMoreDataConverter::Stop() {
371 CHECK(source_callback_); 377 CHECK(source_callback_);
372 source_callback_ = nullptr; 378 source_callback_ = nullptr;
373 audio_converter_.RemoveInput(this); 379 audio_converter_.RemoveInput(this);
374 } 380 }
375 381
376 int OnMoreDataConverter::OnMoreData(AudioBus* dest, 382 int OnMoreDataConverter::OnMoreData(AudioBus* dest,
377 uint32_t total_bytes_delay, 383 uint32_t total_bytes_delay,
378 uint32_t frames_skipped) { 384 uint32_t frames_skipped) {
385 TRACE_EVENT2("audio", "OnMoreDataConverter::OnMoreData", "input buffer size",
o1ka 2016/08/19 13:20:47 Passing buffer sizes on each trace does not look c
DaleCurtis 2016/08/19 16:49:00 Also is it useful to have this information? Isn't
386 input_buffer_size_, "output buffer size", output_buffer_size_);
379 current_total_bytes_delay_ = total_bytes_delay; 387 current_total_bytes_delay_ = total_bytes_delay;
380 audio_converter_.Convert(dest); 388 audio_converter_.Convert(dest);
381 389
382 // Always return the full number of frames requested, ProvideInput() 390 // Always return the full number of frames requested, ProvideInput()
383 // will pad with silence if it wasn't able to acquire enough data. 391 // will pad with silence if it wasn't able to acquire enough data.
384 return dest->frames(); 392 return dest->frames();
385 } 393 }
386 394
387 double OnMoreDataConverter::ProvideInput(AudioBus* dest, 395 double OnMoreDataConverter::ProvideInput(AudioBus* dest,
388 uint32_t frames_delayed) { 396 uint32_t frames_delayed) {
(...skipping 14 matching lines...) Expand all
403 dest->ZeroFramesPartial(frames, dest->frames() - frames); 411 dest->ZeroFramesPartial(frames, dest->frames() - frames);
404 return frames > 0 ? 1 : 0; 412 return frames > 0 ? 1 : 0;
405 } 413 }
406 414
407 void OnMoreDataConverter::OnError(AudioOutputStream* stream) { 415 void OnMoreDataConverter::OnError(AudioOutputStream* stream) {
408 error_occurred_ = true; 416 error_occurred_ = true;
409 source_callback_->OnError(stream); 417 source_callback_->OnError(stream);
410 } 418 }
411 419
412 } // namespace media 420 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698