From 82adb053319b9eb647918135271aca6f97b89b28 Mon Sep 17 00:00:00 2001 From: jules Date: Sun, 2 Jun 2013 11:50:02 +0100 Subject: [PATCH] Minor tidying-up. --- .../audio_io/juce_AudioDeviceManager.h | 9 ++++++--- .../native/juce_win32_ASIO.cpp | 14 ++++++------- .../native/juce_win32_WASAPI.cpp | 20 ++++++++++--------- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h index 2eaba6a3d8..a671b3e3d6 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h +++ b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h @@ -166,9 +166,12 @@ public: This will attempt to open either a default audio device, or one that was 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 by createStateXml(), or nullptr if you want the manager to choose the best device to open. diff --git a/modules/juce_audio_devices/native/juce_win32_ASIO.cpp b/modules/juce_audio_devices/native/juce_win32_ASIO.cpp index 416a152f07..28f8484bf9 100644 --- a/modules/juce_audio_devices/native/juce_win32_ASIO.cpp +++ b/modules/juce_audio_devices/native/juce_win32_ASIO.cpp @@ -192,7 +192,7 @@ private: { 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; } } @@ -200,7 +200,7 @@ private: { 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; } } @@ -238,7 +238,7 @@ private: { 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; } } @@ -246,7 +246,7 @@ private: { 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; } } @@ -284,7 +284,7 @@ private: { 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; } } @@ -292,7 +292,7 @@ private: { 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; } } @@ -473,7 +473,7 @@ public: shouldUsePreferredSize = false; } - int sampleRate = roundDoubleToInt (sr); + int sampleRate = roundToInt (sr); currentSampleRate = sampleRate; currentBlockSizeSamples = bufferSizeSamples; currentChansOut.clear(); diff --git a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp index 48a1e4b270..4cb0a42c1b 100644 --- a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp +++ b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp @@ -326,7 +326,7 @@ EDataFlow getDataFlow (const ComSmartPtr& device) 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 @@ -553,12 +553,12 @@ private: 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; switch (numChannels) @@ -573,8 +573,10 @@ private: 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); if (hr == S_FALSE && format.Format.nSamplesPerSec == nearestFormat->Format.nSamplesPerSec)