Hi DirectShow forum,
I would like to use the sample grabber to get uncompressed PCM audio data out of my filter graph to play using other means (i.e. not a DirectShow renderer).
The sample grabber "one shot" mode would be the ideal solution to this problem, becuase it would allow me to create a simple GetSample function which advances to the next sample and returns the data. Unfortunately, the "one shot" mode is completely broken (as anybody who has attempted to use it already knows...)
I can't use the callback functions because my application for the sample data does not match the playback rate of the graph. It would be possible to use the callback functions if I could reliably pause the graph after each callback, allowing me to fetch the samples one at a time. This would be like reinventing a very clumsy equivalent of the broken one shot mode, but it would be preferable to writing a filter.
I am not confident to write a filter, and I am surprised and dissapointed that it should be necessary to accomplish this trivial task! Does anybody have any suggestions for a) how to pause the graph after exactly one sample in the sample grabber callback, or b) a better way to achieve my desired outcome
Thank you in advance for your time,
wtrn

Sample grabber callback / one shot for audio samples
senthil_palraj_e81a78
I would like to try doing all my processing in the callback as you suggest, do you have any tip for what might be causing the error I described in the last post I need to solve this error before I can use the callback.
Best regards,
wtrn
LKeene
Thanks for the info! I think I misunderstand the operation of the SG callback. I read that processing in the callback must be kept short because it must fit within one sample. So I though that turning of the graph clock would make things worse by triggering the callback more often! Are you suggesting that I can 'pause' the graph after each sample by blocking in the SG callback If so, that could be a good option for me.
I am using your DirectShowLib (an excellent piece of work), and I tried to use the SG callback methods but I have a problem... I can compile and run your DxSnap or DxScan examples fine, but when I copy and paste their code in to my own application I get a build error:
"The type 'DirectShowLib.ISampleGrabberCB' is defined in an assembly that is not referenced. You must add a reference to assembly 'DirectShowLib-2005, Version=1.5.0.19545, Culture=neutral, PublicKeyToken=67e7b740cdfc2d3f'."
Of course I have referenced the DirectShowLib source, and I use other parts of it all through my application (including in the same class as I try to use SampleCB and BufferCB). The build error only occurs when I inherit ISampleGrabberCB and include SampleCB and BufferCB.
I don't understand what causes this error, because the assembly *is* referenced (and google and msdn are no help). Do you have any tips for me If I can solve this error, I should be able to test the SG method you suggest myself.
Best regards,
wtrn
abcoura
Thank you for your suggestion! You are correct, because I am not rendering there is no "too late"
Best regards,
wtrn
P.S. I did not realise that if I use a classA which inherits another classB, I must reference the assembling containing the inherited classB whenever I use the classA. This was the cause of the reference error.
CnoEvil
the-rpd
If you aren't doing rendering, and there is no clock, what does "too late" mean
Without knowing your particular application, it's hard to say what the best programming technique would be. However, rather than pausing the graph after each sample, how about if you just do everything you need to do with the sample in the callback
nikos_22
Since you aren't going to be using the DS rendering, how about it you just turn off the graph's clock, and do all your processing in the SampleGrabber's callback
As for writing your own filter, that may not be *quite* as bad as you imagine. Heck, I've written a DMO that splits a stereo audio stream into two mono streams. Wasn't that bad. Course I wrote it in c#.