xbmc: re-added wait-for-nic-on-wakeup.patch

thanks devkid
This commit is contained in:
Stefan Saraev 2013-08-31 20:05:33 +03:00
parent 3c5c56cc67
commit 47ffb91b52

View File

@ -0,0 +1,60 @@
diff --git a/xbmc/powermanagement/PowerManager.cpp b/xbmc/powermanagement/PowerManager.cpp
index 26d7002..71c4bd4 100644
--- a/xbmc/powermanagement/PowerManager.cpp
+++ b/xbmc/powermanagement/PowerManager.cpp
@@ -23,6 +23,7 @@
#include "Application.h"
#include "cores/AudioEngine/AEFactory.h"
#include "input/KeyboardStat.h"
+#include "network/Network.h"
#include "settings/GUISettings.h"
#include "windowing/WindowingFactory.h"
#include "utils/log.h"
@@ -218,10 +219,34 @@ void CPowerManager::OnSleep()
CAEFactory::Suspend();
}
+void CPowerManager::WaitForNet()
+{
+ CLog::Log(LOGDEBUG, "%s: Waithing for first NIC to come up", __FUNCTION__);
+
+ const unsigned maxLoopCount = 50u;
+ const unsigned sleepTimeMs = 200u;
+
+ for(unsigned i=0; i < 50; ++i)
+ {
+ CNetworkInterface* pIface = g_application.getNetwork().GetFirstConnectedInterface();
+ if (pIface && pIface->IsEnabled() && pIface->IsConnected())
+ {
+ CLog::Log(LOGDEBUG, "%s: NIC is up after waiting %d ms", __FUNCTION__, i * sleepTimeMs);
+ return;
+ }
+
+ Sleep(sleepTimeMs);
+ }
+
+ CLog::Log(LOGDEBUG, "%s: NIC did not come up within %d ms... Lets give up...", __FUNCTION__, maxLoopCount * sleepTimeMs);
+}
+
void CPowerManager::OnWake()
{
CLog::Log(LOGNOTICE, "%s: Running resume jobs", __FUNCTION__);
+ WaitForNet();
+
// reset out timers
g_application.ResetShutdownTimers();
diff --git a/xbmc/powermanagement/PowerManager.h b/xbmc/powermanagement/PowerManager.h
index 0a9183c..714b5cc 100644
--- a/xbmc/powermanagement/PowerManager.h
+++ b/xbmc/powermanagement/PowerManager.h
@@ -72,6 +72,8 @@ private:
void OnLowBattery();
+ void WaitForNet();
+
IPowerSyscall *m_instance;
};