PVRWindow CGUIViewStatePVR::GetActiveView() { PVRWindow returnWindow = PVR_WINDOW_UNKNOWN; int iActiveWindow = g_windowManager.GetActiveWindow(); if (iActiveWindow == WINDOW_PVR) { CGUIWindowPVR *pWindow = (CGUIWindowPVR *) g_windowManager.GetWindow(WINDOW_PVR); CGUIWindowPVRCommon *pActiveView = NULL; if (pWindow && (pActiveView = pWindow->GetActiveView()) != NULL) returnWindow = pActiveView->GetWindowId(); } return returnWindow; }
bool CPVRManager::Load(void) { /* start the add-on update thread */ m_addons->Start(); /* load at least one client */ while (GetState() == ManagerStateStarting && m_addons && !m_addons->HasConnectedClients()) Sleep(50); if (GetState() != ManagerStateStarting || !m_addons || !m_addons->HasConnectedClients()) return false; CLog::Log(LOGDEBUG, "PVRManager - %s - active clients found. continue to start", __FUNCTION__); /* load all channels and groups */ ShowProgressDialog(g_localizeStrings.Get(19236), 0); if (!m_channelGroups->Load() || GetState() != ManagerStateStarting) return false; /* get timers from the backends */ ShowProgressDialog(g_localizeStrings.Get(19237), 50); m_timers->Load(); /* get recordings from the backend */ ShowProgressDialog(g_localizeStrings.Get(19238), 75); m_recordings->Load(); CSingleLock lock(m_critSection); if (GetState() != ManagerStateStarting) return false; CGUIWindowPVR *pWindow = (CGUIWindowPVR *) g_windowManager.GetWindow(WINDOW_PVR); if (pWindow) pWindow->Reset(); /* start the other pvr related update threads */ ShowProgressDialog(g_localizeStrings.Get(19239), 85); m_guiInfo->Start(); /* close the progess dialog */ HideProgressDialog(); return true; }
void CPVRManager::Process(void) { /* load the pvr data from the db and clients if it's not already loaded */ if (!Load()) { /* close the busy dialog */ ShowBusyDialog(false); CLog::Log(LOGERROR, "PVRManager - %s - failed to load PVR data", __FUNCTION__); return; } /* reset observers that are observing pvr related data in the pvr windows, or updates won't work after a reload */ CGUIWindowPVR *pWindow = (CGUIWindowPVR *) g_windowManager.GetWindow(WINDOW_PVR); if (pWindow) pWindow->Reset(); /* start the other pvr related update threads */ m_addons->Start(); m_guiInfo->Start(); m_epg->RegisterObserver(this); m_epg->Start(); /* continue last watched channel after first startup */ if (!m_bStop && m_bFirstStart && g_guiSettings.GetInt("pvrplayback.startlast") != START_LAST_CHANNEL_OFF) ContinueLastChannel(); /* close the busy dialog */ ShowBusyDialog(false); /* signal to window that clients are loaded */ if (pWindow) pWindow->UnlockWindow(); /* check whether all channel icons are cached */ m_channelGroups->GetGroupAllRadio()->CacheIcons(); m_channelGroups->GetGroupAllTV()->CacheIcons(); CLog::Log(LOGDEBUG, "PVRManager - %s - entering main loop", __FUNCTION__); /* main loop */ while (!m_bStop) { /* keep trying to load remaining clients if they're not already loaded */ if (!m_addons->AllClientsLoaded()) m_addons->TryLoadClients(1); /* execute the next pending jobs if there are any */ ExecutePendingJobs(); /* check if the (still) are any enabled addons */ if (DisableIfNoClients()) { CLog::Log(LOGNOTICE, "PVRManager - %s - no add-ons enabled. disabling PVR functionality", __FUNCTION__); Stop(); return; } WaitForSingleObject(m_triggerEvent, 1000); } }