Advertisement
Guest User

Untitled

a guest
Mar 15th, 2012
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.76 KB | None | 0 0
  1. diff --git a/xbmc/cores/AudioRenderers/Win32WASAPI.cpp b/xbmc/cores/AudioRenderers/Win32WASAPI.cpp
  2. index 7befc28..7d2b3c9 100644
  3. --- a/xbmc/cores/AudioRenderers/Win32WASAPI.cpp
  4. +++ b/xbmc/cores/AudioRenderers/Win32WASAPI.cpp
  5. @@ -398,7 +398,9 @@ bool CWin32WASAPI::Resume()
  6.  
  7.    m_bPause = false;
  8.  
  9. -  UpdateCacheStatus();
  10. +  if (!UpdateCacheStatus())
  11. +    return false;
  12. +
  13.    if(m_CacheLen >= m_PreCacheSize) // Make sure we have some data to play (if not, playback will start when we add some)
  14.    {
  15.      HRESULT hr = m_pAudioClient->Start();
  16. @@ -492,7 +494,8 @@ unsigned int CWin32WASAPI::AddPackets(const void* data, unsigned int len)
  17.    BYTE* pBuffer = NULL;
  18.    HRESULT hr;
  19.  
  20. -  UpdateCacheStatus();
  21. +  if (!UpdateCacheStatus())
  22. +    return 0;
  23.  
  24.    uiBytesToWrite  = std::min(m_uiBufferLen - m_CacheLen, (len / m_uiBytesPerSrcFrame) * m_uiBytesPerFrame);
  25.    uiBytesToWrite /= m_uiChunkSize;
  26. @@ -533,11 +536,11 @@ unsigned int CWin32WASAPI::AddPackets(const void* data, unsigned int len)
  27.    return uiSrcBytesToWrite; // Bytes used
  28.  }
  29.  
  30. -void CWin32WASAPI::UpdateCacheStatus()
  31. +bool CWin32WASAPI::UpdateCacheStatus()
  32.  {
  33.    unsigned int time = XbmcThreads::SystemClockMillis();
  34.    if (time == m_LastCacheCheck)
  35. -    return; // Don't recalc more frequently than once/ms (that is our max resolution anyway)
  36. +    return true; // Don't recalc more frequently than once/ms (that is our max resolution anyway)
  37.  
  38.    m_LastCacheCheck = time;
  39.  
  40. @@ -547,16 +550,19 @@ void CWin32WASAPI::UpdateCacheStatus()
  41.    {
  42.      CLog::Log(LOGERROR, __FUNCTION__": GetCurrentPadding failed (%i)", hr);
  43.      CLOSE_ON_INVALID(hr,)
  44. +
  45.      // On error pretend the buffer is full.
  46.      m_CacheLen = m_uiBufferLen;
  47. +    return false;
  48.    }
  49.    else
  50.    {
  51.      m_CacheLen *= m_uiBytesPerFrame;
  52.    }
  53. +  return true;
  54.  }
  55.  
  56. -void CWin32WASAPI::CheckPlayStatus()
  57. +bool CWin32WASAPI::CheckPlayStatus()
  58.  {
  59.    if(m_Initialized && !m_bPause && !m_bPlaying && m_CacheLen >= m_PreCacheSize) // If we have some data, see if we can start playback
  60.    {
  61. @@ -564,13 +570,14 @@ void CWin32WASAPI::CheckPlayStatus()
  62.      if (FAILED(hr))
  63.      {
  64.        CLog::Log(LOGERROR, __FUNCTION__": Start failed (%i)", hr);
  65. -      CLOSE_ON_INVALID(hr,)
  66. +      CLOSE_ON_INVALID(hr, return false)
  67.      }
  68.      else
  69.      {
  70.         m_bPlaying = true;
  71.      }
  72.    }
  73. +  return true;
  74.  }
  75.  
  76.  unsigned int CWin32WASAPI::GetSpace()
  77. @@ -581,7 +588,8 @@ unsigned int CWin32WASAPI::GetSpace()
  78.      return 0;
  79.  
  80.    // Make sure we know how much data is in the cache
  81. -  UpdateCacheStatus();
  82. +  if (!UpdateCacheStatus())
  83. +    return 0;
  84.  
  85.    return ((m_uiBufferLen - m_CacheLen) / m_uiBytesPerFrame) * m_uiBytesPerSrcFrame;
  86.  }
  87. @@ -595,7 +603,8 @@ float CWin32WASAPI::GetDelay()
  88.      return 0.0f;
  89.  
  90.    // Make sure we know how much data is in the cache
  91. -  UpdateCacheStatus();
  92. +  if (!UpdateCacheStatus())
  93. +    return 0.0f;
  94.  
  95.    return (float)m_CacheLen / (float)m_uiAvgBytesPerSec;
  96.  }
  97. @@ -609,7 +618,8 @@ float CWin32WASAPI::GetCacheTime()
  98.      return 0.0f;
  99.  
  100.    // Make sure we know how much data is in the cache
  101. -  UpdateCacheStatus();
  102. +  if (!UpdateCacheStatus())
  103. +    return 0.0f;
  104.  
  105.    return (float)m_CacheLen / (float)m_uiAvgBytesPerSec;
  106.  }
  107. diff --git a/xbmc/cores/AudioRenderers/Win32WASAPI.h b/xbmc/cores/AudioRenderers/Win32WASAPI.h
  108. index 95d4d88..24471fc 100644
  109. --- a/xbmc/cores/AudioRenderers/Win32WASAPI.h
  110. +++ b/xbmc/cores/AudioRenderers/Win32WASAPI.h
  111. @@ -70,8 +70,8 @@ private:
  112.    bool Initialize();
  113.    bool Close();
  114.    void AddDataToBuffer(unsigned char* pData, unsigned int len, unsigned char* pOut);
  115. -  void UpdateCacheStatus();
  116. -  void CheckPlayStatus();
  117. +  bool UpdateCacheStatus();
  118. +  bool CheckPlayStatus();
  119.    void BuildChannelMapping(int channels, enum PCMChannels* map);
  120.  
  121.    IMMDevice* m_pDevice;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement