Browse Source

Minor tidying-up.

tags/2021-05-28
jules 12 years ago
parent
commit
82adb05331
3 changed files with 24 additions and 19 deletions
  1. +6
    -3
      modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h
  2. +7
    -7
      modules/juce_audio_devices/native/juce_win32_ASIO.cpp
  3. +11
    -9
      modules/juce_audio_devices/native/juce_win32_WASAPI.cpp

+ 6
- 3
modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h View File

@@ -166,9 +166,12 @@ public:
This will attempt to open either a default audio device, or one that was This will attempt to open either a default audio device, or one that was
previously saved as XML. previously saved as XML.
@param numInputChannelsNeeded a minimum number of input channels needed
by your app.
@param numOutputChannelsNeeded a minimum number of output channels to open
@param numInputChannelsNeeded the maximum number of input channels your app would like to
use (the actual number of channels opened may be less than
the number requested)
@param numOutputChannelsNeeded the maximum number of output channels your app would like to
use (the actual number of channels opened may be less than
the number requested)
@param savedState either a previously-saved state that was produced @param savedState either a previously-saved state that was produced
by createStateXml(), or nullptr if you want the manager by createStateXml(), or nullptr if you want the manager
to choose the best device to open. to choose the best device to open.


+ 7
- 7
modules/juce_audio_devices/native/juce_win32_ASIO.cpp View File

@@ -192,7 +192,7 @@ private:
{ {
while (--numSamples >= 0) while (--numSamples >= 0)
{ {
*(uint16*) dest = ByteOrder::swapIfBigEndian ((uint16) (short) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * *src++)));
*(uint16*) dest = ByteOrder::swapIfBigEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * *src++)));
dest += dstStrideBytes; dest += dstStrideBytes;
} }
} }
@@ -200,7 +200,7 @@ private:
{ {
while (--numSamples >= 0) while (--numSamples >= 0)
{ {
*(uint16*) dest = ByteOrder::swapIfLittleEndian ((uint16) (short) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * *src++)));
*(uint16*) dest = ByteOrder::swapIfLittleEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * *src++)));
dest += dstStrideBytes; dest += dstStrideBytes;
} }
} }
@@ -238,7 +238,7 @@ private:
{ {
while (--numSamples >= 0) while (--numSamples >= 0)
{ {
ByteOrder::littleEndian24BitToChars ((uint32) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * *src++)), dest);
ByteOrder::littleEndian24BitToChars ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * *src++)), dest);
dest += dstStrideBytes; dest += dstStrideBytes;
} }
} }
@@ -246,7 +246,7 @@ private:
{ {
while (--numSamples >= 0) while (--numSamples >= 0)
{ {
ByteOrder::bigEndian24BitToChars ((uint32) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * *src++)), dest);
ByteOrder::bigEndian24BitToChars ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * *src++)), dest);
dest += dstStrideBytes; dest += dstStrideBytes;
} }
} }
@@ -284,7 +284,7 @@ private:
{ {
while (--numSamples >= 0) while (--numSamples >= 0)
{ {
*(uint32*) dest = ByteOrder::swapIfBigEndian ((uint32) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * *src++)));
*(uint32*) dest = ByteOrder::swapIfBigEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * *src++)));
dest += dstStrideBytes; dest += dstStrideBytes;
} }
} }
@@ -292,7 +292,7 @@ private:
{ {
while (--numSamples >= 0) while (--numSamples >= 0)
{ {
*(uint32*) dest = ByteOrder::swapIfLittleEndian ((uint32) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * *src++)));
*(uint32*) dest = ByteOrder::swapIfLittleEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * *src++)));
dest += dstStrideBytes; dest += dstStrideBytes;
} }
} }
@@ -473,7 +473,7 @@ public:
shouldUsePreferredSize = false; shouldUsePreferredSize = false;
} }
int sampleRate = roundDoubleToInt (sr);
int sampleRate = roundToInt (sr);
currentSampleRate = sampleRate; currentSampleRate = sampleRate;
currentBlockSizeSamples = bufferSizeSamples; currentBlockSizeSamples = bufferSizeSamples;
currentChansOut.clear(); currentChansOut.clear();


+ 11
- 9
modules/juce_audio_devices/native/juce_win32_WASAPI.cpp View File

@@ -326,7 +326,7 @@ EDataFlow getDataFlow (const ComSmartPtr<IMMDevice>& device)
int refTimeToSamples (const REFERENCE_TIME& t, const double sampleRate) noexcept int refTimeToSamples (const REFERENCE_TIME& t, const double sampleRate) noexcept
{ {
return roundDoubleToInt (sampleRate * ((double) t) * 0.0000001);
return roundToInt (sampleRate * ((double) t) * 0.0000001);
} }
void copyWavFormat (WAVEFORMATEXTENSIBLE& dest, const WAVEFORMATEX* const src) noexcept void copyWavFormat (WAVEFORMATEXTENSIBLE& dest, const WAVEFORMATEX* const src) noexcept
@@ -553,12 +553,12 @@ private:
format.Format.cbSize = sizeof (WAVEFORMATEXTENSIBLE) - sizeof (WAVEFORMATEX); format.Format.cbSize = sizeof (WAVEFORMATEXTENSIBLE) - sizeof (WAVEFORMATEX);
} }
format.Format.nSamplesPerSec = (DWORD) roundDoubleToInt (sampleRate);
format.Format.nChannels = (WORD) numChannels;
format.Format.wBitsPerSample = (WORD) (8 * bytesPerSampleToTry);
format.Format.nAvgBytesPerSec = (DWORD) (format.Format.nSamplesPerSec * numChannels * bytesPerSampleToTry);
format.Format.nBlockAlign = (WORD) (numChannels * bytesPerSampleToTry);
format.SubFormat = useFloat ? KSDATAFORMAT_SUBTYPE_IEEE_FLOAT : KSDATAFORMAT_SUBTYPE_PCM;
format.Format.nSamplesPerSec = (DWORD) sampleRate;
format.Format.nChannels = (WORD) numChannels;
format.Format.wBitsPerSample = (WORD) (8 * bytesPerSampleToTry);
format.Format.nAvgBytesPerSec = (DWORD) (format.Format.nSamplesPerSec * numChannels * bytesPerSampleToTry);
format.Format.nBlockAlign = (WORD) (numChannels * bytesPerSampleToTry);
format.SubFormat = useFloat ? KSDATAFORMAT_SUBTYPE_IEEE_FLOAT : KSDATAFORMAT_SUBTYPE_PCM;
format.Samples.wValidBitsPerSample = format.Format.wBitsPerSample; format.Samples.wValidBitsPerSample = format.Format.wBitsPerSample;
switch (numChannels) switch (numChannels)
@@ -573,8 +573,10 @@ private:
WAVEFORMATEXTENSIBLE* nearestFormat = nullptr; WAVEFORMATEXTENSIBLE* nearestFormat = nullptr;
HRESULT hr = client->IsFormatSupported (useExclusiveMode ? AUDCLNT_SHAREMODE_EXCLUSIVE : AUDCLNT_SHAREMODE_SHARED,
(WAVEFORMATEX*) &format, useExclusiveMode ? nullptr : (WAVEFORMATEX**) &nearestFormat);
HRESULT hr = client->IsFormatSupported (useExclusiveMode ? AUDCLNT_SHAREMODE_EXCLUSIVE
: AUDCLNT_SHAREMODE_SHARED,
(WAVEFORMATEX*) &format,
useExclusiveMode ? nullptr : (WAVEFORMATEX**) &nearestFormat);
logFailure (hr); logFailure (hr);
if (hr == S_FALSE && format.Format.nSamplesPerSec == nearestFormat->Format.nSamplesPerSec) if (hr == S_FALSE && format.Format.nSamplesPerSec == nearestFormat->Format.nSamplesPerSec)


Loading…
Cancel
Save