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

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

Issue 2582703003: Audio output debug recording. (Closed)
Patch Set: Code review. Created 3 years, 9 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
« no previous file with comments | « media/audio/audio_manager_unittest.cc ('k') | media/audio/audio_output_resampler.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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 namespace { 44 namespace {
45 45
46 static const int kTestCloseDelayMs = 10; 46 static const int kTestCloseDelayMs = 10;
47 47
48 // Delay between callbacks to AudioSourceCallback::OnMoreData. 48 // Delay between callbacks to AudioSourceCallback::OnMoreData.
49 static const int kOnMoreDataCallbackDelayMs = 10; 49 static const int kOnMoreDataCallbackDelayMs = 10;
50 50
51 // Let start run long enough for many OnMoreData callbacks to occur. 51 // Let start run long enough for many OnMoreData callbacks to occur.
52 static const int kStartRunTimeMs = kOnMoreDataCallbackDelayMs * 10; 52 static const int kStartRunTimeMs = kOnMoreDataCallbackDelayMs * 10;
53 53
54 // Dummy function.
55 std::unique_ptr<media::AudioDebugRecorder> RegisterDebugRecording(
56 const media::AudioParameters& params) {
57 return nullptr;
58 }
59
54 class MockAudioOutputStream : public AudioOutputStream { 60 class MockAudioOutputStream : public AudioOutputStream {
55 public: 61 public:
56 MockAudioOutputStream(AudioManagerBase* manager, 62 MockAudioOutputStream(AudioManagerBase* manager,
57 const AudioParameters& params) 63 const AudioParameters& params)
58 : start_called_(false), 64 : start_called_(false),
59 stop_called_(false), 65 stop_called_(false),
60 params_(params), 66 params_(params),
61 fake_output_stream_( 67 fake_output_stream_(
62 FakeAudioOutputStream::MakeFakeStream(manager, params_)) { 68 FakeAudioOutputStream::MakeFakeStream(manager, params_)) {
63 } 69 }
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 void TearDown() override { AudioOutputProxyTest::TearDown(); } 498 void TearDown() override { AudioOutputProxyTest::TearDown(); }
493 499
494 void InitDispatcher(base::TimeDelta close_delay) override { 500 void InitDispatcher(base::TimeDelta close_delay) override {
495 // Use a low sample rate and large buffer size when testing otherwise the 501 // Use a low sample rate and large buffer size when testing otherwise the
496 // FakeAudioOutputStream will keep the message loop busy indefinitely; i.e., 502 // FakeAudioOutputStream will keep the message loop busy indefinitely; i.e.,
497 // RunUntilIdle() will never terminate. 503 // RunUntilIdle() will never terminate.
498 resampler_params_ = AudioParameters( 504 resampler_params_ = AudioParameters(
499 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO, 505 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO,
500 16000, 16, 1024); 506 16000, 16, 1024);
501 resampler_ = base::MakeUnique<AudioOutputResampler>( 507 resampler_ = base::MakeUnique<AudioOutputResampler>(
502 &manager(), params_, resampler_params_, std::string(), close_delay); 508 &manager(), params_, resampler_params_, std::string(), close_delay,
509 base::BindRepeating(&RegisterDebugRecording));
503 } 510 }
504 511
505 void OnStart() override { 512 void OnStart() override {
506 // Let Start() run for a bit. 513 // Let Start() run for a bit.
507 base::RunLoop run_loop; 514 base::RunLoop run_loop;
508 message_loop_.task_runner()->PostDelayedTask( 515 message_loop_.task_runner()->PostDelayedTask(
509 FROM_HERE, run_loop.QuitClosure(), 516 FROM_HERE, run_loop.QuitClosure(),
510 base::TimeDelta::FromMilliseconds(kStartRunTimeMs)); 517 base::TimeDelta::FromMilliseconds(kStartRunTimeMs));
511 run_loop.Run(); 518 run_loop.Run();
512 } 519 }
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 .WillOnce(Return(&real_stream)); 840 .WillOnce(Return(&real_stream));
834 841
835 // Stream1 should be able to successfully open and start. 842 // Stream1 should be able to successfully open and start.
836 EXPECT_CALL(real_stream, Open()).WillOnce(Return(true)); 843 EXPECT_CALL(real_stream, Open()).WillOnce(Return(true));
837 proxy = resampler_->CreateStreamProxy(); 844 proxy = resampler_->CreateStreamProxy();
838 EXPECT_TRUE(proxy->Open()); 845 EXPECT_TRUE(proxy->Open());
839 CloseAndWaitForCloseTimer(proxy, &real_stream); 846 CloseAndWaitForCloseTimer(proxy, &real_stream);
840 } 847 }
841 848
842 } // namespace media 849 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_manager_unittest.cc ('k') | media/audio/audio_output_resampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698