views:

18

answers:

1

I have a filtergraph with a custom source filter that delivers uncompressed RGB24 bitmap data and uncmompressed PCM sound through two pins. The graph compresses the data using arbitrary compression filters and saves it to a file using an arbitray writer filter. Internally, for each frame there is generated a sound sample with an equal time stamp at the same time. Whenever a frame sample is delivered the corresponding sound sample is buffered and vice versa. The generation of a frame and its sound sample is necessary. They cannot be generated independently.

In certain graph configurations the following behaviour occurs:

The sound pin's FillBuffer method is called and the pin is forced generate a frame and a sound sample to deliver the sound, if no sound sample is buffered. This happens constanly while the frame pin is blocking such that all frames generated are being buffered, consuming a lot of memory after a while.

This has been observed in a graph that compresses the samples using DivX 6.0 (frames) and an ISO MP3 codec (audio) and writes it to an AVI file. Using no compression for audio or Microsoft's ADPCM compressor, the encoding process has a constant (low) memory usage.

How can I guarantee a data flow of equal proportions for both pins of my source filter with the least need to buffer samples?

A: 

Why not derive your filter from CBaseFilter instead of CSource, and then have a single worker thread at the filter level that delivers one sample to each output pin once per loop? Thus, if you are blocked waiting for an empty buffer on the video, you will not be generating unnecessary audio.

Then you could use COutputQueue objects, to deliver data downstream on a separate worker thread for each output pin, so that any compression can be done in parallel.

G

Geraint Davies
I did it the way to described but is has no effect. The frame pin is still blocking in GetDeliveryBuffer(), waiting for an empty buffer.Even though I deliver one video and one audio sample once per loop.Since the downstream input pin's GetDeliveryBuffer() is blocking I can't queue any new IMediaSamples to my output queues.So the question is, why does the video pin's input counterpart cannot provide new empty buffers in certain graph configurations?As I noted before, this happens reproducably using an MP3 audio compressor in a filtergraph that writes an AVI file.
Daniel
The next upstream filter on the video pin is always an InfTee filter.The InfTree filter connects to a Sample Grabber on one pin and a compression filter on the other.The source audio pin is always connected to a compressor filter or to a multiplexer/writer.
Daniel
Not sure that I'm getting what the problem is. The output pin's DecideBufferSize method sets a fixed number of buffers for that connection. When they're used up, you will block until one is released. Also, the inftee will send the *same buffer* to both output pins, so that won't be freed until both downstream pins finish with it.
Geraint Davies