summaryrefslogtreecommitdiff
path: root/dvd.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2001-08-05 15:11:35 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2001-08-05 15:11:35 +0200
commit57692504cd4576a40d442d866e12eba09835db03 (patch)
tree0521d2934de89cb1dedcc8aa04c75b14beaea312 /dvd.c
parent8c1fc6560d2ef79565c89f1f5b6223e2ee829a2e (diff)
downloadvdr-57692504cd4576a40d442d866e12eba09835db03.tar.gz
vdr-57692504cd4576a40d442d866e12eba09835db03.tar.bz2
Improved DVD handling
Diffstat (limited to 'dvd.c')
-rw-r--r--dvd.c41
1 files changed, 29 insertions, 12 deletions
diff --git a/dvd.c b/dvd.c
index 8daa926c..025361ab 100644
--- a/dvd.c
+++ b/dvd.c
@@ -6,7 +6,7 @@
*
* Initially written by Andreas Schultz <aschultz@warp10.net>
*
- * $Id: dvd.c 1.1 2001/08/03 12:35:38 kls Exp $
+ * $Id: dvd.c 1.2 2001/08/05 15:00:45 kls Exp $
*/
//XXX //#define DVDDEBUG 1
@@ -46,6 +46,17 @@ cDVD::~cDVD()
Close();
}
+int cDVD::Command(int Cmd)
+{
+ int result = -1;
+ int f;
+ if ((f = open(deviceName, O_RDONLY | O_NONBLOCK)) > 0) {
+ result = ioctl(f, Cmd, 0);
+ close(f);
+ }
+ return result;
+}
+
void cDVD::SetDeviceName(const char *DeviceName)
{
deviceName = strdup(DeviceName);
@@ -56,6 +67,23 @@ const char *cDVD::DeviceName(void)
return deviceName;
}
+bool cDVD::DriveExists(void)
+{
+ return access(deviceName, F_OK) == 0;
+}
+
+bool cDVD::DiscOk(void)
+{
+ return Command(CDROM_DRIVE_STATUS) == CDS_DISC_OK;
+}
+
+void cDVD::Eject(void)
+{
+ if (dvdInstance)
+ dvdInstance->Close();
+ Command(CDROMEJECT);
+}
+
void cDVD::Open(void)
{
if (!dvd)
@@ -81,17 +109,6 @@ void cDVD::Close(void)
dvd = NULL;
}
-void cDVD::Eject(void)
-{
- int fd;
- Close();
- // ignore all errors try our best :-)
- if ((fd = open(deviceName, O_RDONLY)) > 0) {
- ioctl(fd, CDROMEJECT, 0);
- close(fd);
- }
-}
-
ifo_handle_t *cDVD::openVMG(void)
{
if (!isValid())