Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed 4186: Enabling AC3 encoding option in audio renderer causes mem…

…ory leaks

- ProcessAC3Frame was leaking memory when the temp buffer was not release
- NegotiateFormat was not releasing WAVEFORMATEXTENSIBLE
  • Loading branch information...
commit ded02e6641291fbc0add2ccbf63c09aaf76c2bfa 1 parent 28daf6b
@tourettes tourettes authored Scythe42 committed
View
BIN  DirectShowFilters/MPAudioRenderer/bin/Debug/AudioRenderer.pdb
Binary file not shown
View
BIN  DirectShowFilters/MPAudioRenderer/bin/Debug/mpaudiorenderer.ax
Binary file not shown
View
BIN  DirectShowFilters/MPAudioRenderer/bin/Release/mpaudiorenderer.ax
Binary file not shown
View
11 DirectShowFilters/MPAudioRenderer/source/AC3EncoderFilter.cpp
@@ -127,6 +127,9 @@ HRESULT CAC3EncoderFilter::NegotiateFormat(const WAVEFORMATEXTENSIBLE* pwfx, int
// Finally verify next sink accepts AC3 format
WAVEFORMATEXTENSIBLE* pAC3wfx = CreateAC3Format(pwfx->Format.nSamplesPerSec, 0);
+ if (!pAC3wfx)
+ return E_OUTOFMEMORY;
+
hr = m_pNextSink->NegotiateFormat(pAC3wfx, nApplyChangesDepth, pChOrder);
if (FAILED(hr))
@@ -153,7 +156,10 @@ HRESULT CAC3EncoderFilter::NegotiateFormat(const WAVEFORMATEXTENSIBLE* pwfx, int
OpenAC3Encoder(m_nBitRate, m_pInputFormat->Format.nChannels, m_pInputFormat->Format.nSamplesPerSec);
}
else
+ {
+ SAFE_DELETE_WAVEFORMATEX(pAC3wfx);
LogWaveFormat(pwfx, "AC3 - ");
+ }
*pChOrder = AC3_ORDER;
@@ -514,12 +520,17 @@ HRESULT CAC3EncoderFilter::ProcessAC3Frame(const BYTE* pData)
ASSERT(pOutData);
BYTE* buf = (BYTE*)malloc(m_nMaxCompressedAC3FrameSize); // temporary buffer
+ if (!buf)
+ return E_OUTOFMEMORY;
+
int AC3length = ac3_encoder_frame(m_pEncoder, (short*)pData, buf, m_nMaxCompressedAC3FrameSize);
nOffset += CreateAC3Bitstream(buf, AC3length, pOutData + nOffset);
m_pNextOutSample->SetActualDataLength(nOffset);
if (nOffset >= nSize)
OutputNextSample();
+ free(buf);
+
return S_OK;
}
View
2  DirectShowFilters/MPAudioRenderer/source/Settings.cpp
@@ -126,7 +126,7 @@ AudioRendererSettings::AudioRendererSettings() :
m_bExpandMonoToStereo(true)
{
LogRotate();
- Log("MP Audio Renderer - v1.0.4");
+ Log("MP Audio Renderer - v1.0.5");
LoadSettingsFromRegistry();
}
Please sign in to comment.
Something went wrong with that request. Please try again.