Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
Output pins use the COutputQueueto send samples to another filter by using the local memory-based transport (that is, to input pins that support the IMemInputPininterface). COutputQueueuses IMemInputPin::ReceiveCanBlockto determine if the connected input pin has a blocking implementation of IMemInputPin::Receive. If so, all samples are queued in COutputQueueand a thread is created to pass samples from the queue to the connected input pin. If the input pin's IMemInputPin::Receivemethod does not block, samples are passed directly to IMemInputPin::Receive. COutputQueuecan also batch samples to reduce the number of calls to the downstream pin.
COutputQueueis useful when the filter has other work to do while samples that it has already completed are being processed downstream. This occurs, for example, in a filter that can read more data off disk while data is being processed, or when it has more than one output pin and does not want to starve an output pin because IMemInputPin::Receivehas no optional batching of samples.
To use this class, create one COutputQueueobject for every output pin for which it will be used. This can either be created when the pin is created and deleted when the pin is disconnected, or it can be created when the pin goes active and deleted when the pin goes inactive.
The samples sent to this object by calling its COutputQueue::Receiveor COutputQueue::ReceiveMultiplemember function should have references added by means of IUnknown::AddRef(as they usually are if they were obtained directly from an allocator). This object then calls IUnknown::Releaseon all samples it receives, whether they were processed successfully or not. Note that Releaseis not called for special (control) samples.
Some control information, such as end of stream, needs to be queued with the data and processed once all the data has been delivered. This information is queued in the form of special control packets. COutputQueueimplements a sticky HRESULTso it will not send any more data after it gets a return code that is not S_OK from the downstream ReceiveMultiplecall. (A sticky state setting is one that persists even after execution of operations that would usually reset the setting.) This sticky state is reset by the EndFlushand EOScalls. However, if the sticky HRESULTis not S_OK, EOSitself is not sent downstream; the HRESULTis just reset. Because of this, if this object is not deleted when the pin goes inactive, BeginFlushand EndFlushshould be called at that time to free the state.
In many ways this object acts as a proxy for the connected input pin, supporting a similar set of methods for stream control.
Protected Data Members
m_bBatchExact | TRUE if commands are batched; FALSE if commands are sent singly. |
m_bFlushed | Flag to signify if samples have been flushed. |
m_bFlushing | Flag for flushing state. |
m_bSendAnyway | Flag to override batch processing. |
m_bTerminate | Termination flag. |
m_evFlushComplete | Event signaling that flushing has finished. |
m_hSem | Handle used for signaling. |
m_hr | HRESULTstructure for return values; used to implement a sticky return value (one that persists even after operations that would usually change the value). |
m_hThread | Worker thread handle. |
m_lBatchSize | Work in batches of this batch size. Ignored if m_bBatchExactis not TRUE. |
m_List | Pointer to a
CSampleListobject. The class
CSampleListis a generic list (
CGenericList) of
objects of
IMediaSampletype.
It is defined as follows:
typedef CGenericList<IMediaSample> CSampleList; |
m_lWaiting | Variable set to nonzero value when waiting for a free element. |
m_nBatched | Number of samples currently batched awaiting processing. |
m_pInputPin | Pointer to the connected input pin. |
m_pPin | Pointer to the output pin. |
m_ppSamples | Pointer to an array of batched samples. |
Member Functions
BeginFlush | Causes all unsent samples to be discarded and sets flushing state. |
COutputQueue | Constructs a COutputQueueobject. |
EndFlush | Finalizes flush of batched or queued samples and resets flushing state. |
EOS | Queues an end-of-stream call to the connected input pin after all batched and queued samples have been passed to the input pin. |
FreeSamples | Removes and releases batched and queued samples. |
InitialThreadProc | Executed by the thread on thread creation. |
IsIdle | Determines if the output queue is idle. |
IsQueued | Determines if samples are being queued or being sent directly. |
IsSpecialSample | Determines if the sample is a control sample. |
NotifyThread | Notifies the thread that there is something to do. |
NewSegment | Queues an IPin::NewSegmentcall to the connected input pin after all queued samples have been passed to the input pin. |
QueueSample | Queues the prepared sample. |
Receive | Passes in a single sample to send to the input pin. |
ReceiveMultiple | Passes a set of samples to send to the input pin. |
Reset | Resets the deferred return code m_hrto allow the output queue to be ready for more data. |
SendAnyway | Frees any batches samples to be sent to the input pin. |
ThreadProc | Implements the thread that sends samples downstream. |