Permalink
Browse files

[AE] [DirectSound] Work around AE initializing before window created …

…and no window handle existing. Fixes start-up failure of DS until sink is re-opened at next init and correct window handle is supplied.
  • Loading branch information...
1 parent 70c52cf commit 3f5353a9a7eb1ea1676fe77c913f10197e2bbbd9 @DDDamian DDDamian committed May 19, 2012
Showing with 11 additions and 1 deletion.
  1. +11 −1 xbmc/cores/AudioEngine/Sinks/AESinkDirectSound.cpp
@@ -158,7 +158,17 @@ bool CAESinkDirectSound::Initialize(AEAudioFormat &format, std::string &device)
return false;
}
- hr = m_pDSound->SetCooperativeLevel(g_hWnd, DSSCL_PRIORITY);
+ HWND tmp_hWnd;
+
+ /* Dodge the null handle on first init by using desktop handle */
+ if (g_hWnd == NULL)
+ tmp_hWnd = GetDesktopWindow();
+ else
+ tmp_hWnd = g_hWnd;
+
+ CLog::Log(LOGDEBUG, __FUNCTION__": Using Window handle: %d", tmp_hWnd);
+
+ hr = m_pDSound->SetCooperativeLevel(tmp_hWnd, DSSCL_PRIORITY);
if (FAILED(hr))
{

0 comments on commit 3f5353a

Please sign in to comment.