summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/input/Makefile.am8
-rw-r--r--src/input/input_cdda.c12
-rw-r--r--src/input/input_dvd.c92
-rw-r--r--src/input/input_vcd.c66
-rw-r--r--src/input/media_helper.c134
-rw-r--r--src/input/media_helper.h23
6 files changed, 182 insertions, 153 deletions
diff --git a/src/input/Makefile.am b/src/input/Makefile.am
index ea9436949..dc4cf7334 100644
--- a/src/input/Makefile.am
+++ b/src/input/Makefile.am
@@ -86,7 +86,7 @@ xineplug_inp_file_la_SOURCES = input_file.c
xineplug_inp_file_la_LIBADD = $(XINE_LIB)
xineplug_inp_file_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-xineplug_inp_dvd_la_SOURCES = input_dvd.c
+xineplug_inp_dvd_la_SOURCES = input_dvd.c media_helper.c
xineplug_inp_dvd_la_LIBADD = $(XINE_LIB) $(link_dvdnav)
xineplug_inp_dvd_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
@@ -98,7 +98,7 @@ xineplug_inp_mms_la_SOURCES = input_mms.c net_buf_ctrl.c mms.c mmsh.c
xineplug_inp_mms_la_LIBADD = $(XINE_LIB)
xineplug_inp_mms_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-xineplug_inp_vcd_la_SOURCES = input_vcd.c
+xineplug_inp_vcd_la_SOURCES = input_vcd.c media_helper.c
xineplug_inp_vcd_la_LIBADD = $(XINE_LIB)
xineplug_inp_vcd_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
@@ -126,7 +126,7 @@ xineplug_inp_rtsp_la_SOURCES = input_rtsp.c net_buf_ctrl.c
xineplug_inp_rtsp_la_LIBADD = $(XINE_LIB) libreal/libreal.la librtsp/librtsp.la
xineplug_inp_rtsp_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-xineplug_inp_cdda_la_SOURCES = input_cdda.c
+xineplug_inp_cdda_la_SOURCES = input_cdda.c media_helper.c
xineplug_inp_cdda_la_LIBADD = $(XINE_LIB)
xineplug_inp_cdda_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
@@ -143,7 +143,7 @@ xineplug_inp_pvr_la_LIBADD = $(XINE_LIB)
xineplug_inp_pvr_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
include_HEADERS = input_plugin.h
-noinst_HEADERS = net_buf_ctrl.h mms.h mmsh.h pnm.h
+noinst_HEADERS = net_buf_ctrl.h mms.h mmsh.h pnm.h media_helper.h
$(XINE_LIB):
@cd $(top_builddir)/src/xine-engine && $(MAKE)
diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c
index e21fd11dc..05c763780 100644
--- a/src/input/input_cdda.c
+++ b/src/input/input_cdda.c
@@ -20,7 +20,7 @@
* Compact Disc Digital Audio (CDDA) Input Plugin
* by Mike Melanson (melanson@pcisys.net)
*
- * $Id: input_cdda.c,v 1.11 2003/03/29 09:37:24 heikos Exp $
+ * $Id: input_cdda.c,v 1.12 2003/04/06 00:51:29 hadess Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -44,6 +44,7 @@
#include "xine_internal.h"
#include "xineutils.h"
#include "input_plugin.h"
+#include "media_helper.h"
#if defined(__sun)
#define DEFAULT_CDDA_DEVICE "/vol/dev/aliases/cdrom0"
@@ -1436,6 +1437,13 @@ static void cdda_class_dispose (input_class_t *this_gen) {
free (this);
}
+static int cdda_class_eject_media (input_class_t *this_gen) {
+ cdda_input_class_t *this = (cdda_input_class_t *) this_gen;
+
+ return media_eject_media (this->cdda_device);
+}
+
+
static void *init_plugin (xine_t *xine, void *data) {
cdda_input_class_t *this;
@@ -1454,7 +1462,7 @@ static void *init_plugin (xine_t *xine, void *data) {
this->input_class.get_dir = NULL;
this->input_class.get_autoplay_list = cdda_class_get_autoplay_list;
this->input_class.dispose = cdda_class_dispose;
- this->input_class.eject_media = NULL;
+ this->input_class.eject_media = cdda_class_eject_media;
this->mrls = (xine_mrl_t **) xine_xmalloc(sizeof(xine_mrl_t*));
this->mrls_allocated_entries = 0;
diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c
index b36edb934..7d494662f 100644
--- a/src/input/input_dvd.c
+++ b/src/input/input_dvd.c
@@ -18,7 +18,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: input_dvd.c,v 1.142 2003/04/05 12:28:16 miguelfreitas Exp $
+ * $Id: input_dvd.c,v 1.143 2003/04/06 00:51:29 hadess Exp $
*
*/
@@ -82,6 +82,7 @@
#include "xineutils.h"
#include "buffer.h"
#include "xine_internal.h"
+#include "media_helper.h"
/* Print debug messages? */
/* #define INPUT_DEBUG */
@@ -780,34 +781,6 @@ static uint32_t dvd_plugin_get_blocksize (input_plugin_t *this_gen) {
return DVD_BLOCK_SIZE;
}
-static int dvd_umount_media(char *device)
-{
- char *argv[10];
- int i;
- pid_t pid;
- int status;
- argv[0]="umount";
- argv[1]=device;
- argv[2]=0;
- pid=fork();
- if (pid == 0) {
- i= execv("/bin/umount", argv);
- exit(127);
- }
- do {
- if(waitpid(pid, &status, 0) == -1) {
- if (errno != EINTR)
- return -1;
- }
- else {
- return WEXITSTATUS(status);
- }
- } while(1);
-
- return -1;
-}
-
-
static char* dvd_plugin_get_mrl (input_plugin_t *this_gen) {
dvd_input_plugin_t *this = (dvd_input_plugin_t*)this_gen;
@@ -1455,63 +1428,9 @@ void dvd_class_dispose(input_class_t *this_gen) {
}
static int dvd_class_eject_media (input_class_t *this_gen) {
- dvd_input_class_t *this = (dvd_input_class_t *) this_gen;
- int ret, status;
- int fd;
-
- /* printf("input_dvd: Eject Device %s current device %s opened=%d handle=%p trying...\n",this->dvd_device, this->current_dvd_device, this->opened, this->dvdnav); */
- ret=dvd_umount_media(this->dvd_device);
- /**********
- printf("ipnut_dvd: umount result: %s\n",
- strerror(errno));
- ***********/
- if ((fd = open (this->dvd_device, O_RDONLY|O_NONBLOCK)) > -1) {
-
-#if defined (__linux__)
- if((status = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT)) > 0) {
- switch(status) {
- case CDS_TRAY_OPEN:
- if((ret = ioctl(fd, CDROMCLOSETRAY)) != 0) {
-#ifdef LOG_DVD_EJECT
- printf("input_dvd: CDROMCLOSETRAY failed: %s\n",
- strerror(errno));
-#endif
- }
- break;
- case CDS_DISC_OK:
- if((ret = ioctl(fd, CDROMEJECT)) != 0) {
-#ifdef LOG_DVD_EJECT
- printf("input_dvd: CDROMEJECT failed: %s\n", strerror(errno));
-#endif
- }
- break;
- }
- }
- else {
-#ifdef LOG_DVD_EJECT
- printf("input_dvd: CDROM_DRIVE_STATUS failed: %s\n",
- strerror(errno));
-#endif
- close(fd);
- return 0;
- }
-#elif defined (__NetBSD__) || defined (__OpenBSD__) || defined (__FreeBSD__)
-
- if (ioctl(fd, CDIOCALLOW) == -1) {
- perror("ioctl(cdromallow)");
- } else {
- if (ioctl(fd, CDIOCEJECT) == -1) {
- perror("ioctl(cdromeject)");
- }
- }
-
-#endif
+ dvd_input_class_t *this = (dvd_input_class_t*)this_gen;
- close(fd);
- } else {
- printf("input_dvd: Device %s failed to open during eject calls\n",this->dvd_device);
- }
- return 1;
+ return media_eject_media (this->dvd_device);
}
static void *init_class (xine_t *xine, void *data) {
@@ -1633,6 +1552,9 @@ static void *init_class (xine_t *xine, void *data) {
/*
* $Log: input_dvd.c,v $
+ * Revision 1.143 2003/04/06 00:51:29 hadess
+ * - shared eject implementation taken from the DVD input, eject doesn't work if the CD/DVD isn't mounted, which definitely breaks the CDDA plugin... better than nothing
+ *
* Revision 1.142 2003/04/05 12:28:16 miguelfreitas
* "perfect" time display for dvds
* (see thread on xine-devel for details)
diff --git a/src/input/input_vcd.c b/src/input/input_vcd.c
index 980f3a4bf..7a297e453 100644
--- a/src/input/input_vcd.c
+++ b/src/input/input_vcd.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: input_vcd.c,v 1.64 2003/02/14 18:11:47 heikos Exp $
+ * $Id: input_vcd.c,v 1.65 2003/04/06 00:51:29 hadess Exp $
*
*/
@@ -50,6 +50,7 @@
#include "xine_internal.h"
#include "xineutils.h"
#include "input_plugin.h"
+#include "media_helper.h"
#if defined(__sun)
#define CDROM "/vol/dev/aliases/cdrom0"
@@ -928,71 +929,12 @@ static void vcd_class_dispose (input_class_t *this_gen) {
free (this);
}
-#if defined (__linux__)
static int vcd_class_eject_media (input_class_t *this_gen) {
- vcd_input_class_t *this = (vcd_input_class_t *) this_gen;
- int ret, status, fd;
-
- if ((fd = open (this->device, O_RDONLY|O_NONBLOCK)) > -1) {
- if((status = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT)) > 0) {
- switch(status) {
- case CDS_TRAY_OPEN:
- if((ret = ioctl(fd, CDROMCLOSETRAY)) != 0) {
- printf ("input_vcd: CDROMCLOSETRAY failed: %s\n", strerror(errno));
- }
- break;
- case CDS_DISC_OK:
- if((ret = ioctl(fd, CDROMEJECT)) != 0) {
- printf ("input_vcd: CDROMEJECT failed: %s\n", strerror(errno));
- }
- break;
- }
- }
- else {
- printf ("input_vcd: CDROM_DRIVE_STATUS failed: %s\n",
- strerror(errno));
- close(fd);
- return 0;
- }
- }
- close(fd);
-
- return 1;
-}
-#elif defined (__FreeBSD__)
-static int vcd_class_eject_media (input_class_t *this_gen) {
- vcd_input_class_t *this = (vcd_input_class_t *) this_gen;
- int fd;
-
- if ((fd = open(this->device, O_RDONLY|O_NONBLOCK)) > -1) {
- if (ioctl(fd, CDIOCALLOW) == -1) {
- perror("ioctl(cdromallow)");
- } else {
- if (ioctl(fd, CDIOCEJECT) == -1) {
- perror("ioctl(cdromeject)");
- }
- }
- close(fd);
- }
-
- return 1;
-}
-#elif defined (__sun)
-static int vcd_class_eject_media (input_class_t *this_gen) {
- vcd_input_class_t *this = (vcd_input_class_t *) this_gen;
- int fd, ret;
-
- if ((fd = open(this->device, O_RDONLY|O_NONBLOCK)) > -1) {
- if ((ret = ioctl(fd, CDROMEJECT)) != 0) {
- printf ("input_vcd: CDROMEJECT failed: %s\n", strerror(errno));
- }
- close(fd);
- }
+ vcd_input_class_t *this = (vcd_input_class_t *) this_gen;
- return 1;
+ return media_eject_media (this->device);
}
-#endif
static xine_mrl_t **vcd_class_get_dir (input_class_t *this_gen, const char *filename,
int *num_files) {
diff --git a/src/input/media_helper.c b/src/input/media_helper.c
new file mode 100644
index 000000000..8c71e09f7
--- /dev/null
+++ b/src/input/media_helper.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2000-2002 the xine project,
+ *
+ * This file is part of xine, a free video player.
+ *
+ * xine is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * xine is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ */
+
+/* Standard includes */
+#include "config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <string.h>
+
+#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
+#include <sys/cdio.h> /* CDIOCALLOW etc... */
+#elif defined(HAVE_LINUX_CDROM_H)
+#include <linux/cdrom.h>
+#elif defined(HAVE_SYS_CDIO_H)
+#include <sys/cdio.h>
+#else
+#warning "This might not compile due to missing cdrom ioctls"
+#endif
+
+
+#define LOG_MEDIA_EJECT
+
+static int media_umount_media(char *device)
+{
+ char *argv[10];
+ int i;
+ pid_t pid;
+ int status;
+
+ argv[0]="umount";
+ argv[1]=device;
+ argv[2]=0;
+ pid=fork();
+ if (pid == 0) {
+ i= execv("/bin/umount", argv);
+ exit(127);
+ }
+ do {
+ if(waitpid(pid, &status, 0) == -1) {
+ if (errno != EINTR)
+ return -1;
+ }
+ else {
+ return WEXITSTATUS(status);
+ }
+ } while(1);
+
+ return -1;
+}
+
+int media_eject_media (char *device) {
+ int ret, status;
+ int fd;
+
+ /* printf("input_dvd: Eject Device %s current device %s opened=%d handle=%p trying...\n",device, this->current_dvd_device, this->opened, this->dvdnav); */
+ media_umount_media(device);
+ /**********
+ printf("ipnut_dvd: umount result: %s\n",
+ strerror(errno));
+ ***********/
+ if ((fd = open (device, O_RDONLY|O_NONBLOCK)) > -1) {
+
+#if defined (__linux__)
+ if((status = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT)) > 0) {
+ switch(status) {
+ case CDS_TRAY_OPEN:
+ if((ret = ioctl(fd, CDROMCLOSETRAY)) != 0) {
+#ifdef LOG_MEDIA_EJECT
+ printf("input_dvd: CDROMCLOSETRAY failed: %s\n",
+ strerror(errno));
+#endif
+ }
+ break;
+ case CDS_DISC_OK:
+ if((ret = ioctl(fd, CDROMEJECT)) != 0) {
+#ifdef LOG_MEDIA_EJECT
+ printf("input_dvd: CDROMEJECT failed: %s\n", strerror(errno));
+#endif
+ }
+ break;
+ }
+ }
+ else {
+#ifdef LOG_MEDIA_EJECT
+ printf("input_dvd: CDROM_DRIVE_STATUS failed: %s\n",
+ strerror(errno));
+#endif
+ close(fd);
+ return 0;
+ }
+#elif defined (__NetBSD__) || defined (__OpenBSD__) || defined (__FreeBSD__)
+
+ if (ioctl(fd, CDIOCALLOW) == -1) {
+ perror("ioctl(cdromallow)");
+ } else {
+ if (ioctl(fd, CDIOCEJECT) == -1) {
+ perror("ioctl(cdromeject)");
+ }
+ }
+
+#endif
+
+ close(fd);
+ } else {
+ printf("input_dvd: Device %s failed to open during eject calls\n",device);
+ }
+ return 1;
+}
+
diff --git a/src/input/media_helper.h b/src/input/media_helper.h
new file mode 100644
index 000000000..41aeb6cb2
--- /dev/null
+++ b/src/input/media_helper.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2000-2002 the xine project,
+ *
+ * This file is part of xine, a free video player.
+ *
+ * xine is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * xine is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ */
+
+int media_eject_media (char *device);
+