OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <limits> | 12 #include <limits> |
13 #include <list> | 13 #include <list> |
14 #include <numeric> | 14 #include <numeric> |
15 #include <string> | 15 #include <string> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "webrtc/base/arraysize.h" | 20 #include "webrtc/base/arraysize.h" |
21 #include "webrtc/base/criticalsection.h" | 21 #include "webrtc/base/criticalsection.h" |
22 #include "webrtc/base/scoped_ptr.h" | 22 #include "webrtc/base/scoped_ptr.h" |
| 23 #include "webrtc/base/scoped_ref_ptr.h" |
23 #include "webrtc/modules/audio_device/android/audio_common.h" | 24 #include "webrtc/modules/audio_device/android/audio_common.h" |
24 #include "webrtc/modules/audio_device/android/audio_manager.h" | 25 #include "webrtc/modules/audio_device/android/audio_manager.h" |
25 #include "webrtc/modules/audio_device/android/build_info.h" | 26 #include "webrtc/modules/audio_device/android/build_info.h" |
26 #include "webrtc/modules/audio_device/android/ensure_initialized.h" | 27 #include "webrtc/modules/audio_device/android/ensure_initialized.h" |
27 #include "webrtc/modules/audio_device/audio_device_impl.h" | 28 #include "webrtc/modules/audio_device/audio_device_impl.h" |
28 #include "webrtc/modules/audio_device/include/audio_device.h" | 29 #include "webrtc/modules/audio_device/include/audio_device.h" |
29 #include "webrtc/system_wrappers/interface/clock.h" | 30 #include "webrtc/system_wrappers/interface/clock.h" |
30 #include "webrtc/system_wrappers/interface/event_wrapper.h" | 31 #include "webrtc/system_wrappers/interface/event_wrapper.h" |
31 #include "webrtc/system_wrappers/interface/scoped_refptr.h" | |
32 #include "webrtc/system_wrappers/interface/sleep.h" | 32 #include "webrtc/system_wrappers/interface/sleep.h" |
33 #include "webrtc/test/testsupport/fileutils.h" | 33 #include "webrtc/test/testsupport/fileutils.h" |
34 | 34 |
35 using std::cout; | 35 using std::cout; |
36 using std::endl; | 36 using std::endl; |
37 using ::testing::_; | 37 using ::testing::_; |
38 using ::testing::AtLeast; | 38 using ::testing::AtLeast; |
39 using ::testing::Gt; | 39 using ::testing::Gt; |
40 using ::testing::Invoke; | 40 using ::testing::Invoke; |
41 using ::testing::NiceMock; | 41 using ::testing::NiceMock; |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 return playout_parameters_.frames_per_10ms_buffer(); | 529 return playout_parameters_.frames_per_10ms_buffer(); |
530 } | 530 } |
531 int record_frames_per_10ms_buffer() const { | 531 int record_frames_per_10ms_buffer() const { |
532 return record_parameters_.frames_per_10ms_buffer(); | 532 return record_parameters_.frames_per_10ms_buffer(); |
533 } | 533 } |
534 | 534 |
535 int total_delay_ms() const { | 535 int total_delay_ms() const { |
536 return audio_manager()->GetDelayEstimateInMilliseconds(); | 536 return audio_manager()->GetDelayEstimateInMilliseconds(); |
537 } | 537 } |
538 | 538 |
539 scoped_refptr<AudioDeviceModule> audio_device() const { | 539 rtc::scoped_refptr<AudioDeviceModule> audio_device() const { |
540 return audio_device_; | 540 return audio_device_; |
541 } | 541 } |
542 | 542 |
543 AudioDeviceModuleImpl* audio_device_impl() const { | 543 AudioDeviceModuleImpl* audio_device_impl() const { |
544 return static_cast<AudioDeviceModuleImpl*>(audio_device_.get()); | 544 return static_cast<AudioDeviceModuleImpl*>(audio_device_.get()); |
545 } | 545 } |
546 | 546 |
547 AudioManager* audio_manager() const { | 547 AudioManager* audio_manager() const { |
548 return audio_device_impl()->GetAndroidAudioManagerForTest(); | 548 return audio_device_impl()->GetAndroidAudioManagerForTest(); |
549 } | 549 } |
550 | 550 |
551 AudioManager* GetAudioManager(AudioDeviceModule* adm) const { | 551 AudioManager* GetAudioManager(AudioDeviceModule* adm) const { |
552 return static_cast<AudioDeviceModuleImpl*>(adm)-> | 552 return static_cast<AudioDeviceModuleImpl*>(adm)-> |
553 GetAndroidAudioManagerForTest(); | 553 GetAndroidAudioManagerForTest(); |
554 } | 554 } |
555 | 555 |
556 AudioDeviceBuffer* audio_device_buffer() const { | 556 AudioDeviceBuffer* audio_device_buffer() const { |
557 return audio_device_impl()->GetAudioDeviceBuffer(); | 557 return audio_device_impl()->GetAudioDeviceBuffer(); |
558 } | 558 } |
559 | 559 |
560 scoped_refptr<AudioDeviceModule> CreateAudioDevice( | 560 rtc::scoped_refptr<AudioDeviceModule> CreateAudioDevice( |
561 AudioDeviceModule::AudioLayer audio_layer) { | 561 AudioDeviceModule::AudioLayer audio_layer) { |
562 scoped_refptr<AudioDeviceModule> module( | 562 rtc::scoped_refptr<AudioDeviceModule> module( |
563 AudioDeviceModuleImpl::Create(0, audio_layer)); | 563 AudioDeviceModuleImpl::Create(0, audio_layer)); |
564 return module; | 564 return module; |
565 } | 565 } |
566 | 566 |
567 // Returns file name relative to the resource root given a sample rate. | 567 // Returns file name relative to the resource root given a sample rate. |
568 std::string GetFileName(int sample_rate) { | 568 std::string GetFileName(int sample_rate) { |
569 EXPECT_TRUE(sample_rate == 48000 || sample_rate == 44100); | 569 EXPECT_TRUE(sample_rate == 48000 || sample_rate == 44100); |
570 char fname[64]; | 570 char fname[64]; |
571 snprintf(fname, | 571 snprintf(fname, |
572 sizeof(fname), | 572 sizeof(fname), |
(...skipping 14 matching lines...) Expand all Loading... |
587 } | 587 } |
588 | 588 |
589 AudioDeviceModule::AudioLayer GetActiveAudioLayer() const { | 589 AudioDeviceModule::AudioLayer GetActiveAudioLayer() const { |
590 AudioDeviceModule::AudioLayer audio_layer; | 590 AudioDeviceModule::AudioLayer audio_layer; |
591 EXPECT_EQ(0, audio_device()->ActiveAudioLayer(&audio_layer)); | 591 EXPECT_EQ(0, audio_device()->ActiveAudioLayer(&audio_layer)); |
592 return audio_layer; | 592 return audio_layer; |
593 } | 593 } |
594 | 594 |
595 int TestDelayOnAudioLayer( | 595 int TestDelayOnAudioLayer( |
596 const AudioDeviceModule::AudioLayer& layer_to_test) { | 596 const AudioDeviceModule::AudioLayer& layer_to_test) { |
597 scoped_refptr<AudioDeviceModule> audio_device; | 597 rtc::scoped_refptr<AudioDeviceModule> audio_device; |
598 audio_device = CreateAudioDevice(layer_to_test); | 598 audio_device = CreateAudioDevice(layer_to_test); |
599 EXPECT_NE(audio_device.get(), nullptr); | 599 EXPECT_NE(audio_device.get(), nullptr); |
600 AudioManager* audio_manager = GetAudioManager(audio_device.get()); | 600 AudioManager* audio_manager = GetAudioManager(audio_device.get()); |
601 EXPECT_NE(audio_manager, nullptr); | 601 EXPECT_NE(audio_manager, nullptr); |
602 return audio_manager->GetDelayEstimateInMilliseconds(); | 602 return audio_manager->GetDelayEstimateInMilliseconds(); |
603 } | 603 } |
604 | 604 |
605 AudioDeviceModule::AudioLayer TestActiveAudioLayer( | 605 AudioDeviceModule::AudioLayer TestActiveAudioLayer( |
606 const AudioDeviceModule::AudioLayer& layer_to_test) { | 606 const AudioDeviceModule::AudioLayer& layer_to_test) { |
607 scoped_refptr<AudioDeviceModule> audio_device; | 607 rtc::scoped_refptr<AudioDeviceModule> audio_device; |
608 audio_device = CreateAudioDevice(layer_to_test); | 608 audio_device = CreateAudioDevice(layer_to_test); |
609 EXPECT_NE(audio_device.get(), nullptr); | 609 EXPECT_NE(audio_device.get(), nullptr); |
610 AudioDeviceModule::AudioLayer active; | 610 AudioDeviceModule::AudioLayer active; |
611 EXPECT_EQ(0, audio_device->ActiveAudioLayer(&active)); | 611 EXPECT_EQ(0, audio_device->ActiveAudioLayer(&active)); |
612 return active; | 612 return active; |
613 } | 613 } |
614 | 614 |
615 bool DisableTestForThisDevice(const std::string& model) { | 615 bool DisableTestForThisDevice(const std::string& model) { |
616 return (build_info_->GetDeviceModel() == model); | 616 return (build_info_->GetDeviceModel() == model); |
617 } | 617 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 return min_volume; | 678 return min_volume; |
679 } | 679 } |
680 | 680 |
681 int GetSpeakerVolume() const { | 681 int GetSpeakerVolume() const { |
682 uint32_t volume(0); | 682 uint32_t volume(0); |
683 EXPECT_EQ(0, audio_device()->SpeakerVolume(&volume)); | 683 EXPECT_EQ(0, audio_device()->SpeakerVolume(&volume)); |
684 return volume; | 684 return volume; |
685 } | 685 } |
686 | 686 |
687 rtc::scoped_ptr<EventWrapper> test_is_done_; | 687 rtc::scoped_ptr<EventWrapper> test_is_done_; |
688 scoped_refptr<AudioDeviceModule> audio_device_; | 688 rtc::scoped_refptr<AudioDeviceModule> audio_device_; |
689 AudioParameters playout_parameters_; | 689 AudioParameters playout_parameters_; |
690 AudioParameters record_parameters_; | 690 AudioParameters record_parameters_; |
691 rtc::scoped_ptr<BuildInfo> build_info_; | 691 rtc::scoped_ptr<BuildInfo> build_info_; |
692 }; | 692 }; |
693 | 693 |
694 TEST_F(AudioDeviceTest, ConstructDestruct) { | 694 TEST_F(AudioDeviceTest, ConstructDestruct) { |
695 // Using the test fixture to create and destruct the audio device module. | 695 // Using the test fixture to create and destruct the audio device module. |
696 } | 696 } |
697 | 697 |
698 // We always ask for a default audio layer when the ADM is constructed. But the | 698 // We always ask for a default audio layer when the ADM is constructed. But the |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 1000 * kMeasureLatencyTimeInSec)); | 998 1000 * kMeasureLatencyTimeInSec)); |
999 StopPlayout(); | 999 StopPlayout(); |
1000 StopRecording(); | 1000 StopRecording(); |
1001 // Verify that the correct number of transmitted impulses are detected. | 1001 // Verify that the correct number of transmitted impulses are detected. |
1002 EXPECT_EQ(latency_audio_stream->num_latency_values(), | 1002 EXPECT_EQ(latency_audio_stream->num_latency_values(), |
1003 kImpulseFrequencyInHz * kMeasureLatencyTimeInSec - 1); | 1003 kImpulseFrequencyInHz * kMeasureLatencyTimeInSec - 1); |
1004 latency_audio_stream->PrintResults(); | 1004 latency_audio_stream->PrintResults(); |
1005 } | 1005 } |
1006 | 1006 |
1007 } // namespace webrtc | 1007 } // namespace webrtc |
OLD | NEW |