Re: A question about outpin delivering sample

Tech-Archive recommends: Fix windows errors by optimizing your registry



On 29 May 2007 20:00:05 -0700, acolor0429@xxxxxxxxx wrote:

I am new to learning DirectShow.
My question is how to be more efficient and stable to deliver sample
to downstream. The input data is a network stream, the data is
received and put into my buffer. Then, downstream filter will call
DoBufferProcessingLoop() and FillBuffer() on my OutPin to get the
sample. I am confused of how to handle the case if there is no data
in the buffer. In this situation (no data to be delivered), I will
poll the buffer until there is something to be sent. But I sometimes
meet crash when the buffer is empty. The crash is due to "Deliver()"
function pointer is wrong (Access Violation). This is very strange
because this looks like some object is already released. Do you know
when will happen ? and how to improve my outpin implementation.

First you're logic is a bit backwards. DoBufferProcessingLoop() is
effectively part of your output pin (it's in the base class), this is your
streaming thread. This thread requests a buffer with GetMediaSample(),
calls your FillBuffer() and then attempts to Deliver() down stream to the
connected pin.

The safest thing to do if you don't have any data is to not deliver.
Without overriding the DoBufferProcessingLoop() you can do this by blocking
in FillBuffer() while waiting for data. Delivering empty buffers
downstream may or may not work depending on the connected filters and the
media type.

--
http://www.chrisnet.net/code.htm
[MS MVP for DirectShow / MediaFoundation]
.



Relevant Pages

  • Re: I/O buffering
    ... StreamReader also buffers data? ... so they buffer as well. ... Neither StreamReader nor StreamWriter inherit from FileStream. ... What StreamReader and StreamWriter _do_ use is any Stream instance. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Assembly conversion to Pocket Pc format
    ... But in my case it is throwing exception before executing that statement what ... That is before reading buffer size it is throwing ... Stream respStream = resp.GetResponseStream; ... upload and download files in compact framework. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: I/O buffering
    ... classes (those with word Buffer in their name)? ... Stream class. ... One would not normally use BufferedStream with a FileStream, ... explicitly dispose your custom Stream class, when you were sure you were   ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: WMS source changing issue
    ... we use 5 second buffer in WMP. ... The question is - why the server is stopping broadcasting for a while (it ... clearly seen in network statistic in Task Manager) when switching to file ... We're streaming one 5Mbps live stream and one 5Mbps CBR file periodically so ...
    (microsoft.public.windowsmedia.server)
  • Re: scanf() quesion?
    ... characters are intended to ... When a stream is fully buffered, ... when a buffer is filled. ... If standard output refers to an interactive device, ...
    (comp.lang.c)