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

Side by Side Diff: media/renderers/audio_renderer_impl_unittest.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: Fix html viewer. Created 5 years, 1 month 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
« no previous file with comments | « media/renderers/audio_renderer_impl.cc ('k') | media/renderers/video_renderer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback_helpers.h" 6 #include "base/callback_helpers.h"
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/test/simple_test_tick_clock.h" 10 #include "base/test/simple_test_tick_clock.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 virtual ~AudioRendererImplTest() { 107 virtual ~AudioRendererImplTest() {
108 SCOPED_TRACE("~AudioRendererImplTest()"); 108 SCOPED_TRACE("~AudioRendererImplTest()");
109 } 109 }
110 110
111 void ExpectUnsupportedAudioDecoder() { 111 void ExpectUnsupportedAudioDecoder() {
112 EXPECT_CALL(*decoder_, Initialize(_, _, _)) 112 EXPECT_CALL(*decoder_, Initialize(_, _, _))
113 .WillOnce(DoAll(SaveArg<2>(&output_cb_), RunCallback<1>(false))); 113 .WillOnce(DoAll(SaveArg<2>(&output_cb_), RunCallback<1>(false)));
114 } 114 }
115 115
116 MOCK_METHOD1(OnStatistics, void(const PipelineStatistics&)); 116 void OnStatistics(const PipelineStatistics& stats) {
117 last_statistics_.audio_memory_usage += stats.audio_memory_usage;
118 }
119
117 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState)); 120 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState));
118 MOCK_METHOD1(OnError, void(PipelineStatus)); 121 MOCK_METHOD1(OnError, void(PipelineStatus));
119 MOCK_METHOD0(OnWaitingForDecryptionKey, void(void)); 122 MOCK_METHOD0(OnWaitingForDecryptionKey, void(void));
120 123
121 void InitializeRenderer(const PipelineStatusCB& pipeline_status_cb) { 124 void InitializeRenderer(const PipelineStatusCB& pipeline_status_cb) {
122 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); 125 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0);
123 renderer_->Initialize( 126 renderer_->Initialize(
124 &demuxer_stream_, pipeline_status_cb, SetDecryptorReadyCB(), 127 &demuxer_stream_, pipeline_status_cb, SetDecryptorReadyCB(),
125 base::Bind(&AudioRendererImplTest::OnStatistics, 128 base::Bind(&AudioRendererImplTest::OnStatistics,
126 base::Unretained(this)), 129 base::Unretained(this)),
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 FROM_HERE, 272 FROM_HERE,
270 base::Bind(base::ResetAndReturn(&decode_cb_), AudioDecoder::kOk)); 273 base::Bind(base::ResetAndReturn(&decode_cb_), AudioDecoder::kOk));
271 274
272 WaitForPendingRead(); 275 WaitForPendingRead();
273 276
274 message_loop_.PostTask( 277 message_loop_.PostTask(
275 FROM_HERE, 278 FROM_HERE,
276 base::Bind(base::ResetAndReturn(&decode_cb_), AudioDecoder::kOk)); 279 base::Bind(base::ResetAndReturn(&decode_cb_), AudioDecoder::kOk));
277 280
278 base::RunLoop().RunUntilIdle(); 281 base::RunLoop().RunUntilIdle();
282 EXPECT_EQ(last_statistics_.audio_memory_usage,
283 renderer_->algorithm_->GetMemoryUsage());
279 } 284 }
280 285
281 // Delivers frames until |renderer_|'s internal buffer is full and no longer 286 // Delivers frames until |renderer_|'s internal buffer is full and no longer
282 // has pending reads. 287 // has pending reads.
283 void DeliverRemainingAudio() { 288 void DeliverRemainingAudio() {
284 while (frames_remaining_in_buffer().value > 0) { 289 while (frames_remaining_in_buffer().value > 0) {
285 SatisfyPendingRead(InputFrames(256)); 290 SatisfyPendingRead(InputFrames(256));
286 } 291 }
287 } 292 }
288 293
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 } 357 }
353 358
354 bool ended() const { return ended_; } 359 bool ended() const { return ended_; }
355 360
356 // Fixture members. 361 // Fixture members.
357 base::MessageLoop message_loop_; 362 base::MessageLoop message_loop_;
358 scoped_ptr<AudioRendererImpl> renderer_; 363 scoped_ptr<AudioRendererImpl> renderer_;
359 scoped_refptr<FakeAudioRendererSink> sink_; 364 scoped_refptr<FakeAudioRendererSink> sink_;
360 AudioHardwareConfig hardware_config_; 365 AudioHardwareConfig hardware_config_;
361 base::SimpleTestTickClock* tick_clock_; 366 base::SimpleTestTickClock* tick_clock_;
367 PipelineStatistics last_statistics_;
362 368
363 private: 369 private:
364 void DecodeDecoder(const scoped_refptr<DecoderBuffer>& buffer, 370 void DecodeDecoder(const scoped_refptr<DecoderBuffer>& buffer,
365 const AudioDecoder::DecodeCB& decode_cb) { 371 const AudioDecoder::DecodeCB& decode_cb) {
366 // TODO(scherkus): Make this a DCHECK after threading semantics are fixed. 372 // TODO(scherkus): Make this a DCHECK after threading semantics are fixed.
367 if (base::MessageLoop::current() != &message_loop_) { 373 if (base::MessageLoop::current() != &message_loop_) {
368 message_loop_.PostTask(FROM_HERE, base::Bind( 374 message_loop_.PostTask(FROM_HERE, base::Bind(
369 &AudioRendererImplTest::DecodeDecoder, 375 &AudioRendererImplTest::DecodeDecoder,
370 base::Unretained(this), buffer, decode_cb)); 376 base::Unretained(this), buffer, decode_cb));
371 return; 377 return;
(...skipping 14 matching lines...) Expand all
386 reset_cb_ = reset_cb; 392 reset_cb_ = reset_cb;
387 return; 393 return;
388 } 394 }
389 395
390 message_loop_.PostTask(FROM_HERE, reset_cb); 396 message_loop_.PostTask(FROM_HERE, reset_cb);
391 } 397 }
392 398
393 void DeliverBuffer(AudioDecoder::Status status, 399 void DeliverBuffer(AudioDecoder::Status status,
394 const scoped_refptr<AudioBuffer>& buffer) { 400 const scoped_refptr<AudioBuffer>& buffer) {
395 CHECK(!decode_cb_.is_null()); 401 CHECK(!decode_cb_.is_null());
402
396 if (buffer.get() && !buffer->end_of_stream()) 403 if (buffer.get() && !buffer->end_of_stream())
397 output_cb_.Run(buffer); 404 output_cb_.Run(buffer);
398 base::ResetAndReturn(&decode_cb_).Run(status); 405 base::ResetAndReturn(&decode_cb_).Run(status);
399 406
400 if (!reset_cb_.is_null()) 407 if (!reset_cb_.is_null())
401 base::ResetAndReturn(&reset_cb_).Run(); 408 base::ResetAndReturn(&reset_cb_).Run();
402 409
403 base::RunLoop().RunUntilIdle(); 410 base::RunLoop().RunUntilIdle();
404 } 411 }
405 412
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 // Advance far enough that we shouldn't be clamped to current time (tested 882 // Advance far enough that we shouldn't be clamped to current time (tested
876 // already above). 883 // already above).
877 tick_clock_->Advance(kOneSecond); 884 tick_clock_->Advance(kOneSecond);
878 EXPECT_EQ( 885 EXPECT_EQ(
879 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value), 886 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value),
880 CurrentMediaWallClockTime(&is_time_moving)); 887 CurrentMediaWallClockTime(&is_time_moving));
881 EXPECT_TRUE(is_time_moving); 888 EXPECT_TRUE(is_time_moving);
882 } 889 }
883 890
884 } // namespace media 891 } // namespace media
OLDNEW
« no previous file with comments | « media/renderers/audio_renderer_impl.cc ('k') | media/renderers/video_renderer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698