Adds stream-switch support in new Windows ADM.

Second round of the new Windows ADM is now ready for review. Main
changes are:

Supports internal (automatic) restart of audio streams when an active
audio stream disconnects (happens when a device is removed).

Adds support for IAudioClient3 and IAudioClient2 for platforms which
supports it (>Win8 and >Win10).

Modifies the threading model to support restart "from the inside" on
the native audio thread.

Adds two new test methods for the ADM to emulate restart events or
stream-switch events.

Adds two new test methods to support rate conversion to ensure that
audio can be tested in loopback even if devices runs at different
sample rates.

Added initial components for low-latency support. Verified that it works
but disabled it with a flag for now.

Bug: webrtc:9265
Change-Id: Ia8e577daabea6b433f2c2eabab4e46ce8added6a
Reviewed-on: https://webrtc-review.googlesource.com/86020
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24578}
This commit is contained in:
henrika
2018-09-05 14:34:40 +02:00
committed by Commit Bot
parent e10f3b7403
commit 5b6afc0ce6
20 changed files with 1805 additions and 264 deletions

View File

@ -17,6 +17,8 @@
namespace webrtc {
class AudioDeviceModuleForTest;
class AudioDeviceModule : public rtc::RefCountInterface {
public:
// Deprecated.
@ -46,9 +48,13 @@ class AudioDeviceModule : public rtc::RefCountInterface {
enum ChannelType { kChannelLeft = 0, kChannelRight = 1, kChannelBoth = 2 };
public:
// Creates an ADM.
// Creates a default ADM for usage in production code.
static rtc::scoped_refptr<AudioDeviceModule> Create(
const AudioLayer audio_layer);
// Creates an ADM with support for extra test methods. Don't use this factory
// in production code.
static rtc::scoped_refptr<AudioDeviceModuleForTest> CreateForTest(
const AudioLayer audio_layer);
// TODO(bugs.webrtc.org/7306): deprecated (to be removed).
static rtc::scoped_refptr<AudioDeviceModule> Create(
const int32_t id,
@ -158,6 +164,20 @@ class AudioDeviceModule : public rtc::RefCountInterface {
~AudioDeviceModule() override {}
};
// Extends the default ADM interface with some extra test methods.
// Intended for usage in tests only and requires a unique factory method.
class AudioDeviceModuleForTest : public AudioDeviceModule {
public:
// Triggers internal restart sequences of audio streaming. Can be used by
// tests to emulate events corresponding to e.g. removal of an active audio
// device or other actions which causes the stream to be disconnected.
virtual int RestartPlayoutInternally() = 0;
virtual int RestartRecordingInternally() = 0;
virtual int SetPlayoutSampleRate(uint32_t sample_rate) = 0;
virtual int SetRecordingSampleRate(uint32_t sample_rate) = 0;
};
} // namespace webrtc
#endif // MODULES_AUDIO_DEVICE_INCLUDE_AUDIO_DEVICE_H_