Note that there are some explanatory texts on larger screens.

plurals
  1. POSample Grabber Sink release() issue
    primarykey
    data
    text
    <p>I use Sample Grabber Sink in my Media session using most of code from msdn sample.</p> <p>In OnProcessSample method I memcpy data to media buffer, attach it to MFSample and put this one into main process pointer. Problem is I either get memory leaking or crashes in ntdll.dll</p> <blockquote> <p>ntdll.dll!@RtlpLowFragHeapFree@8() Unknown</p> </blockquote> <p>SampleGrabberSink:</p> <pre><code>OnProcessSample(...) { MFCreateMemoryBuffer(dwSampleSize,&amp;tmpBuff); tmpBuff-&gt;Lock(&amp;data,NULL,NULL); memcpy(data,pSampleBuffer,dwSampleSize); tmpBuff-&gt;Unlock(); MFCreateSample(&amp;tmpSample); tmpSample-&gt;AddBuffer(tmpBuff); while(!(*Free) &amp;&amp; (*pSample)!=NULL) { Sleep(1); } (*Free)=false; (*pSample)=tmpSample; (*Free)=true; SafeRelease(&amp;tmpBuff); } </code></pre> <p>in main thread</p> <pre><code>ReadSample() { if(pSample==NULL) return; while(!Free) Sleep(1); Free=false; //process sample into dx surface// SafeRelease(&amp;pSample); Free=true; } </code></pre> <p>//hr checks omitted// With this code i get that ntdll.dll error after playing few vids. I also tried to push samples in qeue so OnProcess doesn't have to wait but then some memory havent free after video ended. (even now it practicaly doesn't wait, Session rate is 1 and main process can read more than 60fps)</p> <p><strong>EDIT:</strong> It was thread synchronization problem. Solved by using <a href="http://msdn.microsoft.com/en-us/library/ms682530%28VS.85%29.aspx%3a" rel="nofollow">critical section</a> thanks to Roman R.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload