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 sphery, 14 years ago)

Not-completely-updated patch referenced in comment:3

  • 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  
    11121112    MythObservable::dispatch(event);
    11131113}
    11141114
    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 
    11221115void MythCoreContext::SetLocalHostname(const QString &hostname)
    11231116{
    11241117    QMutexLocker locker(&d->m_hostnameLock);
  • libs/libmythbase/mythcorecontext.h

    old new class MBASE_PUBLIC MythCoreContext : pub  
    151151    void OverrideSettingForSession(const QString &key, const QString &value);
    152152
    153153    void dispatch(const MythEvent &event);
    154     void dispatchNow(const MythEvent &event) MDEPRECATED;
    155154
    156155    void InitLocale(void);
    157156    const MythLocale *GetLocale(void) const;
  • libs/libmythbase/mythobservable.cpp

    old new  
    1212 *  events to listening QObjects.
    1313 *
    1414 *  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()
    1816 *
    1917 *  The name MythObservable is 'wrong', since all the methods refer to
    2018 *  the observers as listeners (ie. addListener), however,
    void MythObservable::dispatch(const Myth  
    8583    for (; it != m_listeners.end() ; ++it)
    8684        QCoreApplication::postEvent(*it, event.clone());
    8785}
    88 
    89 /** \brief Dispatch an event to all listeners
    90  *
    91  *  This sends an event using the current thread, this is
    92  *  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  
    1818    void removeListener(QObject *listener);
    1919
    2020    void dispatch(const MythEvent &event);
    21     void dispatchNow(const MythEvent &event) MDEPRECATED;
    2221
    2322    bool hasListeners(void) { return !m_listeners.isEmpty(); }
    2423
  • libs/libmythbase/util.cpp

    old new using namespace std;  
    4343
    4444// Myth headers
    4545#include "mythcorecontext.h"
     46#include "mythcontext.h"
     47#include "mythplugin.h"
    4648#include "exitcodes.h"
    4749#include "mythlogging.h"
    4850#include "msocketdevice.h"
    QString getSymlinkTarget(const QString &  
    11181120
    11191121void sendPlaybackStart(void)
    11201122{
    1121     MythEvent me(QString("PLAYBACK_START %1").arg(gCoreContext->GetHostName()));
    1122     gCoreContext->dispatchNow(me);
     1123    gContext->getPluginManager()->PauseAllPlugins();
    11231124}
    11241125
    11251126void sendPlaybackEnd(void)
    11261127{
    1127     MythEvent me(QString("PLAYBACK_END %1").arg(gCoreContext->GetHostName()));
    1128     gCoreContext->dispatchNow(me);
     1128    gContext->getPluginManager()->ResumeAllPlugins();
    11291129}
    11301130
    11311131bool IsMACAddress(QString MAC)
  • libs/libmyth/mythpluginapi.h

    old new  
    77extern "C" {
    88    MPUBLIC int mythplugin_init(const char *);
    99    MPUBLIC int mythplugin_run();
     10    MPUBLIC void mythplugin_pause();
     11    MPUBLIC void mythplugin_resume();
    1012    MPUBLIC int mythplugin_config();
    1113    MPUBLIC MythPluginType mythplugin_type();
    1214    MPUBLIC void mythplugin_destroy();
  • libs/libmyth/mythplugin.cpp

    old new int MythPlugin::run(void)  
    6868    return rVal;
    6969}
    7070
     71void MythPlugin::pause(void)
     72{
     73    typedef int (*PluginPauseFunc)();
     74    PluginPauseFunc rfunc = (PluginPauseFunc)QLibrary::resolve("mythplugin_pause");
     75
     76    if (rfunc)
     77        rfunc();
     78}
     79
     80void MythPlugin::resume(void)
     81{
     82    typedef int (*PluginResumeFunc)();
     83    PluginResumeFunc rfunc = (PluginResumeFunc)QLibrary::resolve("mythplugin_resume");
     84
     85    if (rfunc)
     86        rfunc();
     87}
     88
    7189int MythPlugin::config(void)
    7290{
    7391    typedef int (*PluginConfigFunc)();
    QStringList MythPluginManager::Enumerate  
    327345    return ret;
    328346}
    329347
     348void 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
     357void 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  
    3030
    3131    // This method will call the mythplugin_run() function of the library.
    3232    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
    3440    // This method will call the mythplugin_config() function of the library.
    3541    int config(void);
    3642
    class MythPlugin : public QLibrary  
    6773// this should only be instantiated through MythContext.
    6874class MPUBLIC MythPluginManager
    6975{
    70   public:   
     76  public:
    7177    MythPluginManager();
    7278   ~MythPluginManager();
    73    
     79
    7480    bool init_plugin(const QString &plugname);
    7581    bool run_plugin(const QString &plugname);
    7682    bool config_plugin(const QString &plugname);
    class MPUBLIC MythPluginManager  
    8288
    8389    QStringList EnumeratePlugins(void);
    8490    void DestroyAllPlugins();
    85      
     91    void PauseAllPlugins();
     92    void ResumeAllPlugins();
     93
    8694  private:
    8795    QHash<QString,MythPlugin*> m_dict;
    88    
     96
    8997    QMap<QString, MythPlugin *> moduleMap;
    9098    QMap<QString, MythPlugin *> menuPluginMap;
    9199    vector<MythPlugin*> menuPluginList;
  • libs/libmythbase/mythversion.h

    old new  
    1212/// Update this whenever the plug-in API changes.
    1313/// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and
    1414/// libmythui class methods used by plug-ins.
    15 #define MYTH_BINARY_VERSION "0.25.20111201-1"
     15#define MYTH_BINARY_VERSION "0.25.20111205-1"
    1616
    1717/** \brief Increment this whenever the MythTV network protocol changes.
    1818 *