Skip to content
This repository
Browse code

[epg] fixed - epg load/update was interrupted when the pvr manager im…

…ports channels, leading to delays and channel ids gone missing in certain situations
  • Loading branch information...
commit bdf8842d543fae54067c4dd453bded8474e1044f 1 parent a2e3fe4
Lars Op den Kamp authored January 05, 2013
6  xbmc/epg/EpgContainer.cpp
@@ -228,6 +228,12 @@ void CEpgContainer::Process(void)
228 228
   bool bUpdateEpg(true);
229 229
   bool bHasPendingUpdates(false);
230 230
 
  231
+  if (!CPVRManager::Get().WaitUntilInitialised())
  232
+  {
  233
+    CLog::Log(LOGDEBUG, "EPG - %s - pvr manager failed to load - exiting", __FUNCTION__);
  234
+    return;
  235
+  }
  236
+
231 237
   while (!m_bStop && !g_application.m_bStop)
232 238
   {
233 239
     CDateTime::GetCurrentDateTime().GetAsUTCDateTime().GetAsTime(iNow);
14  xbmc/pvr/PVRManager.cpp
@@ -180,6 +180,12 @@ bool CPVRManager::UpgradeOutdatedAddons(void)
180 180
   return false;
181 181
 }
182 182
 
  183
+bool CPVRManager::WaitUntilInitialised(void)
  184
+{
  185
+  return m_initialisedEvent.Wait() &&
  186
+      IsStarted();
  187
+}
  188
+
183 189
 void CPVRManager::Cleanup(void)
184 190
 {
185 191
   CSingleLock lock(m_critSection);
@@ -202,6 +208,7 @@ void CPVRManager::Cleanup(void)
202 208
     delete m_pendingUpdates.at(iJobPtr);
203 209
   m_pendingUpdates.clear();
204 210
 
  211
+  m_initialisedEvent.Reset();
205 212
   SetState(ManagerStateStopped);
206 213
 }
207 214
 
@@ -264,6 +271,8 @@ void CPVRManager::Start(bool bAsync /* = false */, bool bOpenPVRWindow /* = fals
264 271
     m_database = new CPVRDatabase;
265 272
   m_database->Open();
266 273
 
  274
+  g_EpgContainer.Start();
  275
+
267 276
   /* create the supervisor thread to do all background activities */
268 277
   StartUpdateThreads();
269 278
 }
@@ -278,6 +287,7 @@ void CPVRManager::Stop(void)
278 287
   SetState(ManagerStateStopping);
279 288
 
280 289
   /* stop the EPG updater, since it might be using the pvr add-ons */
  290
+  m_initialisedEvent.Set();
281 291
   g_EpgContainer.Stop();
282 292
 
283 293
   CLog::Log(LOGNOTICE, "PVRManager - stopping");
@@ -317,8 +327,6 @@ void CPVRManager::SetState(ManagerState state)
317 327
 
318 328
 void CPVRManager::Process(void)
319 329
 {
320  
-  g_EpgContainer.Stop();
321  
-
322 330
   /* load the pvr data from the db and clients if it's not already loaded */
323 331
   while (!Load() && GetState() == ManagerStateStarting)
324 332
   {
@@ -336,7 +344,7 @@ void CPVRManager::Process(void)
336 344
 
337 345
   /* main loop */
338 346
   CLog::Log(LOGDEBUG, "PVRManager - %s - entering main loop", __FUNCTION__);
339  
-  g_EpgContainer.Start();
  347
+  m_initialisedEvent.Set();
340 348
 
341 349
   if (m_bOpenPVRWindow)
342 350
   {
7  xbmc/pvr/PVRManager.h
@@ -467,6 +467,12 @@ namespace PVR
467 467
      */
468 468
     bool SetWakeupCommand(void);
469 469
 
  470
+    /*!
  471
+     * @brief Wait until the pvr manager is loaded
  472
+     * @return True when loaded, false otherwise
  473
+     */
  474
+    bool WaitUntilInitialised(void);
  475
+
470 476
   protected:
471 477
     /*!
472 478
      * @brief PVR update and control thread.
@@ -575,6 +581,7 @@ namespace PVR
575 581
     CStopWatch                     *m_parentalTimer;
576 582
     bool                            m_bOpenPVRWindow;
577 583
     std::map<std::string, std::string> m_outdatedAddons;
  584
+    CEvent                             m_initialisedEvent;         /*!< triggered when the pvr manager initialised */
578 585
   };
579 586
 
580 587
   class CPVRRecordingsUpdateJob : public CJob

2 notes on commit bdf8842

Dimitris Kazakos

This one is in direct conflict with the logic proposed in PR #1994 and still leads to a lot of waiting for the PVR Views to be available.
I think it's worth considering taking a look at it, works wonders in my setup :)

Lars Op den Kamp
Collaborator

as i already commented on that PR, only necessary and minor changes until frodo. this one was necessary because channel IDs weren't assigned to epg tables properly, leading to errors when scheduling recordings.

Please sign in to comment.
Something went wrong with that request. Please try again.