diff options
author | kinddragon <kinddragon@users.sourceforge.net> | 2010-05-29 08:04:26 +0400 |
---|---|---|
committer | kinddragon <kinddragon@users.sourceforge.net> | 2010-05-29 08:04:26 +0400 |
commit | 158e31fbcc38e59cba2451ad5a2bccf69ea697d1 (patch) | |
tree | 1b926f2877ee61d5f052a559fc2f67c10f8bc0eb /src/filters/renderer | |
parent | 02072325a68d4fb294c3ba4f58048c42de3b9e0a (diff) |
A lot of compiler L4 warnings fixed (some warnings disabled)
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1982 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/renderer')
15 files changed, 619 insertions, 625 deletions
diff --git a/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.cpp b/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.cpp index df623f2b2..e0dff543f 100644 --- a/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.cpp +++ b/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.cpp @@ -67,12 +67,12 @@ DEFINE_GUIDSTRUCT("0000000b-0cea-0010-8000-00aa00389b71", KSDATAFORMAT_SUBTYPE_I const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
{
- {&GUID_NULL},
+ {&GUID_NULL},
};
const AMOVIESETUP_PIN sudpPins[] =
{
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
};
const AMOVIESETUP_FILTER sudFilter[] =
@@ -82,7 +82,7 @@ const AMOVIESETUP_FILTER sudFilter[] = CFactoryTemplate g_Templates[] =
{
- {sudFilter[0].strName, &__uuidof(CMpcAudioRenderer), CreateInstance<CMpcAudioRenderer>, NULL, &sudFilter[0]},
+ {sudFilter[0].strName, &__uuidof(CMpcAudioRenderer), CreateInstance<CMpcAudioRenderer>, NULL, &sudFilter[0]},
//{L"CMpcAudioRendererPropertyPage", &__uuidof(CMpcAudioRendererSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpcAudioRendererSettingsWnd> >},
};
@@ -158,7 +158,7 @@ CMpcAudioRenderer::~CMpcAudioRenderer() SAFE_RELEASE (pRenderClient);
SAFE_RELEASE (pAudioClient);
SAFE_RELEASE (pMMDevice);
-
+
if (m_pReferenceClock)
{
SetSyncSource(NULL);
@@ -185,52 +185,52 @@ HRESULT CMpcAudioRenderer::CheckInputType(const CMediaType *pmt) HRESULT CMpcAudioRenderer::CheckMediaType(const CMediaType *pmt)
{
- HRESULT hr = S_OK;
- if (pmt == NULL) return E_INVALIDARG;
- TRACE(_T("CMpcAudioRenderer::CheckMediaType"));
- WAVEFORMATEX *pwfx = (WAVEFORMATEX *) pmt->Format();
-
- if (pwfx == NULL) return VFW_E_TYPE_NOT_ACCEPTED;
-
-if ((pmt->majortype != MEDIATYPE_Audio ) ||
- (pmt->formattype != FORMAT_WaveFormatEx ))
- {
- TRACE(_T("CMpcAudioRenderer::CheckMediaType Not supported"));
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if(useWASAPI)
- {
- hr=CheckAudioClient((WAVEFORMATEX *)NULL);
- if (FAILED(hr))
- {
- TRACE(_T("CMpcAudioRenderer::CheckMediaType Error on check audio client"));
- return hr;
- }
- if (!pAudioClient)
- {
- TRACE(_T("CMpcAudioRenderer::CheckMediaType Error, audio client not loaded"));
- return VFW_E_CANNOT_CONNECT;
- }
-
- if (pAudioClient->IsFormatSupported(AUDCLNT_SHAREMODE_EXCLUSIVE, pwfx, NULL) != S_OK)
- {
- TRACE(_T("CMpcAudioRenderer::CheckMediaType WASAPI client refused the format"));
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- TRACE(_T("CMpcAudioRenderer::CheckMediaType WASAPI client accepted the format"));
- }
- else if (pwfx->wFormatTag != WAVE_FORMAT_PCM)
- {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
+ HRESULT hr = S_OK;
+ if (pmt == NULL) return E_INVALIDARG;
+ TRACE(_T("CMpcAudioRenderer::CheckMediaType"));
+ WAVEFORMATEX *pwfx = (WAVEFORMATEX *) pmt->Format();
+
+ if (pwfx == NULL) return VFW_E_TYPE_NOT_ACCEPTED;
+
+ if ((pmt->majortype != MEDIATYPE_Audio ) ||
+ (pmt->formattype != FORMAT_WaveFormatEx ))
+ {
+ TRACE(_T("CMpcAudioRenderer::CheckMediaType Not supported"));
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+
+ if(useWASAPI)
+ {
+ hr=CheckAudioClient((WAVEFORMATEX *)NULL);
+ if (FAILED(hr))
+ {
+ TRACE(_T("CMpcAudioRenderer::CheckMediaType Error on check audio client"));
+ return hr;
+ }
+ if (!pAudioClient)
+ {
+ TRACE(_T("CMpcAudioRenderer::CheckMediaType Error, audio client not loaded"));
+ return VFW_E_CANNOT_CONNECT;
+ }
+
+ if (pAudioClient->IsFormatSupported(AUDCLNT_SHAREMODE_EXCLUSIVE, pwfx, NULL) != S_OK)
+ {
+ TRACE(_T("CMpcAudioRenderer::CheckMediaType WASAPI client refused the format"));
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+ TRACE(_T("CMpcAudioRenderer::CheckMediaType WASAPI client accepted the format"));
+ }
+ else if (pwfx->wFormatTag != WAVE_FORMAT_PCM)
+ {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
return S_OK;
}
void CMpcAudioRenderer::OnReceiveFirstSample(IMediaSample *pMediaSample)
{
- if (!useWASAPI)
- ClearBuffer();
+ if (!useWASAPI)
+ ClearBuffer();
}
BOOL CMpcAudioRenderer::ScheduleSample(IMediaSample *pMediaSample)
@@ -238,51 +238,51 @@ BOOL CMpcAudioRenderer::ScheduleSample(IMediaSample *pMediaSample) REFERENCE_TIME StartSample;
REFERENCE_TIME EndSample;
- // Is someone pulling our leg
- if (pMediaSample == NULL) return FALSE;
+ // Is someone pulling our leg
+ if (pMediaSample == NULL) return FALSE;
- // Get the next sample due up for rendering. If there aren't any ready
- // then GetNextSampleTimes returns an error. If there is one to be done
- // then it succeeds and yields the sample times. If it is due now then
- // it returns S_OK other if it's to be done when due it returns S_FALSE
- HRESULT hr = GetSampleTimes(pMediaSample, &StartSample, &EndSample);
- if (FAILED(hr)) return FALSE;
+ // Get the next sample due up for rendering. If there aren't any ready
+ // then GetNextSampleTimes returns an error. If there is one to be done
+ // then it succeeds and yields the sample times. If it is due now then
+ // it returns S_OK other if it's to be done when due it returns S_FALSE
+ HRESULT hr = GetSampleTimes(pMediaSample, &StartSample, &EndSample);
+ if (FAILED(hr)) return FALSE;
- // If we don't have a reference clock then we cannot set up the advise
- // time so we simply set the event indicating an image to render. This
- // will cause us to run flat out without any timing or synchronisation
- if (hr == S_OK)
+ // If we don't have a reference clock then we cannot set up the advise
+ // time so we simply set the event indicating an image to render. This
+ // will cause us to run flat out without any timing or synchronisation
+ if (hr == S_OK)
{
EXECUTE_ASSERT(SetEvent((HANDLE) m_RenderEvent));
return TRUE;
- }
-
- if (m_dRate <= 1.1)
- {
- ASSERT(m_dwAdvise == 0);
- ASSERT(m_pClock);
- WaitForSingleObject((HANDLE)m_RenderEvent,0);
-
- hr = m_pClock->AdviseTime( (REFERENCE_TIME) m_tStart, StartSample, (HEVENT)(HANDLE) m_RenderEvent, &m_dwAdvise);
- if (SUCCEEDED(hr)) return TRUE;
- }
- else
- hr = DoRenderSample (pMediaSample);
-
- // We could not schedule the next sample for rendering despite the fact
- // we have a valid sample here. This is a fair indication that either
- // the system clock is wrong or the time stamp for the sample is duff
- ASSERT(m_dwAdvise == 0);
-
- return FALSE;
+ }
+
+ if (m_dRate <= 1.1)
+ {
+ ASSERT(m_dwAdvise == 0);
+ ASSERT(m_pClock);
+ WaitForSingleObject((HANDLE)m_RenderEvent,0);
+
+ hr = m_pClock->AdviseTime( (REFERENCE_TIME) m_tStart, StartSample, (HEVENT)(HANDLE) m_RenderEvent, &m_dwAdvise);
+ if (SUCCEEDED(hr)) return TRUE;
+ }
+ else
+ hr = DoRenderSample (pMediaSample);
+
+ // We could not schedule the next sample for rendering despite the fact
+ // we have a valid sample here. This is a fair indication that either
+ // the system clock is wrong or the time stamp for the sample is duff
+ ASSERT(m_dwAdvise == 0);
+
+ return FALSE;
}
HRESULT CMpcAudioRenderer::DoRenderSample(IMediaSample *pMediaSample)
{
- if (useWASAPI)
- return DoRenderSampleWasapi(pMediaSample);
- else
- return DoRenderSampleDirectSound(pMediaSample);
+ if (useWASAPI)
+ return DoRenderSampleWasapi(pMediaSample);
+ else
+ return DoRenderSampleDirectSound(pMediaSample);
}
@@ -299,48 +299,47 @@ STDMETHODIMP CMpcAudioRenderer::NonDelegatingQueryInterface(REFIID riid, void ** HRESULT CMpcAudioRenderer::SetMediaType(const CMediaType *pmt)
{
if (! pmt) return E_POINTER;
- HRESULT hr = S_OK;
- int size = 0;
- TRACE(_T("CMpcAudioRenderer::SetMediaType"));
-
- if (useWASAPI)
- {
- // New media type set but render client already initialized => reset it
- if (pRenderClient!=NULL)
- {
- WAVEFORMATEX *pNewWf = (WAVEFORMATEX *) pmt->Format();
- TRACE(_T("CMpcAudioRenderer::SetMediaType Render client already initialized. Reinitialization..."));
- CheckAudioClient(pNewWf);
- }
- }
-
- if (m_pWaveFileFormat)
+ int size = 0;
+ TRACE(_T("CMpcAudioRenderer::SetMediaType"));
+
+ if (useWASAPI)
+ {
+ // New media type set but render client already initialized => reset it
+ if (pRenderClient!=NULL)
+ {
+ WAVEFORMATEX *pNewWf = (WAVEFORMATEX *) pmt->Format();
+ TRACE(_T("CMpcAudioRenderer::SetMediaType Render client already initialized. Reinitialization..."));
+ CheckAudioClient(pNewWf);
+ }
+ }
+
+ if (m_pWaveFileFormat)
{
BYTE *p = (BYTE *)m_pWaveFileFormat;
SAFE_DELETE_ARRAY(p);
}
- m_pWaveFileFormat=NULL;
+ m_pWaveFileFormat=NULL;
- WAVEFORMATEX *pwf = (WAVEFORMATEX *) pmt->Format();
- if (pwf!=NULL)
- {
- size = sizeof(WAVEFORMATEX) + pwf->cbSize;
+ WAVEFORMATEX *pwf = (WAVEFORMATEX *) pmt->Format();
+ if (pwf!=NULL)
+ {
+ size = sizeof(WAVEFORMATEX) + pwf->cbSize;
+
+ m_pWaveFileFormat = (WAVEFORMATEX *)new BYTE[size];
+ if (! m_pWaveFileFormat)
+ return E_OUTOFMEMORY;
- m_pWaveFileFormat = (WAVEFORMATEX *)new BYTE[size];
- if (! m_pWaveFileFormat)
- return E_OUTOFMEMORY;
-
- memcpy(m_pWaveFileFormat, pwf, size);
+ memcpy(m_pWaveFileFormat, pwf, size);
- if (!useWASAPI && m_pSoundTouch && (pwf->nChannels <= 2))
- {
- m_pSoundTouch->setSampleRate (pwf->nSamplesPerSec);
- m_pSoundTouch->setChannels (pwf->nChannels);
- m_pSoundTouch->setTempoChange (0);
- m_pSoundTouch->setPitchSemiTones(0);
- }
- }
+ if (!useWASAPI && m_pSoundTouch && (pwf->nChannels <= 2))
+ {
+ m_pSoundTouch->setSampleRate (pwf->nSamplesPerSec);
+ m_pSoundTouch->setChannels (pwf->nChannels);
+ m_pSoundTouch->setTempoChange (0);
+ m_pSoundTouch->setPitchSemiTones(0);
+ }
+ }
return CBaseRenderer::SetMediaType (pmt);
}
@@ -348,65 +347,64 @@ HRESULT CMpcAudioRenderer::SetMediaType(const CMediaType *pmt) HRESULT CMpcAudioRenderer::CompleteConnect(IPin *pReceivePin)
{
HRESULT hr = S_OK;
- TRACE(_T("CMpcAudioRenderer::CompleteConnect"));
+ TRACE(_T("CMpcAudioRenderer::CompleteConnect"));
- if (!useWASAPI && ! m_pDS) return E_FAIL;
+ if (!useWASAPI && ! m_pDS) return E_FAIL;
if (SUCCEEDED(hr)) hr = CBaseRenderer::CompleteConnect(pReceivePin);
if (SUCCEEDED(hr)) hr = InitCoopLevel();
if (!useWASAPI)
- {
- if (SUCCEEDED(hr)) hr = CreateDSBuffer();
- }
- if (SUCCEEDED(hr)) TRACE(_T("CMpcAudioRenderer::CompleteConnect Success"));
+ {
+ if (SUCCEEDED(hr)) hr = CreateDSBuffer();
+ }
+ if (SUCCEEDED(hr)) TRACE(_T("CMpcAudioRenderer::CompleteConnect Success"));
return hr;
-
}
STDMETHODIMP CMpcAudioRenderer::Run(REFERENCE_TIME tStart)
{
HRESULT hr;
- if (m_State == State_Running) return NOERROR;
-
- if (useWASAPI)
- {
- hr=CheckAudioClient(m_pWaveFileFormat);
- if (FAILED(hr))
- {
- TRACE(_T("CMpcAudioRenderer::Run Error on check audio client"));
- return hr;
- }
- // Rather start the client at the last moment when the buffer is fed
- /*hr = pAudioClient->Start();
- if (FAILED (hr))
- {
- TRACE(_T("CMpcAudioRenderer::Run Start error"));
- return hr;
- }*/
- }
- else
- {
- if (m_pDSBuffer &&
- m_pPosition &&
- m_pWaveFileFormat &&
- SUCCEEDED(m_pPosition->GetRate(&m_dRate)))
- {
- if (m_dRate < 1.0)
+ if (m_State == State_Running) return NOERROR;
+
+ if (useWASAPI)
+ {
+ hr=CheckAudioClient(m_pWaveFileFormat);
+ if (FAILED(hr))
+ {
+ TRACE(_T("CMpcAudioRenderer::Run Error on check audio client"));
+ return hr;
+ }
+ // Rather start the client at the last moment when the buffer is fed
+ /*hr = pAudioClient->Start();
+ if (FAILED (hr))
+ {
+ TRACE(_T("CMpcAudioRenderer::Run Start error"));
+ return hr;
+ }*/
+ }
+ else
+ {
+ if (m_pDSBuffer &&
+ m_pPosition &&
+ m_pWaveFileFormat &&
+ SUCCEEDED(m_pPosition->GetRate(&m_dRate)))
+ {
+ if (m_dRate < 1.0)
{
hr = m_pDSBuffer->SetFrequency ((long)(m_pWaveFileFormat->nSamplesPerSec * m_dRate));
if (FAILED (hr)) return hr;
}
- else
+ else
{
hr = m_pDSBuffer->SetFrequency ((long)m_pWaveFileFormat->nSamplesPerSec);
m_pSoundTouch->setRateChange((float)(m_dRate-1.0)*100);
}
- }
+ }
- ClearBuffer();
- }
+ ClearBuffer();
+ }
hr = CBaseRenderer::Run(tStart);
return hr;
@@ -415,17 +413,17 @@ STDMETHODIMP CMpcAudioRenderer::Run(REFERENCE_TIME tStart) STDMETHODIMP CMpcAudioRenderer::Stop()
{
if (m_pDSBuffer) m_pDSBuffer->Stop();
- isAudioClientStarted=false;
+ isAudioClientStarted=false;
- return CBaseRenderer::Stop();
+ return CBaseRenderer::Stop();
};
STDMETHODIMP CMpcAudioRenderer::Pause()
{
if (m_pDSBuffer) m_pDSBuffer->Stop();
- if (pAudioClient && isAudioClientStarted) pAudioClient->Stop();
- isAudioClientStarted=false;
+ if (pAudioClient && isAudioClientStarted) pAudioClient->Stop();
+ isAudioClientStarted=false;
return CBaseRenderer::Pause();
};
@@ -458,11 +456,11 @@ HRESULT CMpcAudioRenderer::GetReferenceClockInterface(REFIID riid, void **ppv) HRESULT CMpcAudioRenderer::EndOfStream(void)
{
- if (m_pDSBuffer) m_pDSBuffer->Stop();
+ if (m_pDSBuffer) m_pDSBuffer->Stop();
#if !FILEWRITER
- if (pAudioClient && isAudioClientStarted) pAudioClient->Stop();
+ if (pAudioClient && isAudioClientStarted) pAudioClient->Stop();
#endif
- isAudioClientStarted=false;
+ isAudioClientStarted=false;
return CBaseRenderer::EndOfStream();
}
@@ -500,14 +498,14 @@ HRESULT CMpcAudioRenderer::CreateDSBuffer() SAFE_RELEASE (m_pDSBuffer);
cDSBufferDesc.dwSize = sizeof (DSBUFFERDESC);
cDSBufferDesc.dwFlags = DSBCAPS_GLOBALFOCUS |
- DSBCAPS_GETCURRENTPOSITION2 |
- DSBCAPS_CTRLVOLUME |
- DSBCAPS_CTRLPAN |
- DSBCAPS_CTRLFREQUENCY;
+ DSBCAPS_GETCURRENTPOSITION2 |
+ DSBCAPS_CTRLVOLUME |
+ DSBCAPS_CTRLPAN |
+ DSBCAPS_CTRLFREQUENCY;
cDSBufferDesc.dwBufferBytes = dwDSBufSize;
cDSBufferDesc.dwReserved = 0;
cDSBufferDesc.lpwfxFormat = m_pWaveFileFormat;
- cDSBufferDesc.guid3DAlgorithm = GUID_NULL;
+ cDSBufferDesc.guid3DAlgorithm = GUID_NULL;
hr = m_pDS->CreateSoundBuffer (&cDSBufferDesc, &m_pDSBuffer, NULL);
@@ -609,23 +607,23 @@ HRESULT CMpcAudioRenderer::DoRenderSampleDirectSound(IMediaSample *pMediaSample) hr = m_pDSBuffer->Play( 0, 0, DSBPLAY_LOOPING);
ATLASSERT(SUCCEEDED(hr));
}
-
+
if (SUCCEEDED(hr)) hr = m_pDSBuffer->GetCurrentPosition(&dwPlayCursor, &dwWriteCursor);
if (SUCCEEDED(hr))
{
if ( ( (dwPlayCursor < dwWriteCursor) &&
- (
- ((m_dwDSWriteOff >= dwPlayCursor) && (m_dwDSWriteOff <= dwWriteCursor))
- ||
- ((m_dwDSWriteOff < dwPlayCursor) && (m_dwDSWriteOff + lSize >= dwPlayCursor))
- )
- )
- ||
- ( (dwWriteCursor < dwPlayCursor) &&
- (
- (m_dwDSWriteOff >= dwPlayCursor) || (m_dwDSWriteOff < dwWriteCursor)
- ) ) )
+ (
+ ((m_dwDSWriteOff >= dwPlayCursor) && (m_dwDSWriteOff <= dwWriteCursor))
+ ||
+ ((m_dwDSWriteOff < dwPlayCursor) && (m_dwDSWriteOff + lSize >= dwPlayCursor))
+ )
+ )
+ ||
+ ( (dwWriteCursor < dwPlayCursor) &&
+ (
+ (m_dwDSWriteOff >= dwPlayCursor) || (m_dwDSWriteOff < dwWriteCursor)
+ ) ) )
{
m_dwDSWriteOff = dwWriteCursor;
}
@@ -637,7 +635,7 @@ HRESULT CMpcAudioRenderer::DoRenderSampleDirectSound(IMediaSample *pMediaSample) }
if (SUCCEEDED(hr)) hr = WriteSampleToDSBuffer(pMediaSample, NULL);
-
+
return hr;
}
@@ -708,338 +706,337 @@ HRESULT CMpcAudioRenderer::WriteSampleToDSBuffer(IMediaSample *pMediaSample, boo HRESULT CMpcAudioRenderer::DoRenderSampleWasapi(IMediaSample *pMediaSample)
{
HRESULT hr = S_OK;
- REFERENCE_TIME rtStart = 0;
+ REFERENCE_TIME rtStart = 0;
REFERENCE_TIME rtStop = 0;
- DWORD flags = 0;
- BYTE *pMediaBuffer = NULL;
- BYTE *pInputBufferPointer = NULL;
- BYTE *pInputBufferEnd = NULL;
- BYTE *pData;
- bufferSize = pMediaSample->GetActualDataLength();
- const long lSize = bufferSize;
- pMediaSample->GetTime (&rtStart, &rtStop);
-
- AM_MEDIA_TYPE *pmt;
- if (SUCCEEDED(pMediaSample->GetMediaType(&pmt)) && pmt!=NULL)
- {
- CMediaType mt(*pmt);
- if ((WAVEFORMATEXTENSIBLE*)mt.Format() != NULL)
- hr=CheckAudioClient(&(((WAVEFORMATEXTENSIBLE*)mt.Format())->Format));
- else
- hr=CheckAudioClient((WAVEFORMATEX*)mt.Format());
- if (FAILED(hr))
- {
- TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi Error while checking audio client with input media type"));
- return hr;
- }
- DeleteMediaType(pmt);
- pmt=NULL;
- }
-
- // Initialization
- hr = pMediaSample->GetPointer(&pMediaBuffer);
- if (FAILED (hr)) return hr;
-
- pInputBufferPointer=&pMediaBuffer[0];
- pInputBufferEnd=&pMediaBuffer[0]+lSize;
-
- WORD frameSize = m_pWaveFileFormat->nBlockAlign;
-
-
- // Sleep for half the buffer duration since last buffer feed
- DWORD currentTime=GetTickCount();
- if (lastBufferTime!=0 && hnsActualDuration!= 0 && lastBufferTime<currentTime && (currentTime-lastBufferTime)<hnsActualDuration)
- {
- hnsActualDuration=hnsActualDuration-(currentTime-lastBufferTime);
- Sleep(hnsActualDuration);
- }
+ BYTE *pMediaBuffer = NULL;
+ BYTE *pInputBufferPointer = NULL;
+ BYTE *pInputBufferEnd = NULL;
+ BYTE *pData;
+ bufferSize = pMediaSample->GetActualDataLength();
+ const long lSize = bufferSize;
+ pMediaSample->GetTime (&rtStart, &rtStop);
+
+ AM_MEDIA_TYPE *pmt;
+ if (SUCCEEDED(pMediaSample->GetMediaType(&pmt)) && pmt!=NULL)
+ {
+ CMediaType mt(*pmt);
+ if ((WAVEFORMATEXTENSIBLE*)mt.Format() != NULL)
+ hr=CheckAudioClient(&(((WAVEFORMATEXTENSIBLE*)mt.Format())->Format));
+ else
+ hr=CheckAudioClient((WAVEFORMATEX*)mt.Format());
+ if (FAILED(hr))
+ {
+ TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi Error while checking audio client with input media type"));
+ return hr;
+ }
+ DeleteMediaType(pmt);
+ pmt=NULL;
+ }
+
+ // Initialization
+ hr = pMediaSample->GetPointer(&pMediaBuffer);
+ if (FAILED (hr)) return hr;
+
+ pInputBufferPointer=&pMediaBuffer[0];
+ pInputBufferEnd=&pMediaBuffer[0]+lSize;
+
+ WORD frameSize = m_pWaveFileFormat->nBlockAlign;
+
+
+ // Sleep for half the buffer duration since last buffer feed
+ DWORD currentTime=GetTickCount();
+ if (lastBufferTime!=0 && hnsActualDuration!= 0 && lastBufferTime<currentTime && (currentTime-lastBufferTime)<hnsActualDuration)
+ {
+ hnsActualDuration=hnsActualDuration-(currentTime-lastBufferTime);
+ Sleep(hnsActualDuration);
+ }
// Each loop fills one of the two buffers.
- while (pInputBufferPointer < pInputBufferEnd)
- {
- UINT32 numFramesPadding=0;
- pAudioClient->GetCurrentPadding(&numFramesPadding);
- UINT32 numFramesAvailable = nFramesInBuffer - numFramesPadding;
-
- UINT32 nAvailableBytes=numFramesAvailable*frameSize;
- UINT32 nBytesToWrite=nAvailableBytes;
- // More room than enough in the output buffer
- if (nAvailableBytes > pInputBufferEnd - pInputBufferPointer)
- {
- nBytesToWrite=pInputBufferEnd - pInputBufferPointer;
- numFramesAvailable=(UINT32)((float)nBytesToWrite/frameSize);
- }
-
- // Grab the next empty buffer from the audio device.
- hr = pRenderClient->GetBuffer(numFramesAvailable, &pData);
- if (FAILED (hr))
- {
- TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi GetBuffer failed with size %ld : (error %lx)"),nFramesInBuffer,hr);
- return hr;
- }
-
- // Load the buffer with data from the audio source.
- if (pData != NULL)
+ while (pInputBufferPointer < pInputBufferEnd)
+ {
+ UINT32 numFramesPadding=0;
+ pAudioClient->GetCurrentPadding(&numFramesPadding);
+ UINT32 numFramesAvailable = nFramesInBuffer - numFramesPadding;
+
+ UINT32 nAvailableBytes=numFramesAvailable*frameSize;
+ UINT32 nBytesToWrite=nAvailableBytes;
+ // More room than enough in the output buffer
+ if (nAvailableBytes > pInputBufferEnd - pInputBufferPointer)
+ {
+ nBytesToWrite=pInputBufferEnd - pInputBufferPointer;
+ numFramesAvailable=(UINT32)((float)nBytesToWrite/frameSize);
+ }
+
+ // Grab the next empty buffer from the audio device.
+ hr = pRenderClient->GetBuffer(numFramesAvailable, &pData);
+ if (FAILED (hr))
+ {
+ TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi GetBuffer failed with size %ld : (error %lx)"),nFramesInBuffer,hr);
+ return hr;
+ }
+
+ // Load the buffer with data from the audio source.
+ if (pData != NULL)
{
- memcpy(&pData[0], pInputBufferPointer, nBytesToWrite);
- pInputBufferPointer += nBytesToWrite;
+ memcpy(&pData[0], pInputBufferPointer, nBytesToWrite);
+ pInputBufferPointer += nBytesToWrite;
+ }
+ else
+ TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi Output buffer is NULL"));
+
+ hr = pRenderClient->ReleaseBuffer(numFramesAvailable, 0); // no flags
+ if (FAILED (hr))
+ {
+ TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi ReleaseBuffer failed with size %ld (error %lx)"),nFramesInBuffer,hr);
+ return hr;
+ }
+
+ if (!isAudioClientStarted)
+ {
+ TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi Starting audio client"));
+ pAudioClient->Start();
+ isAudioClientStarted=true;
+ }
+
+ if (pInputBufferPointer >= pInputBufferEnd)
+ {
+ lastBufferTime=GetTickCount();
+ // This is the duration of the filled buffer
+ hnsActualDuration=(double)REFTIMES_PER_SEC * numFramesAvailable / m_pWaveFileFormat->nSamplesPerSec;
+ // Sleep time is half this duration
+ hnsActualDuration=(DWORD)(hnsActualDuration/REFTIMES_PER_MILLISEC/2);
+ break;
}
- else
- TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi Output buffer is NULL"));
-
- hr = pRenderClient->ReleaseBuffer(numFramesAvailable, 0); // no flags
- if (FAILED (hr))
- {
- TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi ReleaseBuffer failed with size %ld (error %lx)"),nFramesInBuffer,hr);
- return hr;
- }
-
- if (!isAudioClientStarted)
- {
- TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi Starting audio client"));
- pAudioClient->Start();
- isAudioClientStarted=true;
- }
-
- if (pInputBufferPointer >= pInputBufferEnd)
- {
- lastBufferTime=GetTickCount();
- // This is the duration of the filled buffer
- hnsActualDuration=(double)REFTIMES_PER_SEC * numFramesAvailable / m_pWaveFileFormat->nSamplesPerSec;
- // Sleep time is half this duration
- hnsActualDuration=(DWORD)(hnsActualDuration/REFTIMES_PER_MILLISEC/2);
- break;
- }
-
- // Buffer not completely filled, sleep for half buffer capacity duration
- hnsActualDuration=(double)REFTIMES_PER_SEC * nFramesInBuffer / m_pWaveFileFormat->nSamplesPerSec;
- // Sleep time is half this duration
- hnsActualDuration=(DWORD)(hnsActualDuration/REFTIMES_PER_MILLISEC/2);
- Sleep(hnsActualDuration);
- }
+
+ // Buffer not completely filled, sleep for half buffer capacity duration
+ hnsActualDuration=(double)REFTIMES_PER_SEC * nFramesInBuffer / m_pWaveFileFormat->nSamplesPerSec;
+ // Sleep time is half this duration
+ hnsActualDuration=(DWORD)(hnsActualDuration/REFTIMES_PER_MILLISEC/2);
+ Sleep(hnsActualDuration);
+ }
return hr;
}
HRESULT CMpcAudioRenderer::CheckAudioClient(WAVEFORMATEX *pWaveFormatEx)
{
- HRESULT hr = S_OK;
- CAutoLock cAutoLock(&m_csCheck);
- TRACE(_T("CMpcAudioRenderer::CheckAudioClient"));
- if (pMMDevice == NULL) hr=GetDefaultAudioDevice(&pMMDevice);
-
- // If no WAVEFORMATEX structure provided and client already exists, return it
- if (pAudioClient != NULL && pWaveFormatEx == NULL) return hr;
-
- // Just create the audio client if no WAVEFORMATEX provided
- if (pAudioClient == NULL && pWaveFormatEx==NULL)
- {
- if (SUCCEEDED (hr)) hr=CreateAudioClient(pMMDevice, &pAudioClient);
- return hr;
- }
-
- // Compare the exisiting WAVEFORMATEX with the one provided
- WAVEFORMATEX *pNewWaveFormatEx = NULL;
- if (CheckFormatChanged(pWaveFormatEx, &pNewWaveFormatEx))
- {
- // Format has changed, audio client has to be reinitialized
- TRACE(_T("CMpcAudioRenderer::CheckAudioClient Format changed, reinitialize the audio client"));
- if (m_pWaveFileFormat)
- {
- BYTE *p = (BYTE *)m_pWaveFileFormat;
- SAFE_DELETE_ARRAY(p);
- }
- m_pWaveFileFormat=pNewWaveFormatEx;
- hr = pAudioClient->IsFormatSupported(AUDCLNT_SHAREMODE_EXCLUSIVE, pWaveFormatEx, NULL);
- if (SUCCEEDED(hr))
- {
- if (pAudioClient!=NULL && isAudioClientStarted) pAudioClient->Stop();
- isAudioClientStarted=false;
- SAFE_RELEASE(pRenderClient);
- SAFE_RELEASE(pAudioClient);
- if (SUCCEEDED (hr)) hr=CreateAudioClient(pMMDevice, &pAudioClient);
- }
- else
- {
- TRACE(_T("CMpcAudioRenderer::CheckAudioClient New format not supported, accept it anyway"));
- return S_OK;
- }
- }
- else if (pRenderClient == NULL)
- {
- TRACE(_T("CMpcAudioRenderer::CheckAudioClient First initialization of the audio renderer"));
- }
- else
- return hr;
-
-
- SAFE_RELEASE(pRenderClient);
- if (SUCCEEDED (hr)) hr=InitAudioClient(pWaveFormatEx, pAudioClient, &pRenderClient);
- return hr;
+ HRESULT hr = S_OK;
+ CAutoLock cAutoLock(&m_csCheck);
+ TRACE(_T("CMpcAudioRenderer::CheckAudioClient"));
+ if (pMMDevice == NULL) hr=GetDefaultAudioDevice(&pMMDevice);
+
+ // If no WAVEFORMATEX structure provided and client already exists, return it
+ if (pAudioClient != NULL && pWaveFormatEx == NULL) return hr;
+
+ // Just create the audio client if no WAVEFORMATEX provided
+ if (pAudioClient == NULL && pWaveFormatEx==NULL)
+ {
+ if (SUCCEEDED (hr)) hr=CreateAudioClient(pMMDevice, &pAudioClient);
+ return hr;
+ }
+
+ // Compare the exisiting WAVEFORMATEX with the one provided
+ WAVEFORMATEX *pNewWaveFormatEx = NULL;
+ if (CheckFormatChanged(pWaveFormatEx, &pNewWaveFormatEx))
+ {
+ // Format has changed, audio client has to be reinitialized
+ TRACE(_T("CMpcAudioRenderer::CheckAudioClient Format changed, reinitialize the audio client"));
+ if (m_pWaveFileFormat)
+ {
+ BYTE *p = (BYTE *)m_pWaveFileFormat;
+ SAFE_DELETE_ARRAY(p);
+ }
+ m_pWaveFileFormat=pNewWaveFormatEx;
+ hr = pAudioClient->IsFormatSupported(AUDCLNT_SHAREMODE_EXCLUSIVE, pWaveFormatEx, NULL);
+ if (SUCCEEDED(hr))
+ {
+ if (pAudioClient!=NULL && isAudioClientStarted) pAudioClient->Stop();
+ isAudioClientStarted=false;
+ SAFE_RELEASE(pRenderClient);
+ SAFE_RELEASE(pAudioClient);
+ if (SUCCEEDED (hr)) hr=CreateAudioClient(pMMDevice, &pAudioClient);
+ }
+ else
+ {
+ TRACE(_T("CMpcAudioRenderer::CheckAudioClient New format not supported, accept it anyway"));
+ return S_OK;
+ }
+ }
+ else if (pRenderClient == NULL)
+ {
+ TRACE(_T("CMpcAudioRenderer::CheckAudioClient First initialization of the audio renderer"));
+ }
+ else
+ return hr;
+
+
+ SAFE_RELEASE(pRenderClient);
+ if (SUCCEEDED (hr)) hr=InitAudioClient(pWaveFormatEx, pAudioClient, &pRenderClient);
+ return hr;
}
/* Retrieves the default audio device from the Core Audio API
- To be used for WASAPI mode
- TODO : choose a device in the renderer configuration dialogs
+To be used for WASAPI mode
+TODO : choose a device in the renderer configuration dialogs
*/
HRESULT CMpcAudioRenderer::GetDefaultAudioDevice(IMMDevice **ppMMDevice)
{
HRESULT hr;
CComPtr<IMMDeviceEnumerator> enumerator;
- TRACE(_T("CMpcAudioRenderer::GetDefaultAudioDevice"));
+ TRACE(_T("CMpcAudioRenderer::GetDefaultAudioDevice"));
hr = enumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator));
hr = enumerator->GetDefaultAudioEndpoint(eRender, eConsole,
- ppMMDevice);
- return hr;
+ ppMMDevice);
+ return hr;
}
bool CMpcAudioRenderer::CheckFormatChanged(WAVEFORMATEX *pWaveFormatEx, WAVEFORMATEX **ppNewWaveFormatEx)
{
- bool formatChanged=false;
- if (m_pWaveFileFormat==NULL)
- formatChanged=true;
- else if (pWaveFormatEx->wFormatTag != m_pWaveFileFormat->wFormatTag
- || pWaveFormatEx->nChannels != m_pWaveFileFormat->nChannels
- || pWaveFormatEx->wBitsPerSample != m_pWaveFileFormat->wBitsPerSample) // TODO : improve the checks
- formatChanged=true;
+ bool formatChanged=false;
+ if (m_pWaveFileFormat==NULL)
+ formatChanged=true;
+ else if (pWaveFormatEx->wFormatTag != m_pWaveFileFormat->wFormatTag
+ || pWaveFormatEx->nChannels != m_pWaveFileFormat->nChannels
+ || pWaveFormatEx->wBitsPerSample != m_pWaveFileFormat->wBitsPerSample) // TODO : improve the checks
+ formatChanged=true;
- if (!formatChanged) return false;
+ if (!formatChanged) return false;
- int size = sizeof(WAVEFORMATEX) + pWaveFormatEx->cbSize; // Always true, even for WAVEFORMATEXTENSIBLE and WAVEFORMATEXTENSIBLE_IEC61937
- *ppNewWaveFormatEx = (WAVEFORMATEX *)new BYTE[size];
+ int size = sizeof(WAVEFORMATEX) + pWaveFormatEx->cbSize; // Always true, even for WAVEFORMATEXTENSIBLE and WAVEFORMATEXTENSIBLE_IEC61937
+ *ppNewWaveFormatEx = (WAVEFORMATEX *)new BYTE[size];
if (! *ppNewWaveFormatEx)
return false;
- memcpy(*ppNewWaveFormatEx, pWaveFormatEx, size);
- return true;
+ memcpy(*ppNewWaveFormatEx, pWaveFormatEx, size);
+ return true;
}
HRESULT CMpcAudioRenderer::GetBufferSize(WAVEFORMATEX *pWaveFormatEx, REFERENCE_TIME *pHnsBufferPeriod)
{
- if (pWaveFormatEx==NULL) return S_OK;
- if (pWaveFormatEx->cbSize <22) //WAVEFORMATEX
- return S_OK;
-
- WAVEFORMATEXTENSIBLE *wfext=(WAVEFORMATEXTENSIBLE*)pWaveFormatEx;
-
- if (bufferSize==0)
- if (wfext->SubFormat==KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_MLP)
- bufferSize=61440;
- else if (wfext->SubFormat==KSDATAFORMAT_SUBTYPE_IEC61937_DTS_HD)
- bufferSize=32768;
- else if (wfext->SubFormat==KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_DIGITAL_PLUS)
- bufferSize=24576;
- else if (wfext->Format.wFormatTag==WAVE_FORMAT_DOLBY_AC3_SPDIF)
- bufferSize=6144;
- else return S_OK;
-
- *pHnsBufferPeriod = (REFERENCE_TIME)( (REFERENCE_TIME)bufferSize * 10000 * 8 / ((REFERENCE_TIME)pWaveFormatEx->nChannels * pWaveFormatEx->wBitsPerSample *
- 1.0 * pWaveFormatEx->nSamplesPerSec) /*+ 0.5*/);
- *pHnsBufferPeriod *= 1000;
-
- TRACE(_T("CMpcAudioRenderer::GetBufferSize set a %lld period for a %ld buffer size"),*pHnsBufferPeriod,bufferSize);
-
- return S_OK;
+ if (pWaveFormatEx==NULL) return S_OK;
+ if (pWaveFormatEx->cbSize <22) //WAVEFORMATEX
+ return S_OK;
+
+ WAVEFORMATEXTENSIBLE *wfext=(WAVEFORMATEXTENSIBLE*)pWaveFormatEx;
+
+ if (bufferSize==0)
+ if (wfext->SubFormat==KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_MLP)
+ bufferSize=61440;
+ else if (wfext->SubFormat==KSDATAFORMAT_SUBTYPE_IEC61937_DTS_HD)
+ bufferSize=32768;
+ else if (wfext->SubFormat==KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_DIGITAL_PLUS)
+ bufferSize=24576;
+ else if (wfext->Format.wFormatTag==WAVE_FORMAT_DOLBY_AC3_SPDIF)
+ bufferSize=6144;
+ else return S_OK;
+
+ *pHnsBufferPeriod = (REFERENCE_TIME)( (REFERENCE_TIME)bufferSize * 10000 * 8 / ((REFERENCE_TIME)pWaveFormatEx->nChannels * pWaveFormatEx->wBitsPerSample *
+ 1.0 * pWaveFormatEx->nSamplesPerSec) /*+ 0.5*/);
+ *pHnsBufferPeriod *= 1000;
+
+ TRACE(_T("CMpcAudioRenderer::GetBufferSize set a %lld period for a %ld buffer size"),*pHnsBufferPeriod,bufferSize);
+
+ return S_OK;
}
HRESULT CMpcAudioRenderer::InitAudioClient(WAVEFORMATEX *pWaveFormatEx, IAudioClient *pAudioClient, IAudioRenderClient **ppRenderClient)
{
- TRACE(_T("CMpcAudioRenderer::InitAudioClient"));
- HRESULT hr=S_OK;
- // Initialize the stream to play at the minimum latency.
- //if (SUCCEEDED (hr)) hr = pAudioClient->GetDevicePeriod(NULL, &hnsPeriod);
- hnsPeriod=500000; //50 ms is the best according to James @Slysoft
-
- hr = pAudioClient->IsFormatSupported(AUDCLNT_SHAREMODE_EXCLUSIVE, pWaveFormatEx, NULL);
- if (FAILED(hr))
- TRACE(_T("CMpcAudioRenderer::InitAudioClient not supported (0x%08x)"), hr);
- else
- TRACE(_T("CMpcAudioRenderer::InitAudioClient format supported"));
-
- GetBufferSize(pWaveFormatEx, &hnsPeriod);
-
- if (SUCCEEDED (hr)) hr = pAudioClient->Initialize(AUDCLNT_SHAREMODE_EXCLUSIVE,0/*AUDCLNT_STREAMFLAGS_EVENTCALLBACK*/,
- hnsPeriod,hnsPeriod,pWaveFormatEx,NULL);
- if (FAILED (hr) && hr != AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED)
- {
- TRACE(_T("CMpcAudioRenderer::InitAudioClient failed (0x%08x)"), hr);
- return hr;
- }
-
- if (AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED == hr)
- {
- // if the buffer size was not aligned, need to do the alignment dance
- TRACE(_T("CMpcAudioRenderer::InitAudioClient Buffer size not aligned. Realigning"));
-
- // get the buffer size, which will be aligned
- hr = pAudioClient->GetBufferSize(&nFramesInBuffer);
-
- // throw away this IAudioClient
- pAudioClient->Release();pAudioClient=NULL;
-
- // calculate the new aligned periodicity
- hnsPeriod = // hns =
- (REFERENCE_TIME)(
- 10000.0 * // (hns / ms) *
- 1000 * // (ms / s) *
- nFramesInBuffer / // frames /
- pWaveFormatEx->nSamplesPerSec // (frames / s)
- + 0.5 // rounding
- );
-
- if (SUCCEEDED (hr)) hr=CreateAudioClient(pMMDevice, &pAudioClient);
- TRACE(_T("CMpcAudioRenderer::InitAudioClient Trying again with periodicity of %I64u hundred-nanoseconds, or %u frames.\n"), hnsPeriod, nFramesInBuffer);
- if (SUCCEEDED (hr))
- hr = pAudioClient->Initialize(AUDCLNT_SHAREMODE_EXCLUSIVE,0/*AUDCLNT_STREAMFLAGS_EVENTCALLBACK*/,
- hnsPeriod, hnsPeriod, pWaveFormatEx, NULL);
- if (FAILED(hr))
- {
- TRACE(_T("CMpcAudioRenderer::InitAudioClient Failed to reinitialize the audio client"));
- return hr;
- }
- } // if (AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED == hr)
-
- // get the buffer size, which is aligned
- if (SUCCEEDED (hr)) hr = pAudioClient->GetBufferSize(&nFramesInBuffer);
-
- // calculate the new period
- if (SUCCEEDED (hr)) hr = pAudioClient->GetService(__uuidof(IAudioRenderClient), (void**)(ppRenderClient));
-
- if (FAILED (hr))
- TRACE(_T("CMpcAudioRenderer::InitAudioClient service initialization failed (0x%08x)"), hr);
- else
- TRACE(_T("CMpcAudioRenderer::InitAudioClient service initialization success"));
-
- return hr;
+ TRACE(_T("CMpcAudioRenderer::InitAudioClient"));
+ HRESULT hr=S_OK;
+ // Initialize the stream to play at the minimum latency.
+ //if (SUCCEEDED (hr)) hr = pAudioClient->GetDevicePeriod(NULL, &hnsPeriod);
+ hnsPeriod=500000; //50 ms is the best according to James @Slysoft
+
+ hr = pAudioClient->IsFormatSupported(AUDCLNT_SHAREMODE_EXCLUSIVE, pWaveFormatEx, NULL);
+ if (FAILED(hr))
+ TRACE(_T("CMpcAudioRenderer::InitAudioClient not supported (0x%08x)"), hr);
+ else
+ TRACE(_T("CMpcAudioRenderer::InitAudioClient format supported"));
+
+ GetBufferSize(pWaveFormatEx, &hnsPeriod);
+
+ if (SUCCEEDED (hr)) hr = pAudioClient->Initialize(AUDCLNT_SHAREMODE_EXCLUSIVE,0/*AUDCLNT_STREAMFLAGS_EVENTCALLBACK*/,
+ hnsPeriod,hnsPeriod,pWaveFormatEx,NULL);
+ if (FAILED (hr) && hr != AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED)
+ {
+ TRACE(_T("CMpcAudioRenderer::InitAudioClient failed (0x%08x)"), hr);
+ return hr;
+ }
+
+ if (AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED == hr)
+ {
+ // if the buffer size was not aligned, need to do the alignment dance
+ TRACE(_T("CMpcAudioRenderer::InitAudioClient Buffer size not aligned. Realigning"));
+
+ // get the buffer size, which will be aligned
+ hr = pAudioClient->GetBufferSize(&nFramesInBuffer);
+
+ // throw away this IAudioClient
+ pAudioClient->Release();pAudioClient=NULL;
+
+ // calculate the new aligned periodicity
+ hnsPeriod = // hns =
+ (REFERENCE_TIME)(
+ 10000.0 * // (hns / ms) *
+ 1000 * // (ms / s) *
+ nFramesInBuffer / // frames /
+ pWaveFormatEx->nSamplesPerSec // (frames / s)
+ + 0.5 // rounding
+ );
+
+ if (SUCCEEDED (hr)) hr=CreateAudioClient(pMMDevice, &pAudioClient);
+ TRACE(_T("CMpcAudioRenderer::InitAudioClient Trying again with periodicity of %I64u hundred-nanoseconds, or %u frames.\n"), hnsPeriod, nFramesInBuffer);
+ if (SUCCEEDED (hr))
+ hr = pAudioClient->Initialize(AUDCLNT_SHAREMODE_EXCLUSIVE,0/*AUDCLNT_STREAMFLAGS_EVENTCALLBACK*/,
+ hnsPeriod, hnsPeriod, pWaveFormatEx, NULL);
+ if (FAILED(hr))
+ {
+ TRACE(_T("CMpcAudioRenderer::InitAudioClient Failed to reinitialize the audio client"));
+ return hr;
+ }
+ } // if (AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED == hr)
+
+ // get the buffer size, which is aligned
+ if (SUCCEEDED (hr)) hr = pAudioClient->GetBufferSize(&nFramesInBuffer);
+
+ // calculate the new period
+ if (SUCCEEDED (hr)) hr = pAudioClient->GetService(__uuidof(IAudioRenderClient), (void**)(ppRenderClient));
+
+ if (FAILED (hr))
+ TRACE(_T("CMpcAudioRenderer::InitAudioClient service initialization failed (0x%08x)"), hr);
+ else
+ TRACE(_T("CMpcAudioRenderer::InitAudioClient service initialization success"));
+
+ return hr;
}
HRESULT CMpcAudioRenderer::CreateAudioClient(IMMDevice *pMMDevice, IAudioClient **ppAudioClient)
{
- HRESULT hr = S_OK;
- hnsPeriod = 0;
-
- TRACE(_T("CMpcAudioRenderer::CreateAudioClient"));
-
- if (*ppAudioClient)
- {
- if (isAudioClientStarted) (*ppAudioClient)->Stop();
- SAFE_RELEASE(*ppAudioClient);
- isAudioClientStarted=false;
- }
-
- if (pMMDevice==NULL)
- {
- TRACE(_T("CMpcAudioRenderer::CreateAudioClient failed, device not loaded"));
- return E_FAIL;
- }
-
- hr = pMMDevice->Activate(__uuidof(IAudioClient), CLSCTX_ALL, NULL, reinterpret_cast<void**>(ppAudioClient));
- if (FAILED(hr))
- TRACE(_T("CMpcAudioRenderer::CreateAudioClient activation failed (0x%08x)"), hr);
- else
- TRACE(_T("CMpcAudioRenderer::CreateAudioClient success"));
- return hr;
+ HRESULT hr = S_OK;
+ hnsPeriod = 0;
+
+ TRACE(_T("CMpcAudioRenderer::CreateAudioClient"));
+
+ if (*ppAudioClient)
+ {
+ if (isAudioClientStarted) (*ppAudioClient)->Stop();
+ SAFE_RELEASE(*ppAudioClient);
+ isAudioClientStarted=false;
+ }
+
+ if (pMMDevice==NULL)
+ {
+ TRACE(_T("CMpcAudioRenderer::CreateAudioClient failed, device not loaded"));
+ return E_FAIL;
+ }
+
+ hr = pMMDevice->Activate(__uuidof(IAudioClient), CLSCTX_ALL, NULL, reinterpret_cast<void**>(ppAudioClient));
+ if (FAILED(hr))
+ TRACE(_T("CMpcAudioRenderer::CreateAudioClient activation failed (0x%08x)"), hr);
+ else
+ TRACE(_T("CMpcAudioRenderer::CreateAudioClient success"));
+ return hr;
}
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/FIRFilter.cpp b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/FIRFilter.cpp index 159df256d..f17d997ed 100644 --- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/FIRFilter.cpp +++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/FIRFilter.cpp @@ -219,7 +219,7 @@ uint FIRFilter::evaluate(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSample // Operator 'new' is overloaded so that it automatically creates a suitable instance
// depending on if we've a MMX-capable CPU available or not.
-void * FIRFilter::operator new(size_t s)
+void * FIRFilter::operator new(size_t /*s*/)
{
// Notice! don't use "new FIRFilter" directly, use "newInstance" to create a new instance instead!
throw std::runtime_error("Error in FIRFilter::new: Don't use 'new FIRFilter', use 'newInstance' member instead!");
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/RateTransposer.cpp b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/RateTransposer.cpp index 7e0b277d6..49d71ab9d 100644 --- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/RateTransposer.cpp +++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/RateTransposer.cpp @@ -106,7 +106,7 @@ public: // Operator 'new' is overloaded so that it automatically creates a suitable instance
// depending on if we've a MMX/SSE/etc-capable CPU available or not.
-void * RateTransposer::operator new(size_t s)
+void * RateTransposer::operator new(size_t /*s*/)
{
throw runtime_error("Error in RateTransoser::new: don't use \"new TDStretch\" directly, use \"newInstance\" to create a new instance instead!");
return NULL;
@@ -417,7 +417,7 @@ uint RateTransposerInteger::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE *sr // now always (iSlopeCount > SCALE)
iSlopeCount -= SCALE;
- while (1)
+ while (TRUE)
{
while (iSlopeCount > SCALE)
{
@@ -467,7 +467,7 @@ uint RateTransposerInteger::transposeStereo(SAMPLETYPE *dest, const SAMPLETYPE * // now always (iSlopeCount > SCALE)
iSlopeCount -= SCALE;
- while (1)
+ while (TRUE)
{
while (iSlopeCount > SCALE)
{
@@ -554,7 +554,7 @@ uint RateTransposerFloat::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE *src, if (nSamples > 1)
{
- while (1)
+ while (TRUE)
{
while (fSlopeCount > 1.0f)
{
@@ -600,7 +600,7 @@ uint RateTransposerFloat::transposeStereo(SAMPLETYPE *dest, const SAMPLETYPE *sr if (nSamples > 1)
{
- while (1)
+ while (TRUE)
{
while (fSlopeCount > 1.0f)
{
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/TDStretch.cpp b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/TDStretch.cpp index 062524c84..6dea5f516 100644 --- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/TDStretch.cpp +++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/TDStretch.cpp @@ -737,7 +737,7 @@ void TDStretch::acceptNewOverlapLength(int newOverlapLength) // Operator 'new' is overloaded so that it automatically creates a suitable instance
// depending on if we've a MMX/SSE/etc-capable CPU available or not.
-void * TDStretch::operator new(size_t s)
+void * TDStretch::operator new(size_t /*s*/)
{
// Notice! don't use "new TDStretch" directly, use "newInstance" to create a new instance instead!
throw std::runtime_error("Error in TDStretch::new: Don't use 'new TDStretch' directly, use 'newInstance' member instead!");
@@ -849,8 +849,8 @@ void TDStretch::overlapStereo(short *poutput, const short *input) const {
temp = (short)(overlapLength - i);
cnt2 = 2 * i;
- poutput[cnt2] = (input[cnt2] * i + pMidBuffer[cnt2] * temp ) / overlapLength;
- poutput[cnt2 + 1] = (input[cnt2 + 1] * i + pMidBuffer[cnt2 + 1] * temp ) / overlapLength;
+ poutput[cnt2] = (short)((input[cnt2] * i + pMidBuffer[cnt2] * temp ) / overlapLength);
+ poutput[cnt2 + 1] = (short)((input[cnt2 + 1] * i + pMidBuffer[cnt2 + 1] * temp ) / overlapLength);
}
}
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/mmx_optimized.cpp b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/mmx_optimized.cpp index 539ee57c8..2740617a0 100644 --- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/mmx_optimized.cpp +++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/mmx_optimized.cpp @@ -162,7 +162,7 @@ void TDStretchMMX::overlapStereo(short *output, const short *input) const // mix1 = mixer values for 2nd stereo sample
// adder = adder for updating mixer values after each round
- mix1 = _mm_set_pi16(0, overlapLength, 0, overlapLength);
+ mix1 = _mm_set_pi16(0, (short)overlapLength, 0, (short)overlapLength);
adder = _mm_set_pi16(1, -1, 1, -1);
mix2 = _mm_add_pi16(mix1, adder);
adder = _mm_add_pi16(adder, adder);
diff --git a/src/filters/renderer/VideoRenderers/AllocatorCommon7.cpp b/src/filters/renderer/VideoRenderers/AllocatorCommon7.cpp index f094311dd..fdff20133 100644 --- a/src/filters/renderer/VideoRenderers/AllocatorCommon7.cpp +++ b/src/filters/renderer/VideoRenderers/AllocatorCommon7.cpp @@ -50,7 +50,7 @@ HRESULT CreateAP7(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppA *ppAP = NULL;
- HRESULT hr;
+ HRESULT hr = S_OK;
if(clsid == CLSID_VMR7AllocatorPresenter && !(*ppAP = DNew CVMR7AllocatorPresenter(hWnd, hr))
|| clsid == CLSID_RM7AllocatorPresenter && !(*ppAP = DNew CRM7AllocatorPresenter(hWnd, hr))
|| clsid == CLSID_QT7AllocatorPresenter && !(*ppAP = DNew CQT7AllocatorPresenter(hWnd, hr)))
diff --git a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp index 9d6122cd2..f126c8f6d 100644 --- a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp @@ -122,49 +122,43 @@ static HRESULT TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[4] HRESULT hr;
- do
- {
- hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
-
- for(int i = 0; i < texcoords; i++)
- {
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_MAGFILTER, filter);
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_MINFILTER, filter);
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_MIPFILTER, filter);
-
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
- }
+ hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
+ hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
+
+ for(int i = 0; i < texcoords; i++)
+ {
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_MAGFILTER, filter);
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_MINFILTER, filter);
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_MIPFILTER, filter);
- //
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
+ }
- hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | FVF);
- // hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, v, sizeof(v[0]));
+ //
- MYD3DVERTEX<texcoords> tmp = v[2];
- v[2] = v[3];
- v[3] = tmp;
- hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
+ hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | FVF);
+ // hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, v, sizeof(v[0]));
- //
+ MYD3DVERTEX<texcoords> tmp = v[2];
+ v[2] = v[3];
+ v[3] = tmp;
+ hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
- for(int i = 0; i < texcoords; i++)
- {
- pD3DDev->SetTexture(i, NULL);
- }
+ //
- return S_OK;
- }
- while(0);
+ for(int i = 0; i < texcoords; i++)
+ {
+ pD3DDev->SetTexture(i, NULL);
+ }
- return E_FAIL;
+ return S_OK;
}
static HRESULT DrawRect(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<0> v[4])
@@ -172,35 +166,29 @@ static HRESULT DrawRect(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<0> v[4]) if(!pD3DDev)
return E_POINTER;
- do
- {
- HRESULT hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- hr = pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- hr = pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
- //D3DRS_COLORVERTEX
- hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+ HRESULT hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
+ hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ hr = pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+ hr = pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
+ //D3DRS_COLORVERTEX
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
+ hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
- hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX0 | D3DFVF_DIFFUSE);
- // hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, v, sizeof(v[0]));
+ hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX0 | D3DFVF_DIFFUSE);
+ // hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, v, sizeof(v[0]));
- MYD3DVERTEX<0> tmp = v[2];
- v[2] = v[3];
- v[3] = tmp;
- hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
+ MYD3DVERTEX<0> tmp = v[2];
+ v[2] = v[3];
+ v[3] = tmp;
+ hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
- return S_OK;
- }
- while(0);
-
- return E_FAIL;
+ return S_OK;
}
using namespace DSObjects;
@@ -928,7 +916,7 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error) return E_UNEXPECTED;
}
- HRESULT hr;
+ HRESULT hr = S_OK;
m_CurrentAdapter = GetAdapter(m_pD3D);
/* // TODO : add nVidia PerfHUD !!!
@@ -1738,7 +1726,7 @@ HRESULT CDX9AllocatorPresenter::TextureResizeBicubic2pass(IDirect3DTexture9* pTe // The 2 pass sampler is incorrect in that it only does bilinear resampling in the y direction.
return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
- HRESULT hr;
+ /*HRESULT hr;
// rotated?
if(dst[0].z != dst[1].z || dst[2].z != dst[3].z || dst[0].z != dst[3].z
@@ -1853,7 +1841,7 @@ HRESULT CDX9AllocatorPresenter::TextureResizeBicubic2pass(IDirect3DTexture9* pTe m_pD3DDev->SetPixelShader(NULL);
- return hr;
+ return hr;*/
}
HRESULT CDX9AllocatorPresenter::AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9* pTexture)
@@ -1997,7 +1985,7 @@ void CDX9AllocatorPresenter::CalculateJitter(LONGLONG PerfCounter) bool CDX9AllocatorPresenter::GetVBlank(int &_ScanLine, int &_bInVBlank, bool _bMeasureTime)
{
- LONGLONG llPerf;
+ LONGLONG llPerf = 0;
if (_bMeasureTime)
llPerf = GetRenderersData()->GetPerfCounter();
@@ -2060,7 +2048,7 @@ bool CDX9AllocatorPresenter::WaitForVBlankRange(int &_RasterStart, int _RasterSi bool bWaited = false;
int ScanLine = 0;
int InVBlank = 0;
- LONGLONG llPerf;
+ LONGLONG llPerf = 0;
if (_bMeasure)
llPerf = GetRenderersData()->GetPerfCounter();
GetVBlank(ScanLine, InVBlank, _bMeasure);
@@ -2162,7 +2150,7 @@ bool CDX9AllocatorPresenter::WaitForVBlankRange(int &_RasterStart, int _RasterSi ScanLineDiffLock += m_ScreenSize.cy;
int LastLineDiffLock = ScanLineDiffLock;
- LONGLONG llPerfLock;
+ LONGLONG llPerfLock = 0;
while (1)
{
diff --git a/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp index eb92698e9..adfaba25c 100644 --- a/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp @@ -1549,6 +1549,7 @@ STDMETHODIMP CEVRAllocatorPresenter::GetVideoService(HANDLE hDevice, REFIID riid else if (riid == __uuidof(IDirectXVideoProcessorService))
{
IDirectXVideoProcessorService* pDXVAProcessor = (IDirectXVideoProcessorService*) *ppService;
+ UNUSED_ALWAYS(pDXVAProcessor);
}
return hr;
@@ -1609,7 +1610,7 @@ STDMETHODIMP CEVRAllocatorPresenter::InitializeDevice(AM_MEDIA_TYPE* pMediaType) DWORD WINAPI CEVRAllocatorPresenter::GetMixerThreadStatic(LPVOID lpParam)
{
- SetThreadName(-1, "CEVRPresenter::MixerThread");
+ SetThreadName((DWORD)-1, "CEVRPresenter::MixerThread");
CEVRAllocatorPresenter* pThis = (CEVRAllocatorPresenter*) lpParam;
pThis->GetMixerThread();
return 0;
@@ -1618,7 +1619,7 @@ DWORD WINAPI CEVRAllocatorPresenter::GetMixerThreadStatic(LPVOID lpParam) DWORD WINAPI CEVRAllocatorPresenter::PresentThread(LPVOID lpParam)
{
- SetThreadName(-1, "CEVRPresenter::PresentThread");
+ SetThreadName((DWORD)-1, "CEVRPresenter::PresentThread");
CEVRAllocatorPresenter* pThis = (CEVRAllocatorPresenter*) lpParam;
pThis->RenderThread();
return 0;
@@ -1652,13 +1653,13 @@ bool ExtractInterlaced(const AM_MEDIA_TYPE* pmt) void CEVRAllocatorPresenter::GetMixerThread()
{
- HANDLE hAvrt;
+ //HANDLE hAvrt;
HANDLE hEvts[] = { m_hEvtQuit};
bool bQuit = false;
TIMECAPS tc;
DWORD dwResolution;
DWORD dwUser = 0;
- DWORD dwTaskIndex = 0;
+ //DWORD dwTaskIndex = 0;
// Tell Vista Multimedia Class Scheduler we are a playback thretad (increase priority)
// if (pfAvSetMmThreadCharacteristicsW)
@@ -1765,6 +1766,7 @@ LONGLONG CEVRAllocatorPresenter::GetClockTime(LONGLONG PerformanceCounter) double TimeChange = llPerf - m_ModeratedTimeLast;
double ClockChange = llClockTime - m_ModeratedClockLast;
+ UNUSED_ALWAYS(ClockChange);
m_ModeratedTimeLast = llPerf;
m_ModeratedClockLast = llClockTime;
@@ -1999,8 +2001,6 @@ STDMETHODIMP_(bool) CEVRAllocatorPresenter::ResetDevice() void CEVRAllocatorPresenter::RenderThread()
{
- HANDLE hAvrt;
- DWORD dwTaskIndex = 0;
HANDLE hEvts[] = { m_hEvtQuit, m_hEvtFlush};
bool bQuit = false;
TIMECAPS tc;
@@ -2012,8 +2012,14 @@ void CEVRAllocatorPresenter::RenderThread() // Tell Vista Multimedia Class Scheduler we are a playback thretad (increase priority)
- if (pfAvSetMmThreadCharacteristicsW) hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
- if (pfAvSetMmThreadPriority) pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
+ HANDLE hAvrt = 0;
+ if (pfAvSetMmThreadCharacteristicsW)
+ {
+ DWORD dwTaskIndex = 0;
+ hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
+ if (pfAvSetMmThreadPriority)
+ pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
+ }
timeGetDevCaps(&tc, sizeof(TIMECAPS));
dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
@@ -2024,6 +2030,7 @@ void CEVRAllocatorPresenter::RenderThread() while (!bQuit)
{
LONGLONG llPerf = GetRenderersData()->GetPerfCounter();
+ UNUSED_ALWAYS(llPerf);
if (!s.m_RenderSettings.iVMR9VSyncAccurate && NextSleepTime == 0)
NextSleepTime = 1;
dwObject = WaitForMultipleObjects (countof(hEvts), hEvts, FALSE, max(NextSleepTime < 0 ? 1 : NextSleepTime, 0));
@@ -2070,7 +2077,8 @@ void CEVRAllocatorPresenter::RenderThread() // if (WaitForMultipleObjects (countof(hEvtsBuff), hEvtsBuff, FALSE, INFINITE) == WAIT_OBJECT_0+2)
{
CComPtr<IMFSample> pMFSample;
- LONGLONG llPerf = GetRenderersData()->GetPerfCounter();
+ LONGLONG llPerf = GetRenderersData()->GetPerfCounter();
+ UNUSED_ALWAYS(llPerf);
int nSamplesLeft = 0;
if (SUCCEEDED (GetScheduledSample(&pMFSample, nSamplesLeft)))
{
@@ -2481,7 +2489,8 @@ void CEVRAllocatorPresenter::MoveToScheduledList(IMFSample* pSample, bool _bSort // double ForceFPS = 23.976;
if (ForceFPS != 0.0)
m_rtTimePerFrame = 10000000.0 / ForceFPS;
- LONGLONG Duration = m_rtTimePerFrame;
+ LONGLONG Duration = m_rtTimePerFrame;
+ UNUSED_ALWAYS(Duration);
LONGLONG PrevTime = m_LastScheduledUncorrectedSampleTime;
LONGLONG Time;
LONGLONG SetDuration;
diff --git a/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.cpp index 451c5b2e0..324dad529 100644 --- a/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.cpp @@ -113,8 +113,8 @@ STDMETHODIMP CQT7AllocatorPresenter::DoBlt(const BITMAP& bm) if(FAILED(m_pVideoSurfaceOff->GetSurfaceDesc(&ddsd)))
return E_FAIL;
- int w = bm.bmWidth;
- int h = abs(bm.bmHeight);
+ UINT w = (UINT)bm.bmWidth;
+ UINT h = abs(bm.bmHeight);
int bpp = bm.bmBitsPixel;
if((bpp == 16 || bpp == 24 || bpp == 32) && w == ddsd.dwWidth && h == ddsd.dwHeight)
diff --git a/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.cpp index 115f5b4a3..ac2957308 100644 --- a/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.cpp @@ -88,8 +88,8 @@ STDMETHODIMP CQT9AllocatorPresenter::DoBlt(const BITMAP& bm) if(FAILED(m_pVideoSurfaceOff->GetDesc(&d3dsd)))
return E_FAIL;
- int w = bm.bmWidth;
- int h = abs(bm.bmHeight);
+ UINT w = (UINT)bm.bmWidth;
+ UINT h = abs(bm.bmHeight);
int bpp = bm.bmBitsPixel;
int dbpp =
d3dsd.Format == D3DFMT_R8G8B8 || d3dsd.Format == D3DFMT_X8R8G8B8 || d3dsd.Format == D3DFMT_A8R8G8B8 ? 32 :
diff --git a/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp index 272ea2f1f..ec6e36650 100644 --- a/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp @@ -160,6 +160,8 @@ STDMETHODIMP CRM7AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* DWORD w = pBitmapInfo->biWidth;
DWORD h = abs(pBitmapInfo->biHeight);
DWORD pitch = pBitmapInfo->biWidth*2;
+ UNUSED_ALWAYS(w);
+ UNUSED_ALWAYS(h);
BYTE* yvyu = pImageData + src.top*pitch + src.left*2;
@@ -190,6 +192,8 @@ STDMETHODIMP CRM7AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* DWORD w = pBitmapInfo->biWidth;
DWORD h = abs(pBitmapInfo->biHeight);
DWORD pitch = pBitmapInfo->biWidth*pBitmapInfo->biBitCount>>3;
+ UNUSED_ALWAYS(w);
+ UNUSED_ALWAYS(h);
BYTE* rgb = pImageData + src.top*pitch + src.left*(pBitmapInfo->biBitCount>>3);
diff --git a/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.cpp index 7d5c25795..8681d5c9d 100644 --- a/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.cpp @@ -139,7 +139,9 @@ STDMETHODIMP CRM9AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* {
DWORD w = pBitmapInfo->biWidth;
DWORD h = abs(pBitmapInfo->biHeight);
- DWORD pitch = pBitmapInfo->biWidth*2;
+ DWORD pitch = pBitmapInfo->biWidth*2;
+ UNUSED_ALWAYS(w);
+ UNUSED_ALWAYS(h);
BYTE* yvyu = pImageData + src.top*pitch + src.left*2;
@@ -169,7 +171,9 @@ STDMETHODIMP CRM9AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* {
DWORD w = pBitmapInfo->biWidth;
DWORD h = abs(pBitmapInfo->biHeight);
- DWORD pitch = pBitmapInfo->biWidth*pBitmapInfo->biBitCount>>3;
+ DWORD pitch = pBitmapInfo->biWidth*pBitmapInfo->biBitCount>>3;
+ UNUSED_ALWAYS(w);
+ UNUSED_ALWAYS(h);
BYTE* rgb = pImageData + src.top*pitch + src.left*(pBitmapInfo->biBitCount>>3);
diff --git a/src/filters/renderer/VideoRenderers/SyncRenderer.cpp b/src/filters/renderer/VideoRenderers/SyncRenderer.cpp index 9ff989588..3806759c0 100644 --- a/src/filters/renderer/VideoRenderers/SyncRenderer.cpp +++ b/src/filters/renderer/VideoRenderers/SyncRenderer.cpp @@ -347,75 +347,65 @@ HRESULT CBaseAP::TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[ return E_FAIL;
}
- HRESULT hr;
- do
- {
- hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
-
- for(int i = 0; i < texcoords; i++)
- {
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_MAGFILTER, filter);
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_MINFILTER, filter);
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_MIPFILTER, filter);
+ HRESULT hr;
+ hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
+ hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
+
+ for(int i = 0; i < texcoords; i++)
+ {
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_MAGFILTER, filter);
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_MINFILTER, filter);
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_MIPFILTER, filter);
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
- }
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
+ }
- hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | FVF);
+ hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | FVF);
- MYD3DVERTEX<texcoords> tmp = v[2];
- v[2] = v[3];
- v[3] = tmp;
- hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
+ MYD3DVERTEX<texcoords> tmp = v[2];
+ v[2] = v[3];
+ v[3] = tmp;
+ hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
- for(int i = 0; i < texcoords; i++)
- {
- pD3DDev->SetTexture(i, NULL);
- }
+ for(int i = 0; i < texcoords; i++)
+ {
+ pD3DDev->SetTexture(i, NULL);
+ }
- return S_OK;
- }
- while(0);
- return E_FAIL;
+ return S_OK;
}
HRESULT CBaseAP::DrawRectBase(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<0> v[4])
{
if(!pD3DDev) return E_POINTER;
- do
- {
- HRESULT hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- hr = pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- hr = pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+ HRESULT hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
+ hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ hr = pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+ hr = pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
+ hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
- hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX0 | D3DFVF_DIFFUSE);
+ hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX0 | D3DFVF_DIFFUSE);
- MYD3DVERTEX<0> tmp = v[2];
- v[2] = v[3];
- v[3] = tmp;
- hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
+ MYD3DVERTEX<0> tmp = v[2];
+ v[2] = v[3];
+ v[3] = tmp;
+ hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
- return S_OK;
- }
- while(0);
- return E_FAIL;
+ return S_OK;
}
MFOffset CBaseAP::GetOffset(float v)
@@ -1440,7 +1430,7 @@ HRESULT CBaseAP::TextureResizeBicubic2pass(IDirect3DTexture9* pTexture, Vector d // The 2 pass sampler is incorrect in that it only does bilinear resampling in the y direction.
return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
- HRESULT hr;
+ /*HRESULT hr;
// rotated?
if(dst[0].z != dst[1].z || dst[2].z != dst[3].z || dst[0].z != dst[3].z
@@ -1517,7 +1507,7 @@ HRESULT CBaseAP::TextureResizeBicubic2pass(IDirect3DTexture9* pTexture, Vector d hr = m_pD3DDev->SetRenderTarget(0, pRTOld);
hr = TextureBlt(m_pD3DDev, vy, D3DTEXF_POINT);
m_pD3DDev->SetPixelShader(NULL);
- return hr;
+ return hr;*/
}
HRESULT CBaseAP::AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9* pTexture)
@@ -3699,8 +3689,6 @@ DWORD WINAPI CSyncAP::RenderThreadStatic(LPVOID lpParam) // Get samples that have been received and queued up by MixerThread() and present them at the correct time by calling Paint().
void CSyncAP::RenderThread()
{
- HANDLE hAvrt;
- DWORD dwTaskIndex = 0;
HANDLE hEvts[] = {m_hEvtQuit, m_hEvtFlush, m_hEvtSkip};
bool bQuit = false;
TIMECAPS tc;
@@ -3714,8 +3702,13 @@ void CSyncAP::RenderThread() CComPtr<IMFSample>pNewSample = NULL; // The sample next in line to be presented
// Tell Vista Multimedia Class Scheduler we are doing threaded playback (increase priority)
- if (pfAvSetMmThreadCharacteristicsW) hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
- if (pfAvSetMmThreadPriority) pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH);
+ HANDLE hAvrt = 0;
+ if (pfAvSetMmThreadCharacteristicsW)
+ {
+ DWORD dwTaskIndex = 0;
+ hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
+ if (pfAvSetMmThreadPriority) pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH);
+ }
// Set timer resolution
timeGetDevCaps(&tc, sizeof(TIMECAPS));
@@ -4460,7 +4453,6 @@ HRESULT CGenlock::ResetClock() adjDelta = 0;
if (syncClock == NULL) return E_FAIL;
else return syncClock->AdjustClock(1.0);
- return S_OK;
}
HRESULT CGenlock::SetTargetSyncOffset(DOUBLE targetD)
diff --git a/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.cpp index a450fdc32..d43b4f3ce 100644 --- a/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.cpp @@ -195,7 +195,7 @@ STDMETHODIMP CVMR7AllocatorPresenter::FreeSurface(DWORD_PTR dwUserID) STDMETHODIMP CVMR7AllocatorPresenter::PrepareSurface(DWORD_PTR dwUserID, IDirectDrawSurface7* lpSurface, DWORD dwSurfaceFlags)
{
- SetThreadName(-1, "CVMR7AllocatorPresenter");
+ SetThreadName((DWORD)-1, "CVMR7AllocatorPresenter");
if(!lpSurface)
return E_POINTER;
diff --git a/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp index a1a9975be..da879d0ff 100644 --- a/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp @@ -459,8 +459,8 @@ public: *pHeight = s.Height();
return hr;
}
- */
- return E_NOTIMPL;
+ return E_NOTIMPL;
+ */
}
STDMETHODIMP SetDefaultSourcePosition()
{
@@ -773,7 +773,7 @@ STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9A hr = m_pD3DDev->ColorFill(m_pVideoSurface[m_nCurSurface], NULL, 0);
- if (m_nVMR9Surfaces && m_nVMR9Surfaces != *lpNumBuffers)
+ if (m_nVMR9Surfaces && m_nVMR9Surfaces != (int)*lpNumBuffers)
m_nVMR9Surfaces = *lpNumBuffers;
*lpNumBuffers = min(nOriginal, *lpNumBuffers);
m_iVMR9Surface = 0;
@@ -850,7 +850,7 @@ STDMETHODIMP CVMR9AllocatorPresenter::StopPresenting(DWORD_PTR dwUserID) STDMETHODIMP CVMR9AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMR9PresentationInfo* lpPresInfo)
{
- SetThreadName(-1, "CVMR9AllocatorPresenter");
+ SetThreadName((DWORD)-1, "CVMR9AllocatorPresenter");
CheckPointer(m_pIVMRSurfAllocNotify, E_UNEXPECTED);
if (m_rtTimePerFrame == 0 || m_bNeedCheckSample)
|