Ticket #9819: mythtv-9819-PauseAllPlugins_on_playback_start_and_resume_on_end.patch
| File mythtv-9819-PauseAllPlugins_on_playback_start_and_resume_on_end.patch, 8.6 KB (added by , 14 years ago) |
|---|
-
libs/libmythbase/mythcorecontext.cpp
--- libs/libmyth/mythplugin.cpp | 35 35 + 0 - 0 ! libs/libmyth/mythplugin.h | 18 13 + 5 - 0 ! libs/libmyth/mythpluginapi.h | 2 2 + 0 - 0 ! libs/libmythbase/mythcorecontext.cpp | 7 0 + 7 - 0 ! libs/libmythbase/mythcorecontext.h | 1 0 + 1 - 0 ! libs/libmythbase/mythobservable.cpp | 21 1 + 20 - 0 ! libs/libmythbase/mythobservable.h | 1 0 + 1 - 0 ! libs/libmythbase/mythversion.h | 2 1 + 1 - 0 ! libs/libmythbase/util.cpp | 8 4 + 4 - 0 ! 9 files changed, 56 insertions(+), 39 deletions(-)
old new void MythCoreContext::dispatch(const Myt 1112 1112 MythObservable::dispatch(event); 1113 1113 } 1114 1114 1115 void MythCoreContext::dispatchNow(const MythEvent &event)1116 {1117 LOG(VB_NETWORK, LOG_INFO, QString("MythEvent: %1").arg(event.Message()));1118 1119 MythObservable::dispatchNow(event);1120 }1121 1122 1115 void MythCoreContext::SetLocalHostname(const QString &hostname) 1123 1116 { 1124 1117 QMutexLocker locker(&d->m_hostnameLock); -
libs/libmythbase/mythcorecontext.h
old new class MBASE_PUBLIC MythCoreContext : pub 151 151 void OverrideSettingForSession(const QString &key, const QString &value); 152 152 153 153 void dispatch(const MythEvent &event); 154 void dispatchNow(const MythEvent &event) MDEPRECATED;155 154 156 155 void InitLocale(void); 157 156 const MythLocale *GetLocale(void) const; -
libs/libmythbase/mythobservable.cpp
old new 12 12 * events to listening QObjects. 13 13 * 14 14 * MythEvents can be dispatched to all listeners by calling dispatch 15 * or dispatchNow. The former is much preferred as it uses 16 * QCoreApplication::postEvent() while the latter uses the blocking 17 * QCoreApplication::sendEvent(). 15 * which uses QCoreApplication::postEvent() 18 16 * 19 17 * The name MythObservable is 'wrong', since all the methods refer to 20 18 * the observers as listeners (ie. addListener), however, … … void MythObservable::dispatch(const Myth 85 83 for (; it != m_listeners.end() ; ++it) 86 84 QCoreApplication::postEvent(*it, event.clone()); 87 85 } 88 89 /** \brief Dispatch an event to all listeners90 *91 * This sends an event using the current thread, this is92 * almost always unsafe.93 *94 * \param event a MythEvent to dispatch.95 */96 void MythObservable::dispatchNow(const MythEvent &event)97 {98 QMutexLocker locker(m_lock);99 100 QSet<QObject*>::const_iterator it = m_listeners.begin();101 for (; it != m_listeners.end() ; ++it)102 QCoreApplication::sendEvent(*it, event.clone());103 }104 -
libs/libmythbase/mythobservable.h
old new class MBASE_PUBLIC MythObservable 18 18 void removeListener(QObject *listener); 19 19 20 20 void dispatch(const MythEvent &event); 21 void dispatchNow(const MythEvent &event) MDEPRECATED;22 21 23 22 bool hasListeners(void) { return !m_listeners.isEmpty(); } 24 23 -
libs/libmythbase/util.cpp
old new using namespace std; 43 43 44 44 // Myth headers 45 45 #include "mythcorecontext.h" 46 #include "mythcontext.h" 47 #include "mythplugin.h" 46 48 #include "exitcodes.h" 47 49 #include "mythlogging.h" 48 50 #include "msocketdevice.h" … … QString getSymlinkTarget(const QString & 1118 1120 1119 1121 void sendPlaybackStart(void) 1120 1122 { 1121 MythEvent me(QString("PLAYBACK_START %1").arg(gCoreContext->GetHostName())); 1122 gCoreContext->dispatchNow(me); 1123 gContext->getPluginManager()->PauseAllPlugins(); 1123 1124 } 1124 1125 1125 1126 void sendPlaybackEnd(void) 1126 1127 { 1127 MythEvent me(QString("PLAYBACK_END %1").arg(gCoreContext->GetHostName())); 1128 gCoreContext->dispatchNow(me); 1128 gContext->getPluginManager()->ResumeAllPlugins(); 1129 1129 } 1130 1130 1131 1131 bool IsMACAddress(QString MAC) -
libs/libmyth/mythpluginapi.h
old new 7 7 extern "C" { 8 8 MPUBLIC int mythplugin_init(const char *); 9 9 MPUBLIC int mythplugin_run(); 10 MPUBLIC void mythplugin_pause(); 11 MPUBLIC void mythplugin_resume(); 10 12 MPUBLIC int mythplugin_config(); 11 13 MPUBLIC MythPluginType mythplugin_type(); 12 14 MPUBLIC void mythplugin_destroy(); -
libs/libmyth/mythplugin.cpp
old new int MythPlugin::run(void) 68 68 return rVal; 69 69 } 70 70 71 void MythPlugin::pause(void) 72 { 73 typedef int (*PluginPauseFunc)(); 74 PluginPauseFunc rfunc = (PluginPauseFunc)QLibrary::resolve("mythplugin_pause"); 75 76 if (rfunc) 77 rfunc(); 78 } 79 80 void MythPlugin::resume(void) 81 { 82 typedef int (*PluginResumeFunc)(); 83 PluginResumeFunc rfunc = (PluginResumeFunc)QLibrary::resolve("mythplugin_resume"); 84 85 if (rfunc) 86 rfunc(); 87 } 88 71 89 int MythPlugin::config(void) 72 90 { 73 91 typedef int (*PluginConfigFunc)(); … … QStringList MythPluginManager::Enumerate 327 345 return ret; 328 346 } 329 347 348 void MythPluginManager::PauseAllPlugins(void) 349 { 350 QHash<QString, MythPlugin*>::iterator it = m_dict.begin(); 351 for (; it != m_dict.end(); ++it) 352 { 353 (*it)->pause(); 354 } 355 } 356 357 void MythPluginManager::ResumeAllPlugins(void) 358 { 359 QHash<QString, MythPlugin*>::iterator it = m_dict.begin(); 360 for (; it != m_dict.end(); ++it) 361 { 362 (*it)->resume(); 363 } 364 } -
libs/libmyth/mythplugin.h
old new class MythPlugin : public QLibrary 30 30 31 31 // This method will call the mythplugin_run() function of the library. 32 32 int run(void); 33 33 34 // This method will call the mythplugin_pause() function of the library. 35 void pause(void); 36 37 // This method will call the mythplugin_resume() function of the library. 38 void resume(void); 39 34 40 // This method will call the mythplugin_config() function of the library. 35 41 int config(void); 36 42 … … class MythPlugin : public QLibrary 67 73 // this should only be instantiated through MythContext. 68 74 class MPUBLIC MythPluginManager 69 75 { 70 public: 76 public: 71 77 MythPluginManager(); 72 78 ~MythPluginManager(); 73 79 74 80 bool init_plugin(const QString &plugname); 75 81 bool run_plugin(const QString &plugname); 76 82 bool config_plugin(const QString &plugname); … … class MPUBLIC MythPluginManager 82 88 83 89 QStringList EnumeratePlugins(void); 84 90 void DestroyAllPlugins(); 85 91 void PauseAllPlugins(); 92 void ResumeAllPlugins(); 93 86 94 private: 87 95 QHash<QString,MythPlugin*> m_dict; 88 96 89 97 QMap<QString, MythPlugin *> moduleMap; 90 98 QMap<QString, MythPlugin *> menuPluginMap; 91 99 vector<MythPlugin*> menuPluginList; -
libs/libmythbase/mythversion.h
old new 12 12 /// Update this whenever the plug-in API changes. 13 13 /// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and 14 14 /// libmythui class methods used by plug-ins. 15 #define MYTH_BINARY_VERSION "0.25.2011120 1-1"15 #define MYTH_BINARY_VERSION "0.25.20111205-1" 16 16 17 17 /** \brief Increment this whenever the MythTV network protocol changes. 18 18 *
