Skip to content

Commit

Permalink
[AE] Additional crash protection when HDMI device removed
Browse files Browse the repository at this point in the history
  • Loading branch information
DDDamian committed May 17, 2012
1 parent a064690 commit 3450c8a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp
Expand Up @@ -337,8 +337,10 @@ double CAESinkWASAPI::GetDelay()
hr = m_pAudioClient->GetBufferSize(&m_uiBufferLen); hr = m_pAudioClient->GetBufferSize(&m_uiBufferLen);
if (FAILED(hr)) if (FAILED(hr))
{ {
#ifdef _DEBUG
CLog::Log(LOGERROR, __FUNCTION__": GetBufferSize Failed : %s", WASAPIErrToStr(hr)); CLog::Log(LOGERROR, __FUNCTION__": GetBufferSize Failed : %s", WASAPIErrToStr(hr));
return false; #endif
return 0.0;
} }
return (double)m_uiBufferLen / (double)m_format.m_sampleRate; return (double)m_uiBufferLen / (double)m_format.m_sampleRate;
} }
Expand Down Expand Up @@ -389,14 +391,18 @@ unsigned int CAESinkWASAPI::AddPackets(uint8_t *data, unsigned int frames)
hr = m_pRenderClient->GetBuffer(NumFramesRequested, &buf); hr = m_pRenderClient->GetBuffer(NumFramesRequested, &buf);
if (FAILED(hr)) if (FAILED(hr))
{ {
#ifdef _DEBUG
CLog::Log(LOGERROR, __FUNCTION__": GetBuffer failed due to %s", WASAPIErrToStr(hr)); CLog::Log(LOGERROR, __FUNCTION__": GetBuffer failed due to %s", WASAPIErrToStr(hr));
#endif
return 0; return 0;
} }
memcpy(buf, data, NumFramesRequested * m_format.m_frameSize); //fill buffer memcpy(buf, data, NumFramesRequested * m_format.m_frameSize); //fill buffer
hr = m_pRenderClient->ReleaseBuffer(NumFramesRequested, flags); //pass back to audio driver hr = m_pRenderClient->ReleaseBuffer(NumFramesRequested, flags); //pass back to audio driver
if (FAILED(hr)) if (FAILED(hr))
{ {
#ifdef _DEBUG
CLog::Log(LOGDEBUG, __FUNCTION__": ReleaseBuffer failed due to %s.", WASAPIErrToStr(hr)); CLog::Log(LOGDEBUG, __FUNCTION__": ReleaseBuffer failed due to %s.", WASAPIErrToStr(hr));
#endif
return 0; return 0;
} }
hr = m_pAudioClient->Start(); //start the audio driver running hr = m_pAudioClient->Start(); //start the audio driver running
Expand Down Expand Up @@ -439,7 +445,7 @@ unsigned int CAESinkWASAPI::AddPackets(uint8_t *data, unsigned int frames)
hr = m_pRenderClient->GetBuffer(NumFramesRequested, &buf); hr = m_pRenderClient->GetBuffer(NumFramesRequested, &buf);
if (FAILED(hr)) if (FAILED(hr))
{ {
#ifndef _DEBUG #ifdef _DEBUG
CLog::Log(LOGERROR, __FUNCTION__": GetBuffer failed due to %s", WASAPIErrToStr(hr)); CLog::Log(LOGERROR, __FUNCTION__": GetBuffer failed due to %s", WASAPIErrToStr(hr));
#endif #endif
return 0; return 0;
Expand All @@ -448,7 +454,7 @@ unsigned int CAESinkWASAPI::AddPackets(uint8_t *data, unsigned int frames)
hr = m_pRenderClient->ReleaseBuffer(NumFramesRequested, flags); //pass back to audio driver hr = m_pRenderClient->ReleaseBuffer(NumFramesRequested, flags); //pass back to audio driver
if (FAILED(hr)) if (FAILED(hr))
{ {
#ifndef _DEBUG #ifdef _DEBUG
CLog::Log(LOGDEBUG, __FUNCTION__": ReleaseBuffer failed due to %s.", WASAPIErrToStr(hr)); CLog::Log(LOGDEBUG, __FUNCTION__": ReleaseBuffer failed due to %s.", WASAPIErrToStr(hr));
#endif #endif
return 0; return 0;
Expand Down

0 comments on commit 3450c8a

Please sign in to comment.