| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 using namespace webrtc; | 47 using namespace webrtc; |
| 48 | 48 |
| 49 class AudioEventObserverAPI: public AudioDeviceObserver { | 49 class AudioEventObserverAPI: public AudioDeviceObserver { |
| 50 public: | 50 public: |
| 51 AudioEventObserverAPI( | 51 AudioEventObserverAPI( |
| 52 const rtc::scoped_refptr<AudioDeviceModule>& audioDevice) | 52 const rtc::scoped_refptr<AudioDeviceModule>& audioDevice) |
| 53 : error_(kRecordingError), | 53 : error_(kRecordingError), |
| 54 warning_(kRecordingWarning), | 54 warning_(kRecordingWarning), |
| 55 audio_device_(audioDevice) {} | 55 audio_device_(audioDevice) {} |
| 56 | 56 |
| 57 ~AudioEventObserverAPI() {} | 57 ~AudioEventObserverAPI() override {} |
| 58 | 58 |
| 59 virtual void OnErrorIsReported(const ErrorCode error) { | 59 void OnErrorIsReported(const ErrorCode error) override { |
| 60 TEST_LOG("\n[*** ERROR ***] => OnErrorIsReported(%d)\n\n", error); | 60 TEST_LOG("\n[*** ERROR ***] => OnErrorIsReported(%d)\n\n", error); |
| 61 error_ = error; | 61 error_ = error; |
| 62 } | 62 } |
| 63 | 63 |
| 64 virtual void OnWarningIsReported(const WarningCode warning) { | 64 void OnWarningIsReported(const WarningCode warning) override { |
| 65 TEST_LOG("\n[*** WARNING ***] => OnWarningIsReported(%d)\n\n", warning); | 65 TEST_LOG("\n[*** WARNING ***] => OnWarningIsReported(%d)\n\n", warning); |
| 66 warning_ = warning; | 66 warning_ = warning; |
| 67 EXPECT_EQ(0, audio_device_->StopRecording()); | 67 EXPECT_EQ(0, audio_device_->StopRecording()); |
| 68 EXPECT_EQ(0, audio_device_->StopPlayout()); | 68 EXPECT_EQ(0, audio_device_->StopPlayout()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 public: | 71 public: |
| 72 ErrorCode error_; | 72 ErrorCode error_; |
| 73 WarningCode warning_; | 73 WarningCode warning_; |
| 74 private: | 74 private: |
| 75 rtc::scoped_refptr<AudioDeviceModule> audio_device_; | 75 rtc::scoped_refptr<AudioDeviceModule> audio_device_; |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 class AudioTransportAPI: public AudioTransport { | 78 class AudioTransportAPI: public AudioTransport { |
| 79 public: | 79 public: |
| 80 AudioTransportAPI(const rtc::scoped_refptr<AudioDeviceModule>& audioDevice) | 80 AudioTransportAPI(const rtc::scoped_refptr<AudioDeviceModule>& audioDevice) |
| 81 : rec_count_(0), | 81 : rec_count_(0), |
| 82 play_count_(0) { | 82 play_count_(0) { |
| 83 } | 83 } |
| 84 | 84 |
| 85 ~AudioTransportAPI() {} | 85 ~AudioTransportAPI() override {} |
| 86 | 86 |
| 87 int32_t RecordedDataIsAvailable(const void* audioSamples, | 87 int32_t RecordedDataIsAvailable(const void* audioSamples, |
| 88 const size_t nSamples, | 88 const size_t nSamples, |
| 89 const size_t nBytesPerSample, | 89 const size_t nBytesPerSample, |
| 90 const size_t nChannels, | 90 const size_t nChannels, |
| 91 const uint32_t sampleRate, | 91 const uint32_t sampleRate, |
| 92 const uint32_t totalDelay, | 92 const uint32_t totalDelay, |
| 93 const int32_t clockSkew, | 93 const int32_t clockSkew, |
| 94 const uint32_t currentMicLevel, | 94 const uint32_t currentMicLevel, |
| 95 const bool keyPressed, | 95 const bool keyPressed, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 132 |
| 133 private: | 133 private: |
| 134 uint32_t rec_count_; | 134 uint32_t rec_count_; |
| 135 uint32_t play_count_; | 135 uint32_t play_count_; |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 class AudioDeviceAPITest: public testing::Test { | 138 class AudioDeviceAPITest: public testing::Test { |
| 139 protected: | 139 protected: |
| 140 AudioDeviceAPITest() {} | 140 AudioDeviceAPITest() {} |
| 141 | 141 |
| 142 virtual ~AudioDeviceAPITest() {} | 142 ~AudioDeviceAPITest() override {} |
| 143 | 143 |
| 144 static void SetUpTestCase() { | 144 static void SetUpTestCase() { |
| 145 process_thread_ = ProcessThread::Create("ProcessThread"); | 145 process_thread_ = ProcessThread::Create("ProcessThread"); |
| 146 process_thread_->Start(); | 146 process_thread_->Start(); |
| 147 | 147 |
| 148 // Windows: | 148 // Windows: |
| 149 // if (WEBRTC_WINDOWS_CORE_AUDIO_BUILD) | 149 // if (WEBRTC_WINDOWS_CORE_AUDIO_BUILD) |
| 150 // user can select between default (Core) or Wave | 150 // user can select between default (Core) or Wave |
| 151 // else | 151 // else |
| 152 // user can select between default (Wave) or Wave | 152 // user can select between default (Wave) or Wave |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 } | 251 } |
| 252 if (audio_transport_) { | 252 if (audio_transport_) { |
| 253 delete audio_transport_; | 253 delete audio_transport_; |
| 254 audio_transport_ = NULL; | 254 audio_transport_ = NULL; |
| 255 } | 255 } |
| 256 if (audio_device_) | 256 if (audio_device_) |
| 257 EXPECT_EQ(0, audio_device_.release()->Release()); | 257 EXPECT_EQ(0, audio_device_.release()->Release()); |
| 258 PRINT_TEST_RESULTS; | 258 PRINT_TEST_RESULTS; |
| 259 } | 259 } |
| 260 | 260 |
| 261 void SetUp() { | 261 void SetUp() override { |
| 262 if (linux_alsa_) { | 262 if (linux_alsa_) { |
| 263 FAIL() << "API Test is not available on ALSA on Linux!"; | 263 FAIL() << "API Test is not available on ALSA on Linux!"; |
| 264 } | 264 } |
| 265 EXPECT_EQ(0, audio_device_->Init()); | 265 EXPECT_EQ(0, audio_device_->Init()); |
| 266 EXPECT_TRUE(audio_device_->Initialized()); | 266 EXPECT_TRUE(audio_device_->Initialized()); |
| 267 } | 267 } |
| 268 | 268 |
| 269 void TearDown() { | 269 void TearDown() override { EXPECT_EQ(0, audio_device_->Terminate()); } |
| 270 EXPECT_EQ(0, audio_device_->Terminate()); | |
| 271 } | |
| 272 | 270 |
| 273 void CheckVolume(uint32_t expected, uint32_t actual) { | 271 void CheckVolume(uint32_t expected, uint32_t actual) { |
| 274 // Mac and Windows have lower resolution on the volume settings. | 272 // Mac and Windows have lower resolution on the volume settings. |
| 275 #if defined(WEBRTC_MAC) || defined(_WIN32) | 273 #if defined(WEBRTC_MAC) || defined(_WIN32) |
| 276 int diff = abs(static_cast<int>(expected - actual)); | 274 int diff = abs(static_cast<int>(expected - actual)); |
| 277 EXPECT_LE(diff, 5); | 275 EXPECT_LE(diff, 5); |
| 278 #else | 276 #else |
| 279 EXPECT_TRUE((actual == expected) || (actual == expected-1)); | 277 EXPECT_TRUE((actual == expected) || (actual == expected-1)); |
| 280 #endif | 278 #endif |
| 281 } | 279 } |
| (...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1798 // TODO(kjellander): Fix so these tests pass on Mac. | 1796 // TODO(kjellander): Fix so these tests pass on Mac. |
| 1799 #if !defined(WEBRTC_MAC) | 1797 #if !defined(WEBRTC_MAC) |
| 1800 EXPECT_EQ(0, audio_device_->InitPlayout()); | 1798 EXPECT_EQ(0, audio_device_->InitPlayout()); |
| 1801 EXPECT_EQ(0, audio_device_->StartPlayout()); | 1799 EXPECT_EQ(0, audio_device_->StartPlayout()); |
| 1802 #endif | 1800 #endif |
| 1803 | 1801 |
| 1804 EXPECT_EQ(-1, audio_device_->GetLoudspeakerStatus(&loudspeakerOn)); | 1802 EXPECT_EQ(-1, audio_device_->GetLoudspeakerStatus(&loudspeakerOn)); |
| 1805 #endif | 1803 #endif |
| 1806 EXPECT_EQ(0, audio_device_->StopPlayout()); | 1804 EXPECT_EQ(0, audio_device_->StopPlayout()); |
| 1807 } | 1805 } |
| OLD | NEW |