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

Side by Side Diff: media/renderers/audio_renderer_impl.cc

Issue 1409123005: Add methods for telling V8 how much memory audio/video is using. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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/renderers/audio_renderer_impl.h" 5 #include "media/renderers/audio_renderer_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 327
328 state_ = kInitializing; 328 state_ = kInitializing;
329 329
330 // Always post |init_cb_| because |this| could be destroyed if initialization 330 // Always post |init_cb_| because |this| could be destroyed if initialization
331 // failed. 331 // failed.
332 init_cb_ = BindToCurrentLoop(init_cb); 332 init_cb_ = BindToCurrentLoop(init_cb);
333 333
334 buffering_state_cb_ = buffering_state_cb; 334 buffering_state_cb_ = buffering_state_cb;
335 ended_cb_ = ended_cb; 335 ended_cb_ = ended_cb;
336 error_cb_ = error_cb; 336 error_cb_ = error_cb;
337 statistics_cb_ = statistics_cb;
337 338
338 const AudioParameters& hw_params = hardware_config_.GetOutputConfig(); 339 const AudioParameters& hw_params = hardware_config_.GetOutputConfig();
339 expecting_config_changes_ = stream->SupportsConfigChanges(); 340 expecting_config_changes_ = stream->SupportsConfigChanges();
340 if (!expecting_config_changes_ || !hw_params.IsValid()) { 341 if (!expecting_config_changes_ || !hw_params.IsValid()) {
341 // The actual buffer size is controlled via the size of the AudioBus 342 // The actual buffer size is controlled via the size of the AudioBus
342 // provided to Render(), so just choose something reasonable here for looks. 343 // provided to Render(), so just choose something reasonable here for looks.
343 int buffer_size = stream->audio_decoder_config().samples_per_second() / 100; 344 int buffer_size = stream->audio_decoder_config().samples_per_second() / 100;
344 audio_parameters_.Reset( 345 audio_parameters_.Reset(
345 AudioParameters::AUDIO_PCM_LOW_LATENCY, 346 AudioParameters::AUDIO_PCM_LOW_LATENCY,
346 stream->audio_decoder_config().channel_layout(), 347 stream->audio_decoder_config().channel_layout(),
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 508
508 if (state_ != kUninitialized) 509 if (state_ != kUninitialized)
509 algorithm_->EnqueueBuffer(buffer); 510 algorithm_->EnqueueBuffer(buffer);
510 } 511 }
511 512
512 // Store the timestamp of the first packet so we know when to start actual 513 // Store the timestamp of the first packet so we know when to start actual
513 // audio playback. 514 // audio playback.
514 if (first_packet_timestamp_ == kNoTimestamp()) 515 if (first_packet_timestamp_ == kNoTimestamp())
515 first_packet_timestamp_ = buffer->timestamp(); 516 first_packet_timestamp_ = buffer->timestamp();
516 517
518 PipelineStatistics stats;
519 stats.audio_memory_usage = algorithm_->GetMemoryUsage();
520 statistics_cb_.Run(stats);
521
517 switch (state_) { 522 switch (state_) {
518 case kUninitialized: 523 case kUninitialized:
519 case kInitializing: 524 case kInitializing:
520 case kFlushing: 525 case kFlushing:
521 NOTREACHED(); 526 NOTREACHED();
522 return false; 527 return false;
523 528
524 case kFlushed: 529 case kFlushed:
525 DCHECK(!pending_read_); 530 DCHECK(!pending_read_);
526 return false; 531 return false;
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 << buffering_state; 803 << buffering_state;
799 DCHECK_NE(buffering_state_, buffering_state); 804 DCHECK_NE(buffering_state_, buffering_state);
800 lock_.AssertAcquired(); 805 lock_.AssertAcquired();
801 buffering_state_ = buffering_state; 806 buffering_state_ = buffering_state;
802 807
803 task_runner_->PostTask(FROM_HERE, 808 task_runner_->PostTask(FROM_HERE,
804 base::Bind(buffering_state_cb_, buffering_state_)); 809 base::Bind(buffering_state_cb_, buffering_state_));
805 } 810 }
806 811
807 } // namespace media 812 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698