Re: How to know when WriteStreamSample has written the sample to d

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



On 14 Mar, 14:30, Fredrik <c...@xxxxxxx> wrote:
Thank you for your answer.

The problem is not the timestamps. They are read from source file in the
correct order and written to the asf-file. Like I said the problem is that
when we are writing to a slow disk, the writer operation is slower than the
filereader.
This means that the wmwriter starts buffering and it's eating memory until
the machine is out of it. That's what I must prevent.
I was hoping that it's somehow possible to control that buffering but I have
come up empty reading the docs.  
One solution could for example be if there was a possiblity to monitor the
"buffering" and stop pushing samples with writestreamsample when the buffer
is getting high.

Like I said it should be ideal to get the reader to be synhronous (I know
the packets from the source file always arrives in the correct order)  but I
have not figured out how to do it. There's doesnt seem to be any callback for
when samples are written or when the output buffer is growing.

There's of course not an option that the writer starts dropping samples, the
whole idea iis that an file in our own format should be exported to an
asf-file.

Do you have any idea of how this could be done or is there really no way to
do this with the wmfsdk?

I've written capture functionality using IWMWriterAdvanced. While
doing so I had a bunch of debug logging to make sure nothing went
wrong. One thing I noticed is the following:

// Write sample
wmWriterAdvanced->WriteStreamSample( ... );
QWORD writerTime = 0;
wmWriterAdvanced->GetWriterTime(&writerTime);
If you print writerTime here, you'll probably find that it doesn't
change every time that you call WriteStreamSample.
It will change when the thread that does the actual writing updates
it, though. Atleast that's what I can gather looking at the output.
I suppose you could check the writer time if you want to block until
samples are actually written.
If it doesn't help you, perhaps take a look at the
IWMWriterAdvanced::GetStatistics . Maybe you can introduce some
waiting based on the contents of that structure.
.



Relevant Pages

  • Re: How to know when WriteStreamSample has written the sample to d
    ... However I still think we are talking about different reason for the buffering. ... Like I said it's nothing about the timestamp not arriving in the correct ... I don't understand why the writer should wait for more samples when it ... but it writes the data when the buffered streams ...
    (microsoft.public.windowsmedia.sdk)
  • Re: How to know when WriteStreamSample has written the sample to d
    ... If the writer is not writing out the data, ... but it writes the data when the buffered streams ... are more or less in sync. ... steadily without too much buffering. ...
    (microsoft.public.windowsmedia.sdk)
  • Re: Pipes, cat buffer size
    ... decouples how the reader and the writer interact. ... the reader will be forced to read each byte individually. ... it switches between async in-kernel buffering (<8192 ... Linux isn't actually much better, ...
    (freebsd-hackers)
  • Re: impossible?
    ... >> I don't think any of the standard IPC mechanisms provide this feature. ... When you have no control about the writer how should you be able to ... control if it writes without buffering? ...
    (comp.unix.programmer)