Re: change buffer size
From: Chris P. [MVP] (msdn_at_chrisnet.net)
Date: 02/22/05
- Next message: eglaser_at_gmail.com: "Can't play audio files - Intelligent Connect problem?"
- Previous message: Chris P. [MVP]: "Re: WaveOut filter sources"
- In reply to: Mike Belina: "change buffer size"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 22 Feb 2005 11:03:14 -0500
On Mon, 21 Feb 2005 21:20:03 -0800, Mike Belina wrote:
> I have a DirectShow filter setup as follows:
>
> file.mp2 -> CLSID_MPEG1Splitter -> CLSID_SampleGrabber ->
> CLSID_CMpegAudioCodec -> CLSID_DSoundRender
>
> I can get the buffer using the SampleGrabber and GetCurrentBuffer.
> However, I want the buffer size smaller so I can get more samples.
>
> How can I change the buffer size in the graph? I tried to use an
> IAMBufferNegotiation all of the different In/Out pins. I can great the
> object using QueryInterface, but the GetAllocatorProperties call fails.
>
> Do I need to insert another graph filter to get what I want?
>
> Any help appreciated!!
If you want to change the delivery size I suggest using a custom
SampleGrabber. In the SampleGrabber override
CTransInPlaceInputPin::NotifyAllocator(), actually it already is overridden
in the sample. Replace the code with something that controls the buffer
size. Here's a crude sample.
STDMETHODIMP CSampleGrabberInPin::NotifyAllocator( IMemAllocator
*pAllocator, BOOL bReadOnly )
{
if( m_pPrivateAllocator )
{
if( pAllocator != m_pPrivateAllocator )
{
return E_FAIL;
}
else
{
// if the upstream guy wants to be read only and we don't, then
that's bad
// if the upstream guy doesn't request read only, but we do,
that's okay
if( bReadOnly && !SampleGrabber( )->IsReadOnly( ) )
{
return E_FAIL;
}
}
}
// <inserted_code>
ALLOCATOR_PROPERTIES Props, Actual;
// get the current settings
pAllocator->GetProperties(&Props);
if( bReadOnly)
{ // return fail so that it will give us a buffer we can modify
settings
return E_FAIL;
}
if (Props.cbBuffer > 88000)
Props.cbBuffer = Props.cbBuffer / 100;
if (Props.cbBuffer > 44000)
Props.cbBuffer = Props.cbBuffer / 50;
if (Props.cbBuffer >= 24000)
Props.cbBuffer = Props.cbBuffer / 20;
else if (Props.cbBuffer > 8000)
Props.cbBuffer = Props.cbBuffer / 10;
// set our desired settings
pAllocator->SetProperties(&Props, &Actual);
// </inserted_code>
return CTransInPlaceInputPin::NotifyAllocator( pAllocator, bReadOnly );
}
- Next message: eglaser_at_gmail.com: "Can't play audio files - Intelligent Connect problem?"
- Previous message: Chris P. [MVP]: "Re: WaveOut filter sources"
- In reply to: Mike Belina: "change buffer size"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|