user744461
user744461

Reputation: 33

Tracking down the source of E_POINTER in IMFMediaSource::ReadSample

I'm getting an E_POINTER error from the ReadSample call, and as far as I can tell, none of the pointers are invalid. See snippet below (note, it's a C++/CLI app):

IMFSample* sample = NULL;
pin_ptr<IMFSample*> pinnedSample = &sample;

LONGLONG timeStamp;

HRESULT hr = mSourceReader->ReadSample(
    (DWORD)MF_SOURCE_READER_FIRST_VIDEO_STREAM,
    0,
    NULL,
    NULL,
    &timeStamp,
    pinnedSample
    );

I suspect the problem lies in the construction of the mSourceReader (an IMFSourceReader instance, created from an IMFMediaSource). But, alas, I've no idea how to backtrack and find the source, as all the COM calls in the chain of commands that created mSourceReader returned S_OK.

Much thanks for any tips.

Upvotes: 1

Views: 606

Answers (1)

Ben Voigt
Ben Voigt

Reputation: 283624

You don't need pin_ptr when taking the address of a local variable, since the garbage collector never moves local variables around anyway.

I'd guess that one of the other three parameters you're passing NULL to is non-optional, but I need to see what function you're calling to know for sure.

Did you create the IMFSourceReader in synchronous or asynchronous mode? The docs say:

This method can complete synchronously or asynchronously. If you provide a callback pointer when you create the source reader, the method is asynchronous. Otherwise, the method is synchronous.

I think this is your problem:

In synchronous mode:

  • The pdwStreamFlags and ppSample parameters cannot be NULL. Otherwise, the method returns E_POINTER.

You've passed NULL for pdwStreamFlags, which is not allowed.

Doc link: http://msdn.microsoft.com/en-us/library/dd374665.aspx

Upvotes: 1

Related Questions