Build core audio for older windows versions

Some of the constants and structure definitions used are only available with
specific and recent versions of the windows SDK. This change allows this
to build with a toolchain targeting WINVER 0x0601 (Windows 7)

Bug: None
Change-Id: I3339f7c44c375fb7d583b78aa137f748c9776a07
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/147440
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Paul Roberts <pacaro@google.com>
Cr-Commit-Position: refs/heads/master@{#28730}
This commit is contained in:
Paul Roberts 2019-07-29 17:21:54 -07:00 committed by Commit Bot
parent 076bdba8cf
commit fd643a4782

View File

@ -131,6 +131,32 @@ std::string ChannelMaskToString(DWORD channel_mask) {
return ss;
}
#if !defined(KSAUDIO_SPEAKER_1POINT1)
// These values are only defined in ksmedia.h after a certain version, to build
// cleanly for older windows versions this just defines the ones that are
// missing.
#define KSAUDIO_SPEAKER_1POINT1 (SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY)
#define KSAUDIO_SPEAKER_2POINT1 \
(SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY)
#define KSAUDIO_SPEAKER_3POINT0 \
(SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER)
#define KSAUDIO_SPEAKER_3POINT1 \
(SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | \
SPEAKER_LOW_FREQUENCY)
#define KSAUDIO_SPEAKER_5POINT0 \
(SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | \
SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT)
#define KSAUDIO_SPEAKER_7POINT0 \
(SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | \
SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | SPEAKER_SIDE_LEFT | \
SPEAKER_SIDE_RIGHT)
#endif
#if !defined(AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY)
#define AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY 0x08000000
#define AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM 0x80000000
#endif
// Converts from channel mask to DirectSound speaker configuration.
// The values below are copied from ksmedia.h.
// Example: KSAUDIO_SPEAKER_STEREO = (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT).
@ -809,6 +835,9 @@ HRESULT SetClientProperties(IAudioClient2* client) {
}
RTC_DLOG(INFO) << "supports_offload: " << supports_offload;
props.bIsOffload = false;
#if (NTDDI_VERSION < NTDDI_WINBLUE)
RTC_DLOG(INFO) << "options: Not supported in this build";
#else
// TODO(henrika): pros and cons compared with AUDCLNT_STREAMOPTIONS_NONE?
props.Options |= AUDCLNT_STREAMOPTIONS_NONE;
// Requires System.Devices.AudioDevice.RawProcessingSupported.
@ -825,6 +854,7 @@ HRESULT SetClientProperties(IAudioClient2* client) {
// This interface is mainly meant for pro audio scenarios.
// props.Options |= AUDCLNT_STREAMOPTIONS_MATCH_FORMAT;
RTC_DLOG(INFO) << "options: 0x" << rtc::ToHex(props.Options);
#endif
error = client->SetClientProperties(&props);
if (FAILED(error.Error())) {
RTC_LOG(LS_ERROR) << "IAudioClient2::SetClientProperties failed: "