Advertisement
Guest User

PhracturedBlue

a guest
Nov 6th, 2010
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.35 KB | None | 0 0
  1. Index: xbmc/FileSystem/MythDirectory.cpp
  2. ===================================================================
  3. --- xbmc/FileSystem/MythDirectory.cpp.orig 2010-11-03 19:41:04.000000000 -0700
  4. +++ xbmc/FileSystem/MythDirectory.cpp 2010-11-03 20:03:48.000000000 -0700
  5. @@ -239,11 +239,7 @@
  6. bool CMythDirectory::GetRecordings(const CStdString& base, CFileItemList &items, enum FilterType type,
  7. const CStdString& filter)
  8. {
  9. - cmyth_conn_t control = m_session->GetControl();
  10. - if (!control)
  11. - return false;
  12. -
  13. - cmyth_proglist_t list = m_dll->proglist_get_all_recorded(control);
  14. + cmyth_proglist_t list = m_session->GetRecordingList();
  15. if (!list)
  16. {
  17. CLog::Log(LOGERROR, "%s - unable to get list of recordings", __FUNCTION__);
  18. @@ -339,7 +335,6 @@
  19. }
  20. items.AddSortMethod(SORT_METHOD_DATE, 552 /* Date */, LABEL_MASKS("%K", "%J"));
  21.  
  22. - m_dll->ref_release(list);
  23. return true;
  24. }
  25.  
  26. @@ -348,11 +343,7 @@
  27. */
  28. bool CMythDirectory::GetTvShowFolders(const CStdString& base, CFileItemList &items)
  29. {
  30. - cmyth_conn_t control = m_session->GetControl();
  31. - if (!control)
  32. - return false;
  33. -
  34. - cmyth_proglist_t list = m_dll->proglist_get_all_recorded(control);
  35. + cmyth_proglist_t list = m_session->GetRecordingList();
  36. if (!list)
  37. {
  38. CLog::Log(LOGERROR, "%s - unable to get list of recordings", __FUNCTION__);
  39. @@ -415,7 +406,6 @@
  40. items.AddSortMethod(SORT_METHOD_LABEL, 551 /* Name */, LABEL_MASKS("", "", "%L", "%J"));
  41. items.AddSortMethod(SORT_METHOD_DATE, 552 /* Date */, LABEL_MASKS("", "", "%L", "%J"));
  42.  
  43. - m_dll->ref_release(list);
  44. return true;
  45. }
  46.  
  47. Index: xbmc/FileSystem/MythSession.cpp
  48. ===================================================================
  49. --- xbmc/FileSystem/MythSession.cpp.orig 2010-11-03 19:38:48.000000000 -0700
  50. +++ xbmc/FileSystem/MythSession.cpp 2010-11-03 20:49:10.000000000 -0700
  51. @@ -57,7 +57,7 @@
  52. for (it = m_sessions.begin(); it != m_sessions.end(); )
  53. {
  54. CMythSession* session = *it;
  55. - if (session->m_timestamp + 5000 < CTimeUtils::GetTimeMS())
  56. + if (session->m_timestamp + 50000 < CTimeUtils::GetTimeMS())
  57. {
  58. CLog::Log(LOGINFO, "%s - closing idle connection to MythTV backend: %s", __FUNCTION__, session->m_hostname.c_str());
  59. delete session;
  60. @@ -81,14 +81,19 @@
  61. if (session->CanSupport(url))
  62. {
  63. m_sessions.erase(it);
  64. +printf("Aquiring session %p\n", session);
  65. return session;
  66. }
  67. }
  68. - return new CMythSession(url);
  69. + CMythSession* session = new CMythSession(url);
  70. +printf("Aquiring session %p\n", session);
  71. +
  72. + return session;
  73. }
  74.  
  75. void CMythSession::ReleaseSession(CMythSession* session)
  76. {
  77. +printf("Releasing session: %p\n", session);
  78. session->SetListener(NULL);
  79. session->m_timestamp = CTimeUtils::GetTimeMS();
  80. CSingleLock lock(m_section_session);
  81. @@ -353,6 +358,7 @@
  82. m_control = NULL;
  83. m_event = NULL;
  84. m_database = NULL;
  85. + m_proglist = NULL;
  86. m_hostname = url.GetHostName();
  87. m_username = url.GetUserName() == "" ? MYTH_DEFAULT_USERNAME : url.GetUserName();
  88. m_password = url.GetPassWord() == "" ? MYTH_DEFAULT_PASSWORD : url.GetPassWord();
  89. @@ -423,15 +429,19 @@
  90. break;
  91. case CMYTH_EVENT_RECORDING_LIST_CHANGE:
  92. CLog::Log(LOGDEBUG, "%s - MythTV event RECORDING_LIST_CHANGE", __FUNCTION__);
  93. + GetRecordingList(true);
  94. break;
  95. case CMYTH_EVENT_RECORDING_LIST_CHANGE_ADD:
  96. CLog::Log(LOGDEBUG, "%s - MythTV event RECORDING_LIST_CHANGE_ADD: %s", __FUNCTION__, buf);
  97. + GetRecordingList(true);
  98. break;
  99. case CMYTH_EVENT_RECORDING_LIST_CHANGE_UPDATE:
  100. CLog::Log(LOGDEBUG, "%s - MythTV event RECORDING_LIST_CHANGE_UPDATE", __FUNCTION__);
  101. + GetRecordingList(true);
  102. break;
  103. case CMYTH_EVENT_RECORDING_LIST_CHANGE_DELETE:
  104. CLog::Log(LOGDEBUG, "%s - MythTV event RECORDING_LIST_CHANGE_DELETE: %s", __FUNCTION__, buf);
  105. + GetRecordingList(true);
  106. break;
  107. case CMYTH_EVENT_SCHEDULE_CHANGE:
  108. CLog::Log(LOGDEBUG, "%s - MythTV event SCHEDULE_CHANGE", __FUNCTION__);
  109. @@ -541,6 +551,23 @@
  110. return true;
  111. }
  112.  
  113. +cmyth_proglist_t CMythSession::GetRecordingList(bool force)
  114. +{
  115. + if (! m_proglist || force)
  116. + {
  117. + CSingleLock lock(m_section);
  118. + if (m_proglist) {
  119. + m_dll->ref_release(m_proglist);
  120. + m_proglist = NULL;
  121. + }
  122. + cmyth_conn_t control = GetControl();
  123. + if (!control)
  124. + return NULL;
  125. + m_proglist = m_dll->proglist_get_all_recorded(control);
  126. + }
  127. + return m_proglist;
  128. +}
  129. +
  130. DllLibCMyth* CMythSession::GetLibrary()
  131. {
  132. if (m_dll->IsLoaded())
  133. Index: xbmc/FileSystem/MythSession.h
  134. ===================================================================
  135. --- xbmc/FileSystem/MythSession.h.orig 2010-11-03 19:58:27.000000000 -0700
  136. +++ xbmc/FileSystem/MythSession.h 2010-11-03 20:01:32.000000000 -0700
  137. @@ -60,6 +60,7 @@
  138. cmyth_conn_t GetControl();
  139. cmyth_database_t GetDatabase();
  140. DllLibCMyth* GetLibrary();
  141. + cmyth_proglist_t GetRecordingList(bool force = false);
  142.  
  143. void SetFileItemMetaData(CFileItem &item, cmyth_proginfo_t program);
  144.  
  145. @@ -88,6 +89,7 @@
  146. DllLibCMyth* m_dll;
  147. CCriticalSection m_section;
  148. unsigned int m_timestamp;
  149. + cmyth_proglist_t m_proglist;
  150.  
  151. static CCriticalSection m_section_session;
  152. static std::vector<CMythSession*> m_sessions;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement