[mythtv] [PATCH] MythMediaMonitor/MythCDROM
Nigel Pearson
nigel at ind.tansu.com.au
Mon Sep 25 02:06:29 UTC 2006
The attached patch replaces a few stat() calls
with QDir.exists(), and also detects audio CDs on OS X
(no idea how to do this on Linux/FreeBSD/Windows).
It should be safe, but if a few MythMediaMonitor
users could test I would appreciate it.
Index: mythcdrom.cpp
===================================================================
--- mythcdrom.cpp (revision 11285)
+++ mythcdrom.cpp (working copy)
@@ -1,9 +1,11 @@
#include "mythcdrom.h"
-#include <sys/stat.h>
#include "mythconfig.h"
#include "mythcontext.h"
+#include <qdir.h>
+#include <qfileinfo.h>
+
// For testing
#include <cstdio>
#include <iostream>
@@ -26,6 +28,12 @@
#define PATHTO_SVCD_DETECT "/svcd"
#endif
+// Mac OS X mounts audio CDs ready to use
+#ifndef PATHTO_AUDIO_DETECT
+#define PATHTO_AUDIO_DETECT "/1 Audio Track.aiff"
+#endif
+
+
MythCDROM* MythCDROM::get(QObject* par, const char* devicePath, bool
SuperMount,
bool AllowEject) {
#ifdef linux
@@ -61,7 +69,10 @@
void MythCDROM::onDeviceMounted()
{
- QString DetectPath, DetectPath2;
+ QFileInfo audio = QFileInfo(m_MountPath + PATHTO_AUDIO_DETECT);
+ QDir dvd = QDir(m_MountPath + PATHTO_DVD_DETECT);
+ QDir svcd = QDir(m_MountPath + PATHTO_SVCD_DETECT);
+ QDir vcd = QDir(m_MountPath + PATHTO_VCD_DETECT);
// Default is data media
m_MediaType = MEDIATYPE_DATA;
@@ -69,11 +80,8 @@
// Default is mounted media
m_Status = MEDIASTAT_MOUNTED;
- DetectPath.sprintf("%s%s", (const char*)m_MountPath,
PATHTO_DVD_DETECT);
- VERBOSE(VB_IMPORTANT, QString("Looking for:
'%1'").arg(DetectPath));
- struct stat sbuf;
- if (stat(DetectPath, &sbuf) == 0)
+ if (dvd.exists())
{
VERBOSE(VB_GENERAL, "Probable DVD detected.");
m_MediaType = MEDIATYPE_DVD;
@@ -81,14 +89,20 @@
performMountCmd(false);
m_Status = MEDIASTAT_USEABLE;
}
-
- DetectPath.sprintf("%s%s", (const char*)m_MountPath,
PATHTO_VCD_DETECT);
- VERBOSE(VB_IMPORTANT, QString("Looking for:
'%1'").arg(DetectPath));
+ else
+ VERBOSE(VB_IMPORTANT, QString("Path %1 doesn't
exist").arg(dvd.path()));
- DetectPath2.sprintf("%s%s", (const char*)m_MountPath,
PATHTO_SVCD_DETECT);
- VERBOSE(VB_IMPORTANT, QString("Looking for:
'%1'").arg(DetectPath2));
+ if (audio.exists())
+ {
+ VERBOSE(VB_GENERAL, "Probable Audio CD detected.");
+ m_MediaType = MEDIATYPE_AUDIO;
+ m_Status = MEDIASTAT_USEABLE;
+ }
+ else
+ VERBOSE(VB_IMPORTANT, QString("Path %1 doesn't exist")
+ .arg(audio.filePath()));
- if (stat(DetectPath, &sbuf) == 0 || stat(DetectPath2, &sbuf) == 0)
+ if (vcd.exists() || svcd.exists())
{
VERBOSE(VB_GENERAL, "Probable VCD/SVCD detected.");
m_MediaType = MEDIATYPE_VCD;
@@ -96,8 +110,11 @@
performMountCmd(false);
m_Status = MEDIASTAT_USEABLE;
}
+ else
+ VERBOSE(VB_IMPORTANT, QString("Paths %1 and %2 do not exist")
+ .arg(vcd.path()).arg(svcd.path()));
- // If not DVB or VCD, use parent to check file ext to determine
media type
+ // If not DVD/AudioCD/VCD/SVCD, use parent's more generic check
(file ext)
if (MEDIATYPE_DATA == m_MediaType)
--
Nigel Pearson, nigel at ind.tansu.com.au|"Reality is that which,
Telstra Net. Eng., Sydney, Australia | when you stop believing
Office: 9202 3900 Fax: 9261 3912 | in it, doesn't go away."
Mobile: 0408 664435 Home: 9792 6998 | Philip K. Dick - 'Valis'
More information about the mythtv-dev
mailing list