How to Set DVR Capture Buffers on More Than One Physical Disk (C++)

The following method for C++ shows how to get the DVR Sink object from the ltmmPlayControl object, using it to set DVR buffer folder settings on physical disks C: and D:.

void SetDVRCaptureBufferSettings(IltmmPlay *pPlay)
{
   IUnknown *punk = NULL;
   HRESULT hr = pPlay->GetSubObject(ltmmPlay_Object_SourceFilter, &punk);   
   if(SUCCEEDED(hr) && NULL != punk)
   {
      ILMDVRSink *pDvrSink;
      hr = punk->QueryInterface(IID_ILMDVRSink, (LPVOID*)&pDvrSink);
      punk->Release();      
      if (SUCCEEDED(hr))
      {
          // Alloc BSTRs for both C and D drive paths and base filename
         BSTR bstrDVRPath1 = ::SysAllocString(TEXT("C:\\Temp\\DVR"));
         BSTR bstrDVRPath2 = ::SysAllocString(TEXT("D:\\Temp\\DVR"));
         BSTR bstrBaseName = ::SysAllocString(TEXT("Capture.LBL"));
          
         // Tell sink we are starting to change settings 
         pDvrSink->StartChangingAttributes();
         
         // Set TWO folders 
         pDvrSink->put_FolderCount(2);
         pDvrSink->put_BaseName(bstrBaseName);
         pDvrSink->put_FolderName(0, bstrDVRPath1);
         pDvrSink->SetBufferSize(0, 2, 16 * 1024000);
         pDvrSink->put_FolderName(0, bstrDVRPath2);
         pDvrSink->SetBufferSize(1, 4, 8 * 1024000);

         // Tell sink to apply the changes 
         pDvrSink->StopChangingAttributes(VARIANT_FALSE);

         // Release interface and free strings 
         pDvrSink->Release();
         
         SysFreeString(bstrBaseName);
         SysFreeString(bstrDVRPath2);
         SysFreeString(bstrDVRPath1);
      }
   }
}