Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/xbmc/cores/AudioRenderers/Win32WASAPI.cpp b/xbmc/cores/AudioRenderers/Win32WASAPI.cpp
- index 7befc28..7d2b3c9 100644
- --- a/xbmc/cores/AudioRenderers/Win32WASAPI.cpp
- +++ b/xbmc/cores/AudioRenderers/Win32WASAPI.cpp
- @@ -398,7 +398,9 @@ bool CWin32WASAPI::Resume()
- m_bPause = false;
- - UpdateCacheStatus();
- + if (!UpdateCacheStatus())
- + return false;
- +
- if(m_CacheLen >= m_PreCacheSize) // Make sure we have some data to play (if not, playback will start when we add some)
- {
- HRESULT hr = m_pAudioClient->Start();
- @@ -492,7 +494,8 @@ unsigned int CWin32WASAPI::AddPackets(const void* data, unsigned int len)
- BYTE* pBuffer = NULL;
- HRESULT hr;
- - UpdateCacheStatus();
- + if (!UpdateCacheStatus())
- + return 0;
- uiBytesToWrite = std::min(m_uiBufferLen - m_CacheLen, (len / m_uiBytesPerSrcFrame) * m_uiBytesPerFrame);
- uiBytesToWrite /= m_uiChunkSize;
- @@ -533,11 +536,11 @@ unsigned int CWin32WASAPI::AddPackets(const void* data, unsigned int len)
- return uiSrcBytesToWrite; // Bytes used
- }
- -void CWin32WASAPI::UpdateCacheStatus()
- +bool CWin32WASAPI::UpdateCacheStatus()
- {
- unsigned int time = XbmcThreads::SystemClockMillis();
- if (time == m_LastCacheCheck)
- - return; // Don't recalc more frequently than once/ms (that is our max resolution anyway)
- + return true; // Don't recalc more frequently than once/ms (that is our max resolution anyway)
- m_LastCacheCheck = time;
- @@ -547,16 +550,19 @@ void CWin32WASAPI::UpdateCacheStatus()
- {
- CLog::Log(LOGERROR, __FUNCTION__": GetCurrentPadding failed (%i)", hr);
- CLOSE_ON_INVALID(hr,)
- +
- // On error pretend the buffer is full.
- m_CacheLen = m_uiBufferLen;
- + return false;
- }
- else
- {
- m_CacheLen *= m_uiBytesPerFrame;
- }
- + return true;
- }
- -void CWin32WASAPI::CheckPlayStatus()
- +bool CWin32WASAPI::CheckPlayStatus()
- {
- if(m_Initialized && !m_bPause && !m_bPlaying && m_CacheLen >= m_PreCacheSize) // If we have some data, see if we can start playback
- {
- @@ -564,13 +570,14 @@ void CWin32WASAPI::CheckPlayStatus()
- if (FAILED(hr))
- {
- CLog::Log(LOGERROR, __FUNCTION__": Start failed (%i)", hr);
- - CLOSE_ON_INVALID(hr,)
- + CLOSE_ON_INVALID(hr, return false)
- }
- else
- {
- m_bPlaying = true;
- }
- }
- + return true;
- }
- unsigned int CWin32WASAPI::GetSpace()
- @@ -581,7 +588,8 @@ unsigned int CWin32WASAPI::GetSpace()
- return 0;
- // Make sure we know how much data is in the cache
- - UpdateCacheStatus();
- + if (!UpdateCacheStatus())
- + return 0;
- return ((m_uiBufferLen - m_CacheLen) / m_uiBytesPerFrame) * m_uiBytesPerSrcFrame;
- }
- @@ -595,7 +603,8 @@ float CWin32WASAPI::GetDelay()
- return 0.0f;
- // Make sure we know how much data is in the cache
- - UpdateCacheStatus();
- + if (!UpdateCacheStatus())
- + return 0.0f;
- return (float)m_CacheLen / (float)m_uiAvgBytesPerSec;
- }
- @@ -609,7 +618,8 @@ float CWin32WASAPI::GetCacheTime()
- return 0.0f;
- // Make sure we know how much data is in the cache
- - UpdateCacheStatus();
- + if (!UpdateCacheStatus())
- + return 0.0f;
- return (float)m_CacheLen / (float)m_uiAvgBytesPerSec;
- }
- diff --git a/xbmc/cores/AudioRenderers/Win32WASAPI.h b/xbmc/cores/AudioRenderers/Win32WASAPI.h
- index 95d4d88..24471fc 100644
- --- a/xbmc/cores/AudioRenderers/Win32WASAPI.h
- +++ b/xbmc/cores/AudioRenderers/Win32WASAPI.h
- @@ -70,8 +70,8 @@ private:
- bool Initialize();
- bool Close();
- void AddDataToBuffer(unsigned char* pData, unsigned int len, unsigned char* pOut);
- - void UpdateCacheStatus();
- - void CheckPlayStatus();
- + bool UpdateCacheStatus();
- + bool CheckPlayStatus();
- void BuildChannelMapping(int channels, enum PCMChannels* map);
- IMMDevice* m_pDevice;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement