quartz: Implement dynamic format changing in directsound renderer.

This commit is contained in:
Maarten Lankhorst 2008-10-21 12:50:36 +02:00 committed by Alexandre Julliard
parent ca0db58808
commit b2d20154fa

View file

@ -238,6 +238,7 @@ static HRESULT DSoundRender_Sample(LPVOID iface, IMediaSample * pSample)
long cbSrcStream = 0;
REFERENCE_TIME tStart, tStop;
HRESULT hr;
AM_MEDIA_TYPE *amt;
TRACE("%p %p\n", iface, pSample);
@ -259,6 +260,39 @@ static HRESULT DSoundRender_Sample(LPVOID iface, IMediaSample * pSample)
return VFW_E_WRONG_STATE;
}
if (IMediaSample_GetMediaType(pSample, &amt) == S_OK)
{
AM_MEDIA_TYPE *orig = &This->pInputPin->pin.mtCurrent;
WAVEFORMATEX *origfmt = (WAVEFORMATEX *)orig->pbFormat;
WAVEFORMATEX *newfmt = (WAVEFORMATEX *)amt->pbFormat;
if (origfmt->wFormatTag == newfmt->wFormatTag &&
origfmt->nChannels == newfmt->nChannels &&
origfmt->nBlockAlign == newfmt->nBlockAlign &&
origfmt->wBitsPerSample == newfmt->wBitsPerSample &&
origfmt->cbSize == newfmt->cbSize)
{
if (origfmt->nSamplesPerSec != newfmt->nSamplesPerSec)
{
hr = IDirectSoundBuffer_SetFrequency(This->dsbuffer,
newfmt->nSamplesPerSec);
if (FAILED(hr))
{
LeaveCriticalSection(&This->csFilter);
return VFW_E_TYPE_NOT_ACCEPTED;
}
FreeMediaType(orig);
CopyMediaType(orig, amt);
IMediaSample_SetMediaType(pSample, NULL);
}
}
else
{
LeaveCriticalSection(&This->csFilter);
return VFW_E_TYPE_NOT_ACCEPTED;
}
}
SetEvent(This->state_change);
hr = IMediaSample_GetPointer(pSample, &pbSrcStream);