Ticket #1753: mythmediamonitor.cpp.patch

File mythmediamonitor.cpp.patch, 1.6 KB (added by awk@…, 14 years ago)

libs/libmyth/mythmediamonitor.cpp - patch for Darwin specific methods.

  • mythmediamonitor.cpp

     
    2525#include <qdir.h>
    2626#include <qfile.h>
    2727
     28#ifdef Q_OS_MACX
     29#include <CoreFoundation/CoreFoundation.h>
     30#include <DiskArbitration/DiskArbitration.h>
     31#include "mythmediamonitor-darwin.h"
     32#endif // Q_OS_MACX
     33
    2834// MythTV headers
    2935#include "mythmediamonitor.h"
    3036#include "mythcontext.h"
     
    6975// loop and check it's devices.
    7076void MonitorThread::run(void)
    7177{
     78#ifdef Q_OS_MACX
     79    DASessionRef diskArbitrationSession = DASessionCreate(kCFAllocatorDefault);
     80    DARegisterDiskAppearedCallback( diskArbitrationSession, kDADiskDescriptionMatchVolumeMountable, diskAppearedCallback, m_Monitor);
     81    DARegisterDiskDisappearedCallback( diskArbitrationSession, kDADiskDescriptionMatchVolumeMountable, diskDisappearedCallback, m_Monitor);
     82
     83    DASessionScheduleWithRunLoop(diskArbitrationSession, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
     84#endif // Q_OS_MACX
    7285    while (m_Monitor && m_Monitor->IsActive())       
    7386    {
    7487        m_Monitor->CheckDevices();
     88#ifdef Q_OS_MACX
     89        // Run the run loop for interval (milliseconds) - this will handle any disk arbitration
     90        // appeared/dissappeared events
     91        CFRunLoopRunInMode(kCFRunLoopDefaultMode, (float) m_Interval / 1000.0f, false );
     92#else
    7593        msleep(m_Interval);
     94#endif // Q_OS_MACX
    7695    }
     96#ifdef Q_OS_MACX
     97    CFRelease(diskArbitrationSession);
     98#endif // Q_OS_MACX
    7799}
    78100
    79101////////////////////////////////////////////////////////////////////////