OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/android/build_info.h" | 7 #include "base/android/build_info.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 bool started_; | 408 bool started_; |
409 | 409 |
410 DISALLOW_COPY_AND_ASSIGN(FullDuplexAudioSinkSource); | 410 DISALLOW_COPY_AND_ASSIGN(FullDuplexAudioSinkSource); |
411 }; | 411 }; |
412 | 412 |
413 // Test fixture class for tests which only exercise the output path. | 413 // Test fixture class for tests which only exercise the output path. |
414 class AudioAndroidOutputTest : public testing::Test { | 414 class AudioAndroidOutputTest : public testing::Test { |
415 public: | 415 public: |
416 AudioAndroidOutputTest() | 416 AudioAndroidOutputTest() |
417 : loop_(new base::MessageLoopForUI()), | 417 : loop_(new base::MessageLoopForUI()), |
418 audio_manager_(AudioManager::CreateForTesting()), | 418 audio_manager_(AudioManager::CreateForTesting(loop_->task_runner())), |
419 audio_output_stream_(NULL) { | 419 audio_output_stream_(NULL) { |
| 420 // Flush the message loop to ensure that AudioManager is fully initialized. |
| 421 loop_->RunUntilIdle(); |
420 } | 422 } |
421 | 423 |
422 ~AudioAndroidOutputTest() override {} | 424 ~AudioAndroidOutputTest() override {} |
423 | 425 |
424 protected: | 426 protected: |
425 AudioManager* audio_manager() { return audio_manager_.get(); } | 427 AudioManager* audio_manager() { return audio_manager_.get(); } |
426 base::MessageLoopForUI* loop() { return loop_.get(); } | 428 base::MessageLoopForUI* loop() { return loop_.get(); } |
427 const AudioParameters& audio_output_parameters() { | 429 const AudioParameters& audio_output_parameters() { |
428 return audio_output_parameters_; | 430 return audio_output_parameters_; |
429 } | 431 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 } | 556 } |
555 | 557 |
556 void StopAndClose() { | 558 void StopAndClose() { |
557 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); | 559 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); |
558 audio_output_stream_->Stop(); | 560 audio_output_stream_->Stop(); |
559 audio_output_stream_->Close(); | 561 audio_output_stream_->Close(); |
560 audio_output_stream_ = NULL; | 562 audio_output_stream_ = NULL; |
561 } | 563 } |
562 | 564 |
563 scoped_ptr<base::MessageLoopForUI> loop_; | 565 scoped_ptr<base::MessageLoopForUI> loop_; |
564 scoped_ptr<AudioManager> audio_manager_; | 566 ScopedAudioManagerPtr audio_manager_; |
565 AudioParameters audio_output_parameters_; | 567 AudioParameters audio_output_parameters_; |
566 AudioOutputStream* audio_output_stream_; | 568 AudioOutputStream* audio_output_stream_; |
567 base::TimeTicks start_time_; | 569 base::TimeTicks start_time_; |
568 base::TimeTicks end_time_; | 570 base::TimeTicks end_time_; |
569 | 571 |
570 private: | 572 private: |
571 DISALLOW_COPY_AND_ASSIGN(AudioAndroidOutputTest); | 573 DISALLOW_COPY_AND_ASSIGN(AudioAndroidOutputTest); |
572 }; | 574 }; |
573 | 575 |
574 // AudioRecordInputStream should only be created on Jelly Bean and higher. This | 576 // AudioRecordInputStream should only be created on Jelly Bean and higher. This |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); | 955 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); |
954 printf("\n"); | 956 printf("\n"); |
955 StopAndCloseAudioOutputStreamOnAudioThread(); | 957 StopAndCloseAudioOutputStreamOnAudioThread(); |
956 StopAndCloseAudioInputStreamOnAudioThread(); | 958 StopAndCloseAudioInputStreamOnAudioThread(); |
957 } | 959 } |
958 | 960 |
959 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, | 961 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, |
960 testing::ValuesIn(RunAudioRecordInputPathTests())); | 962 testing::ValuesIn(RunAudioRecordInputPathTests())); |
961 | 963 |
962 } // namespace media | 964 } // namespace media |
OLD | NEW |