DShowPlugin: Only dynamically change size in Preprocess
newCX and newCY were being changed when a sample was received. However, the sample associated with that size change will not be processed until it's used in Preprocess, so it could often change the texture size before the sample was even used. This could cause crashes under certain circumstances. A simple fix to this is to only change newCX/newCY when the sample is actually used.master
parent
d0c8f56b8a
commit
65f5bd10cf
|
@ -822,6 +822,9 @@ bool DeviceSource::LoadFilters()
|
|||
ElgatoCheckBuffering(deviceFilter, bUseBuffering, bufferTime);
|
||||
#endif
|
||||
|
||||
lastSampleCX = renderCX;
|
||||
lastSampleCY = renderCY;
|
||||
|
||||
//------------------------------------------------
|
||||
// connect all pins and set up the whole capture thing
|
||||
|
||||
|
@ -1468,8 +1471,8 @@ void DeviceSource::ReceiveMediaSample(IMediaSample *sample, bool bAudio)
|
|||
if (sample->GetMediaType(&mt) == S_OK)
|
||||
{
|
||||
BITMAPINFOHEADER *bih = GetVideoBMIHeader(mt);
|
||||
newCX = bih->biWidth;
|
||||
newCY = bih->biHeight;
|
||||
lastSampleCX = bih->biWidth;
|
||||
lastSampleCY = bih->biHeight;
|
||||
DeleteMediaType(mt);
|
||||
}
|
||||
|
||||
|
@ -1478,8 +1481,8 @@ void DeviceSource::ReceiveMediaSample(IMediaSample *sample, bool bAudio)
|
|||
data->bAudio = bAudio;
|
||||
data->dataLength = sample->GetActualDataLength();
|
||||
data->lpData = (LPBYTE)Allocate(data->dataLength);//pointer; //
|
||||
data->cx = newCX;
|
||||
data->cy = newCY;
|
||||
data->cx = lastSampleCX;
|
||||
data->cy = lastSampleCY;
|
||||
/*data->sample = sample;
|
||||
sample->AddRef();*/
|
||||
|
||||
|
@ -1567,6 +1570,8 @@ void DeviceSource::Preprocess()
|
|||
|
||||
if(lastSample)
|
||||
{
|
||||
newCX = lastSample->cx;
|
||||
newCY = lastSample->cy;
|
||||
/*REFERENCE_TIME refTimeStart, refTimeFinish;
|
||||
lastSample->GetTime(&refTimeStart, &refTimeFinish);
|
||||
|
||||
|
|
|
@ -137,6 +137,7 @@ class DeviceSource : public ImageSource
|
|||
UINT64 frameInterval;
|
||||
UINT renderCX, renderCY;
|
||||
UINT newCX, newCY;
|
||||
UINT lastSampleCX, lastSampleCY;
|
||||
UINT imageCX, imageCY;
|
||||
UINT linePitch, lineShift, lineSize;
|
||||
BOOL bUseCustomResolution;
|
||||
|
|
Loading…
Reference in New Issue