Commit b2d20154 authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Alexandre Julliard

quartz: Implement dynamic format changing in directsound renderer.

parent ca0db588
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment