mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
WASAPI: Avoid OOB write when the device activates fewer channels than requested
This commit is contained in:
parent
a4dfd8d6c6
commit
3ee03cadd9
1 changed files with 6 additions and 4 deletions
|
|
@ -756,7 +756,7 @@ private:
|
|||
: AUDCLNT_SHAREMODE_SHARED,
|
||||
(WAVEFORMATEX*) &format,
|
||||
isExclusiveMode (mode) ? nullptr
|
||||
: &nearestFormat);
|
||||
: &nearestFormat);
|
||||
logFailure (hr);
|
||||
|
||||
auto supportsSRC = supportsSampleRateConversion (mode);
|
||||
|
|
@ -888,7 +888,6 @@ private:
|
|||
|
||||
bool tryInitialisingWithBufferSize (int bufferSizeSamples)
|
||||
{
|
||||
|
||||
if (auto format = findSupportedFormat (client, numChannels, sampleRate))
|
||||
{
|
||||
auto isInitialised = isLowLatencyMode (deviceMode) ? initialiseLowLatencyClient (bufferSizeSamples, *format)
|
||||
|
|
@ -1164,11 +1163,14 @@ public:
|
|||
if (isExclusiveMode (deviceMode) && WaitForSingleObject (clientEvent, 1000) == WAIT_TIMEOUT)
|
||||
break;
|
||||
|
||||
const auto numChannelsToCopy = jmin (actualNumChannels, numSrcBuffers);
|
||||
jassert (numChannelsToCopy <= channelMaps.size());
|
||||
|
||||
uint8* outputData = nullptr;
|
||||
if (check (renderClient->GetBuffer ((UINT32) samplesToDo, &outputData)))
|
||||
{
|
||||
for (int i = 0; i < numSrcBuffers; ++i)
|
||||
converter->convertSamples (outputData, channelMaps.getUnchecked(i), srcBuffers[i] + offset, 0, samplesToDo);
|
||||
for (int i = 0; i < numChannelsToCopy; ++i)
|
||||
converter->convertSamples (outputData, channelMaps.getUnchecked (i), srcBuffers[i] + offset, 0, samplesToDo);
|
||||
|
||||
renderClient->ReleaseBuffer ((UINT32) samplesToDo, 0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue