Minor modifications for ADM2 on Windows.

Code is not used in production. Need this change for a local test.
Using TBR.

TBR: henrik.lundin
Bug: webrtc:9265
Change-Id: I9f0cb265a51507de59ef2d7fd151465133687525
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145330
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28557}
This commit is contained in:
henrika
2019-07-12 13:37:11 +02:00
committed by Commit Bot
parent a0e2609a08
commit d404946c14
2 changed files with 56 additions and 0 deletions

View File

@ -816,6 +816,30 @@ TEST_P(AudioDeviceTest, InitStopInitRecording) {
StopRecording();
}
// Verify that additional attempts to initialize or start recording while
// already being active works. Additional calls should just be ignored.
TEST_P(AudioDeviceTest, StartInitRecording) {
SKIP_TEST_IF_NOT(requirements_satisfied());
StartRecording();
// An additional attempt to initialize at this stage should be ignored.
EXPECT_EQ(0, audio_device()->InitRecording());
// Same for additional request to start recording while already active.
EXPECT_EQ(0, audio_device()->StartRecording());
StopRecording();
}
// Verify that additional attempts to initialize or start playou while
// already being active works. Additional calls should just be ignored.
TEST_P(AudioDeviceTest, StartInitPlayout) {
SKIP_TEST_IF_NOT(requirements_satisfied());
StartPlayout();
// An additional attempt to initialize at this stage should be ignored.
EXPECT_EQ(0, audio_device()->InitPlayout());
// Same for additional request to start playout while already active.
EXPECT_EQ(0, audio_device()->StartPlayout());
StopPlayout();
}
// Tests Init/Stop/Init recording while playout is active.
TEST_P(AudioDeviceTest, InitStopInitRecordingWhilePlaying) {
SKIP_TEST_IF_NOT(requirements_satisfied());

View File

@ -39,6 +39,34 @@ namespace {
} \
} while (0)
#define RETURN_IF_OUTPUT_IS_INITIALIZED(...) \
do { \
if (output_->PlayoutIsInitialized()) { \
return __VA_ARGS__; \
} \
} while (0)
#define RETURN_IF_INPUT_IS_INITIALIZED(...) \
do { \
if (input_->RecordingIsInitialized()) { \
return __VA_ARGS__; \
} \
} while (0)
#define RETURN_IF_OUTPUT_IS_ACTIVE(...) \
do { \
if (output_->Playing()) { \
return __VA_ARGS__; \
} \
} while (0)
#define RETURN_IF_INPUT_IS_ACTIVE(...) \
do { \
if (input_->Recording()) { \
return __VA_ARGS__; \
} \
} while (0)
// This class combines a generic instance of an AudioInput and a generic
// instance of an AudioOutput to create an AudioDeviceModule. This is mostly
// done by delegating to the audio input/output with some glue code. This class
@ -230,6 +258,7 @@ class WindowsAudioDeviceModule : public AudioDeviceModuleForTest {
RTC_LOG(INFO) << __FUNCTION__;
RTC_DCHECK_RUN_ON(&thread_checker_);
RETURN_IF_OUTPUT_RESTARTS(0);
RETURN_IF_OUTPUT_IS_INITIALIZED(0);
return output_->InitPlayout();
}
@ -251,6 +280,7 @@ class WindowsAudioDeviceModule : public AudioDeviceModuleForTest {
RTC_LOG(INFO) << __FUNCTION__;
RTC_DCHECK_RUN_ON(&thread_checker_);
RETURN_IF_INPUT_RESTARTS(0);
RETURN_IF_INPUT_IS_INITIALIZED(0);
return input_->InitRecording();
}
@ -265,6 +295,7 @@ class WindowsAudioDeviceModule : public AudioDeviceModuleForTest {
RTC_LOG(INFO) << __FUNCTION__;
RTC_DCHECK_RUN_ON(&thread_checker_);
RETURN_IF_OUTPUT_RESTARTS(0);
RETURN_IF_OUTPUT_IS_ACTIVE(0);
return output_->StartPlayout();
}
@ -286,6 +317,7 @@ class WindowsAudioDeviceModule : public AudioDeviceModuleForTest {
RTC_LOG(INFO) << __FUNCTION__;
RTC_DCHECK_RUN_ON(&thread_checker_);
RETURN_IF_INPUT_RESTARTS(0);
RETURN_IF_INPUT_IS_ACTIVE(0);
return input_->StartRecording();
}