Browse Source

WASAPI: Allow querying default layouts

v7.0.9
reuk 1 year ago
parent
commit
1f90ecf6e3
2 changed files with 36 additions and 1 deletions
  1. +15
    -0
      modules/juce_audio_devices/audio_io/juce_AudioIODevice.h
  2. +21
    -1
      modules/juce_audio_devices/native/juce_WASAPI_windows.cpp

+ 15
- 0
modules/juce_audio_devices/audio_io/juce_AudioIODevice.h View File

@@ -174,6 +174,21 @@ public:
*/
virtual StringArray getInputChannelNames() = 0;
//==============================================================================
/** For devices that support a default layout, returns the channels that are enabled in the
default layout.
Returns nullopt if the device doesn't supply a default layout.
*/
virtual std::optional<BigInteger> getDefaultOutputChannels() const { return {}; }
/** For devices that support a default layout, returns the channels that are enabled in the
default layout.
Returns nullopt if the device doesn't supply a default layout.
*/
virtual std::optional<BigInteger> getDefaultInputChannels() const { return {}; }
//==============================================================================
/** Returns the set of sample-rates this device supports.
@see getCurrentSampleRate


+ 21
- 1
modules/juce_audio_devices/native/juce_WASAPI_windows.cpp View File

@@ -527,6 +527,16 @@ public:
isActive = true;
}
std::optional<BigInteger> getDefaultLayout() const
{
if (countNumberOfBits ((uint64) defaultFormatChannelMask) == defaultNumChannels)
return BigInteger ((int64) defaultFormatChannelMask);
BigInteger integer;
integer.setRange (0, defaultNumChannels, true);
return integer;
}
//==============================================================================
ComSmartPtr<IMMDevice> device;
ComSmartPtr<IAudioClient> client;
@@ -635,7 +645,7 @@ private:
if (! check (client->GetMixFormat (&mixFormat)))
return {};
WAVEFORMATEXTENSIBLE format;
WAVEFORMATEXTENSIBLE format{};
copyWavFormat (format, mixFormat);
CoTaskMemFree (mixFormat);
@@ -1338,6 +1348,16 @@ public:
String getLastError() override { return lastError; }
int getXRunCount() const noexcept override { return inputDevice != nullptr ? inputDevice->xruns : -1; }
std::optional<BigInteger> getDefaultOutputChannels() const override
{
return outputDevice != nullptr ? outputDevice->getDefaultLayout() : std::nullopt;
}
std::optional<BigInteger> getDefaultInputChannels() const override
{
return inputDevice != nullptr ? inputDevice->getDefaultLayout() : std::nullopt;
}
String open (const BigInteger& inputChannels, const BigInteger& outputChannels,
double sampleRate, int bufferSizeSamples) override
{


Loading…
Cancel
Save