# Define e_pointer _ hresult_typedef _ (0x80004003l)
# Define e_invalidarg _ hresult_typedef _ (0x80000003l)
# Define e_notimpl _ hresult_typedef _ (0x80004001l)
2147746321
# Define co_e_failedtogetwindir _ hresult_typedef _ (0x80040211l)
# Define vfw_e_sizenotset (hresult) 0x80040212l)
# Define s_false (hresult) 0x00000001l)
In line 4841
[Hresult
Cbaseallocator: alloc (void)
{
/* Error if he hasn' t set the size yet */
If (m_lcount <= 0 | m_lsize <= 0 | m_lalignment <= 0 ){
Return vfw_e_sizenotset;
}]
Cbaseoutputpin: how can this error occur when getdeliverybuffer is used? co_e_failedtogetwindir
//
// Messageid: co_e_failedtogetwindir
//
// Messagetext:
//
// Unable to obtain the Windows directory
//
What caused this?
# Define vfw_e_not_committed (hresult) 0x80040211l)
At first, I was confused by the co_e_failedtogetwindir error, but then I read the source code involved in the getdeliverybuffer function and finally found out
In fact, this error is caused
If (! M_bcommitted ){
Return vfw_e_not_committed;
Note: # define co_e_failedtogetwindir _ hresult_typedef _ (0x80040211l)
It is the same as the preceding error value and does not return co_e_failedtogetwindir in the code.
Later, I tracked why m_bcommitted was not set to 1 (true)
If your output pin is based on cbaseoutpin
To fill the sample, follow these steps:
1. Call the cbaseallocator: setproperties method to specify the memory requirements, including the memory quantity and size.
2 call cbaseallocator: The commit class allocates memory. In this function, call alloc () to set m_bcommitted to 1.
3. Use cbaseallocator: getbuffer to obtain media samples. This method is blocked until another sample
Available,
4. After using the sample, remember to call the iunknown: release on the sample to reduce the reference count of the sample.
When the reference count of a sample is 0, the sample is not deleted, but returned to the Allocator memory pool.
For other customers.
5. After allocator is used, call cbaseallocator: decommit to release the memory.
Later I found that because cbaseallocator: commit calls cbaseallocator: alloc ()
Check
Cbaseallocator: alloc (void)
{
/* Error if he hasn' t set the size yet */
If (m_lcount <= 0 | m_lsize <= 0 | m_lalignment <= 0 ){
Return vfw_e_sizenotset;
These values are
Cbaseallocator: setproperties () assigned
As follows:
Pactual-> cbbuffer = m_lsize = prequest-> cbbuffer;
Pactual-> cbuffers = m_lcount = prequest-> cbuffers;
Pactual-> cbalign = m_lalignment = prequest-> cbalign;
Pactual-> cbprefix = m_lprefix = prequest-> cbprefix;
While I
Crecvoutputpin: decidebuffersize internally calls setproperties () prequest-> cbbuffer
If the value is 0, the above error is caused.
But I also figured out the process of filling the sample.
Crecvoutputpin: decidebuffersize is automatically called During pin connection.
Hresult cbaseallocator: getbuffer (imediasample ** ppbuffer,
Reference_time * pstarttime,
Reference_time * pendtime,
DWORD dwflags
)
{
Unreferenced_parameter (pstarttime );
Unreferenced_parameter (pendtime );
Unreferenced_parameter (dwflags );
Cmediasample * psample;
* Ppbuffer = NULL;
For (;;)
{
{// Scope for Lock
Cautolock cobjectlock (this );
/* Check we are committed */
If (! M_bcommitted ){
Return vfw_e_not_committed;
}
Psample = (cmediasample *) m_lfree.removehead ();
If (psample = NULL ){
Setwaiting ();
}
}
/* If we didn't get a sample then wait for the list to signal */
If (psample ){
Break;
}
If (dwflags & am_gbf_nowait ){
Return vfw_e_timeout;
}
Assert (m_hsem! = NULL );
Waitforsingleobject (m_hsem, infinite );
}
/* Addref the buffer up to one. On Release
Back to zero instead of being deleted, it will requeue itself
Calling the releasebuffer member function. Note the owner of
Media sample must always be derived from cbaseallocator */
Assert (psample-> m_cref = 0 );
Psample-> m_cref = 1;
* Ppbuffer = psample;
Return noerror;
}
/// When the filter is out of the Stop State
Stdmethodimp
Cnetworkreceiverfilter: Stop (
)
{
Lockfilter ();
// Synchronous call to stop the timer Er (leaves the multicast group
// And terminates the thread)
M_pnetreceiver-> stop ();
// If we have an output pin (We shoshould) Stop it
If (m_poutput ){
// Overload cbasepin: inactive () call imemallocator: decommit method decommit the Memory Allocator
M_poutput-> inactive ();
}
M_state = state_stopped;
Unlockfilter ();
Return s_ OK;
}
// The filter is in the pause status.
Stdmethodimp
Cnetworkreceiverfilter: Pause (
)
{
Hresult hr;
Lockfilter ();
If (m_ulip = undefined |
M_ulnic = undefined)
{
HR = e_fail;
}
Else if (m_state = state_stopped)
{
//--------------------------------------------------------------------
// Stopped-> pause transition; get the filter up and running
// Activate the aggreger; joins the multicast group and starts
// Thread
// Reload the cbasepin: active method. Call imemallocator: commit method on the allocator to allocate memory for buffers.
HR = m_pnetreceiver-> activate (m_ulip, m_usport, m_ulnic );//
If (succeeded (HR ))
{
M_state = state_paused;
If (m_poutput &&
M_poutput-> isconnected ())
{
M_poutput-> active ();
}
}
}
Else
{
//--------------------------------------------------------------------
// Run-> pause transition; do nothing but set the state
M_state = state_paused;
HR = s_ OK;
}
Unlockfilter ();
Return hr;
}
Initallocator is automatically called.