diff options
author | David Teirney <github@teirney.net> | 2011-06-12 02:56:59 -0700 |
---|---|---|
committer | David Teirney <github@teirney.net> | 2011-06-12 02:56:59 -0700 |
commit | 8f591da9ed4db3e121801b2fc6f07262d4001822 (patch) | |
tree | 0405f4f973ee21a8117f052b6fecd4d8cc694f14 | |
parent | 0f336335f0090579d6fad196c3b66d293f126ead (diff) | |
parent | e59a7b66f0fffd49386141b1d27b000a6b30c027 (diff) |
Merge pull request #187 from dteirney/myth
Performance improvement and fix for a race condition for the myth:// all recorded programs cache.
-rw-r--r-- | xbmc/filesystem/MythDirectory.cpp | 2 | ||||
-rw-r--r-- | xbmc/filesystem/MythSession.cpp | 34 | ||||
-rw-r--r-- | xbmc/filesystem/MythSession.h | 4 |
3 files changed, 32 insertions, 8 deletions
diff --git a/xbmc/filesystem/MythDirectory.cpp b/xbmc/filesystem/MythDirectory.cpp index 9f27a5e413..40aaaf73af 100644 --- a/xbmc/filesystem/MythDirectory.cpp +++ b/xbmc/filesystem/MythDirectory.cpp @@ -320,6 +320,7 @@ bool CMythDirectory::GetRecordings(const CStdString& base, CFileItemList &items, m_dll->ref_release(program); } } + m_dll->ref_release(list); /* * Don't sort by name for TV_SHOWS as they all have the same name, so only date sort is useful. @@ -392,6 +393,7 @@ bool CMythDirectory::GetTvShowFolders(const CStdString& base, CFileItemList &ite } } + m_dll->ref_release(list); if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) items.AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551 /* Name */, LABEL_MASKS("", "", "%L", "%J")); diff --git a/xbmc/filesystem/MythSession.cpp b/xbmc/filesystem/MythSession.cpp index 17cc5ee5a4..36c32fdd47 100644 --- a/xbmc/filesystem/MythSession.cpp +++ b/xbmc/filesystem/MythSession.cpp @@ -434,19 +434,19 @@ void CMythSession::Process() break; case CMYTH_EVENT_RECORDING_LIST_CHANGE: CLog::Log(LOGDEBUG, "%s - MythTV event RECORDING_LIST_CHANGE", __FUNCTION__); - GetAllRecordedPrograms(true); + ResetAllRecordedPrograms(); break; case CMYTH_EVENT_RECORDING_LIST_CHANGE_ADD: CLog::Log(LOGDEBUG, "%s - MythTV event RECORDING_LIST_CHANGE_ADD: %s", __FUNCTION__, buf); - GetAllRecordedPrograms(true); + ResetAllRecordedPrograms(); break; case CMYTH_EVENT_RECORDING_LIST_CHANGE_UPDATE: CLog::Log(LOGDEBUG, "%s - MythTV event RECORDING_LIST_CHANGE_UPDATE", __FUNCTION__); - GetAllRecordedPrograms(true); + ResetAllRecordedPrograms(); break; case CMYTH_EVENT_RECORDING_LIST_CHANGE_DELETE: CLog::Log(LOGDEBUG, "%s - MythTV event RECORDING_LIST_CHANGE_DELETE: %s", __FUNCTION__, buf); - GetAllRecordedPrograms(true); + ResetAllRecordedPrograms(); break; case CMYTH_EVENT_SCHEDULE_CHANGE: CLog::Log(LOGDEBUG, "%s - MythTV event SCHEDULE_CHANGE", __FUNCTION__); @@ -565,11 +565,14 @@ DllLibCMyth* CMythSession::GetLibrary() return NULL; } -cmyth_proglist_t CMythSession::GetAllRecordedPrograms(bool force) +/* + * The caller must call m_dll->ref_release() when finished. + */ +cmyth_proglist_t CMythSession::GetAllRecordedPrograms() { - if (!m_all_recorded || force) + CSingleLock lock(m_section); + if (!m_all_recorded) { - CSingleLock lock(m_section); if (m_all_recorded) { m_dll->ref_release(m_all_recorded); @@ -581,9 +584,26 @@ cmyth_proglist_t CMythSession::GetAllRecordedPrograms(bool force) m_all_recorded = m_dll->proglist_get_all_recorded(control); } + /* + * An extra reference is needed to prevent a race condition while resetting the proglist from + * the Process() thread while it is being read. + */ + m_dll->ref_hold(m_all_recorded); + return m_all_recorded; } +void CMythSession::ResetAllRecordedPrograms() +{ + CSingleLock lock(m_section); + if (m_all_recorded) + { + m_dll->ref_release(m_all_recorded); + m_all_recorded = NULL; + } + return; +} + void CMythSession::LogCMyth(int level, char *msg) { int xbmc_lvl = -1; diff --git a/xbmc/filesystem/MythSession.h b/xbmc/filesystem/MythSession.h index e56626a353..511cc445e2 100644 --- a/xbmc/filesystem/MythSession.h +++ b/xbmc/filesystem/MythSession.h @@ -60,7 +60,7 @@ public: cmyth_conn_t GetControl(); cmyth_database_t GetDatabase(); DllLibCMyth* GetLibrary(); - cmyth_proglist_t GetAllRecordedPrograms(bool force = false); + cmyth_proglist_t GetAllRecordedPrograms(); void SetFileItemMetaData(CFileItem &item, cmyth_proginfo_t program); @@ -78,6 +78,8 @@ private: void SetSeasonAndEpisode(const cmyth_proginfo_t &program, int *season, int *epsiode); + void ResetAllRecordedPrograms(); + IEventListener* m_listener; cmyth_conn_t m_control; cmyth_conn_t m_event; |