DirectShow:The getCurrentbuffer didn't retreive a buffer?

May 5, 2008 at 2:58pm
Hi,

I am using the ISampleGrabber and the function GetCurrentBuffer didn't retreive nothing and i don't know where is the problem my code didn't cause no errors but when i insert a breakpoint in the begining and by following all the instructions of my function i see that the GetCurrentBuffer didn't return no thing.

this is my part of code and as i told you no errors appears so don't ask me this variable or this thing is not declared because all seems good running.Just if someone can told me whats wrong or missing to retreive my buffer:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

long CCaptureVideo::CaptureImage()
{

  int x,y,w,h;

  pGrabber = NULL;
  HRESULT hr;
 hr = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER,IID_IBaseFilter, (void**)&pGrabberF);
 if (FAILED(hr))
 {
    AfxMessageBox("error");

 }
 hr = m_pGraph->AddFilter(pGrabberF, L"Sample Grabber");
 if (FAILED(hr))
 {
      AfxMessageBox("error");
 }
 
 pGrabberF->QueryInterface(IID_ISampleGrabber, (void**)&pGrabber);

 

getTailleImage(&w, &h); 
   x=w;
  y=h;
  long size = x * y * 3;
       
  hr = pGrabber->GetCurrentBuffer(&size, NULL);
  if (FAILED(hr))
  {

    return 0;
   AfxMessageBox("can't retreive buffer size");
  }
        char *pBuffer = new char[size];

        hr = pGrabber->GetCurrentBuffer(&size, (long*)pBuffer);
  if (FAILED(hr))
  {
   return 0;
   AfxMessageBox("can't retreive buffer");
  }
  else {
               AfxMessageBox("buffer retreived");
                return (long)pBuffer;
   }


}


thanks a lot for every one can help me.
Last edited on May 5, 2008 at 2:59pm
Topic archived. No new replies allowed.