Ticket #1753: mythmediamonitor.patch

File mythmediamonitor.patch, 5.3 KB (added by awk@…, 13 years ago)

Patches to mythmediamonitor, cdrom classes and .pro file to support Darwin Disk arbitration

  • mythcdrom.cpp

     
    3333#elif defined(__FreeBSD__)
    3434    return new MythCDROMFreeBSD(par, devicePath, SuperMount, AllowEject);
    3535#elif defined(CONFIG_DARWIN)
    36     return new MythCDROM(par, devicePath, SuperMount, AllowEject);
     36    return new MythCDROMDarwin(par, devicePath, SuperMount, AllowEject);
    3737#else
    3838    return NULL;
    3939#endif
  • mythmediamonitor.h

     
    4747{
    4848    Q_OBJECT
    4949    friend class MonitorThread;
    50 
     50    friend class MonitorThreadDarwin;
     51   
    5152  protected:
    5253    MediaMonitor(QObject* par, unsigned long interval, bool allowEject);
    5354
     
    5657
    5758    bool IsActive(void) const { return m_Active; }
    5859
    59     void StartMonitoring(void);
     60    virtual void StartMonitoring(void);
    6061    void StopMonitoring(void);
    6162    void ChooseAndEjectMedia(void);
    6263
     
    8283    bool CheckMountable(void);
    8384    bool FindPartitions(const QString &dev, bool checkPartitions);
    8485
    85     bool AddDevice(MythMediaDevice* pDevice);
     86    virtual bool AddDevice(MythMediaDevice* pDevice);
    8687    bool AddDevice(const char* dev);
    8788    bool AddDevice(struct fstab* mep);
    8889    bool RemoveDevice(const QString &dev);
     
    9899    QMap<MythMediaDevice*, int>  m_UseCount;
    99100
    100101    bool                         m_Active;
    101     MonitorThread                m_Thread;
     102    MonitorThread                *m_Thread;
     103    unsigned long                m_MonitorPollingInterval;
    102104    bool                         m_AllowEject;
    103105    int                          m_fifo;
    104106
  • mythcdrom.h

     
    5858    virtual MediaError unlock(void);
    5959};
    6060
     61class MythCDROMDarwin: public MythCDROM
     62{
     63public:
     64    MythCDROMDarwin(QObject* par, const char* DevicePath, bool SuperMount,
     65        bool AllowEject):
     66        MythCDROM(par, DevicePath, SuperMount, AllowEject) {
     67    }
     68
     69    virtual bool openDevice();
     70    virtual MediaError testMedia(void);
     71    virtual bool mediaChanged(void);
     72    virtual bool checkOK(void);
     73    virtual MediaStatus checkMedia(void);
     74    virtual MediaError eject(bool open_close = true);
     75    virtual MediaError lock(void);
     76    virtual MediaError unlock(void);
     77};
     78
    6179#endif
  • libmyth.pro

     
    7272}
    7373
    7474macx {
    75     HEADERS += audiooutputca.h   screensaver-osx.h   DisplayResOSX.h
    76     SOURCES += audiooutputca.cpp screensaver-osx.cpp DisplayResOSX.cpp
     75    HEADERS += audiooutputca.h   screensaver-osx.h   DisplayResOSX.h mythmediamonitor-darwin.h
     76    SOURCES += audiooutputca.cpp screensaver-osx.cpp DisplayResOSX.cpp mythmediamonitor-darwin.cpp
    7777    HEADERS += util-osx.h
    7878    SOURCES += util-osx.cpp
    79 
     79    SOURCES += mythcdrom-darwin.cpp
     80   
    8081    using_appleremote {
    8182        HEADERS += AppleRemote.h   AppleRemoteListener.h   lircevent.h
    8283        SOURCES += AppleRemote.cpp AppleRemoteListener.cpp lircevent.cpp
    8384    }
    8485
    8586    # Mac OS X Frameworks
    86     FWKS = ApplicationServices AudioUnit Carbon CoreAudio IOKit
     87    FWKS = ApplicationServices AudioUnit Carbon CoreAudio IOKit DiskArbitration
    8788
    8889    # The following trick is tidier, and shortens the command line, but it
    8990    # depends on the shell expanding Csh-style braces. Luckily, Bash & Zsh do.
  • mythmediamonitor.cpp

     
    2525#include <qdir.h>
    2626#include <qfile.h>
    2727
     28#ifdef Q_OS_MACX
     29#include "mythmediamonitor-darwin.h"
     30#endif // Q_OS_MACX
     31
    2832// MythTV headers
    2933#include "mythmediamonitor.h"
    3034#include "mythcontext.h"
     
    8791
    8892    if (gContext->GetNumSetting("MonitorDrives"))
    8993    {
     94#ifdef Q_OS_MACX
     95        c_monitor = new MediaMonitorDarwin(NULL, 500, true);
     96#else
    9097        c_monitor = new MediaMonitor(NULL, 500, true);
     98#endif // Q_OS_MACX       
    9199        c_monitor->CheckFileSystemTable();
    92100        c_monitor->CheckMountable();
    93101    }
     
    199207
    200208MediaMonitor::MediaMonitor(QObject* par, unsigned long interval,
    201209                           bool allowEject)
    202     : QObject(par), m_Active(false), m_Thread(this, interval),
     210    : QObject(par), m_Active(false), m_Thread(NULL), m_MonitorPollingInterval(interval),
    203211      m_AllowEject(allowEject), m_fifo(-1)
    204212{
    205213}
    206214
    207215MediaMonitor::~MediaMonitor()
    208216{
     217    if (m_Thread)
     218    {
     219        delete m_Thread;
     220        m_Thread = NULL;
     221    }
     222   
    209223    if (m_fifo > 0)
    210224    {
    211225        close(m_fifo);
     
    742756    if (m_Active)
    743757        return;
    744758
     759    if (!m_Thread)
     760    {
     761        m_Thread = new MonitorThread(this, m_MonitorPollingInterval);
     762    }
    745763    m_Active = true;
    746     m_Thread.start();
     764    m_Thread->start();
    747765}
    748766
    749767/** \fn MediaMonitor::StopMonitoring(void)
     
    756774        return;
    757775
    758776    m_Active = false;
    759     m_Thread.wait();
     777    m_Thread->wait();
    760778}
    761779
    762780/** \fn MediaMonitor::ValidateAndLock(MythMediaDevice *pMedia)