Esempio n. 1
0
STDMETHODIMP MFStream::BeginRead(BYTE *pb, ULONG cb, IMFAsyncCallback *pCallback,
                       IUnknown *punkState)
{
    if (!pCallback || !pb)
        return E_INVALIDARG;

    Q_ASSERT(m_currentReadResult == NULL);

    AsyncReadState *state = new (std::nothrow) AsyncReadState(pb, cb);
    if (state == NULL)
        return E_OUTOFMEMORY;

    HRESULT hr = MFCreateAsyncResult(state, pCallback, punkState, &m_currentReadResult);
    state->Release();
    if (FAILED(hr))
        return hr;

    QCoreApplication::postEvent(this, new QEvent(QEvent::User));
    return hr;
}
/** Begins an asyncronous read */
STDMETHODIMP FImfByteStream::BeginRead( BYTE* pb, ULONG cb, IMFAsyncCallback* pCallback, IUnknown* punkState )
{
	HRESULT HResult = S_OK;

	if( !pCallback || !pb )
		return E_INVALIDARG;

	IMFAsyncResult* Result = NULL;
	AsyncReadState* State = new( std::nothrow ) AsyncReadState( pb, cb );
	if( State == NULL )
		return E_OUTOFMEMORY;

	HResult = MFCreateAsyncResult( State, pCallback, punkState, &Result );
	State->Release( );

	if( SUCCEEDED( HResult ) )
	{
		IsCurrentlyReading = true;
		HResult = MFPutWorkItem( MFASYNC_CALLBACK_QUEUE_STANDARD, this, Result );
		Result->Release( );
	}

	return HResult;
}