mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-02 03:20:06 +00:00
WASAPI: Allow querying default layouts
This commit is contained in:
parent
42100c9341
commit
1f90ecf6e3
2 changed files with 36 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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…
Add table
Add a link
Reference in a new issue