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(loop_->task_runner())), | 418 audio_manager_(AudioManager::CreateForTesting()), |
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(); | |
422 } | 420 } |
423 | 421 |
424 ~AudioAndroidOutputTest() override { | 422 ~AudioAndroidOutputTest() override {} |
425 audio_manager_.reset(); | |
426 loop_->RunUntilIdle(); | |
427 } | |
428 | 423 |
429 protected: | 424 protected: |
430 AudioManager* audio_manager() { return audio_manager_.get(); } | 425 AudioManager* audio_manager() { return audio_manager_.get(); } |
431 base::MessageLoopForUI* loop() { return loop_.get(); } | 426 base::MessageLoopForUI* loop() { return loop_.get(); } |
432 const AudioParameters& audio_output_parameters() { | 427 const AudioParameters& audio_output_parameters() { |
433 return audio_output_parameters_; | 428 return audio_output_parameters_; |
434 } | 429 } |
435 | 430 |
436 // Synchronously runs the provided callback/closure on the audio thread. | 431 // Synchronously runs the provided callback/closure on the audio thread. |
437 void RunOnAudioThread(const base::Closure& closure) { | 432 void RunOnAudioThread(const base::Closure& closure) { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 } | 554 } |
560 | 555 |
561 void StopAndClose() { | 556 void StopAndClose() { |
562 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); | 557 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); |
563 audio_output_stream_->Stop(); | 558 audio_output_stream_->Stop(); |
564 audio_output_stream_->Close(); | 559 audio_output_stream_->Close(); |
565 audio_output_stream_ = NULL; | 560 audio_output_stream_ = NULL; |
566 } | 561 } |
567 | 562 |
568 scoped_ptr<base::MessageLoopForUI> loop_; | 563 scoped_ptr<base::MessageLoopForUI> loop_; |
569 ScopedAudioManagerPtr audio_manager_; | 564 scoped_ptr<AudioManager> audio_manager_; |
570 AudioParameters audio_output_parameters_; | 565 AudioParameters audio_output_parameters_; |
571 AudioOutputStream* audio_output_stream_; | 566 AudioOutputStream* audio_output_stream_; |
572 base::TimeTicks start_time_; | 567 base::TimeTicks start_time_; |
573 base::TimeTicks end_time_; | 568 base::TimeTicks end_time_; |
574 | 569 |
575 private: | 570 private: |
576 DISALLOW_COPY_AND_ASSIGN(AudioAndroidOutputTest); | 571 DISALLOW_COPY_AND_ASSIGN(AudioAndroidOutputTest); |
577 }; | 572 }; |
578 | 573 |
579 // AudioRecordInputStream should only be created on Jelly Bean and higher. This | 574 // AudioRecordInputStream should only be created on Jelly Bean and higher. This |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); | 953 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); |
959 printf("\n"); | 954 printf("\n"); |
960 StopAndCloseAudioOutputStreamOnAudioThread(); | 955 StopAndCloseAudioOutputStreamOnAudioThread(); |
961 StopAndCloseAudioInputStreamOnAudioThread(); | 956 StopAndCloseAudioInputStreamOnAudioThread(); |
962 } | 957 } |
963 | 958 |
964 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, | 959 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, |
965 testing::ValuesIn(RunAudioRecordInputPathTests())); | 960 testing::ValuesIn(RunAudioRecordInputPathTests())); |
966 | 961 |
967 } // namespace media | 962 } // namespace media |
OLD | NEW |