[MPlayer-dev-eng] [PATCH] Linux DevFS/RTC revisited

Robert Cardell rbt at mtlb.co.uk
Fri Oct 25 21:39:16 CEST 2002


Hi,

About a month ago, I submitted a patch which checked for /dev/misc/rtc (the
default devfs location) at runtime. Sidik said it was okay (after a change or
two), so I assumed that meant he would commit, and left it there.
Anyway, with -pre9 out I see it wasn't committed for whatever reason, so here's
another one, along with a formal request that it be committed :). This one sets
the rtc node at configure time depending on whether --enable-linux-devfs is
used, since I noticed the OSS driver does the same thing. Tested and works
great for me. Patch is against -pre9.
I also changed the error message when it couldn't be opened - I didn't think it
was a good idea for MPlayer to recommend being setuid without any warnings.

--- MPlayer-0.90pre9/configure	2002-10-24 19:12:40.000000000 +0100
+++ MPlayer-0.90pre9.devfs/configure	2002-10-25 20:07:21.000000000 +0100
@@ -3396,8 +3396,14 @@
 fi
 if test "$_rtc" = yes ; then
   _def_rtc='#define HAVE_RTC 1'
+  if test "$_linux_devfs" = yes; then
+    _def_rtc_dev='#define PATH_DEV_RTC "/dev/misc/rtc"'
+  else
+    _def_rtc_dev='#define PATH_DEV_RTC "/dev/rtc"'
+  fi
 else
   _def_rtc='#undef HAVE_RTC'
+  _def_rtc_dev='#define PATH_DEV_RTC ""'
 fi
 
 
@@ -4621,6 +4627,9 @@
 /* define this to use RTC (/dev/rtc) for video timers (LINUX only) */
 $_def_rtc
 
+/* define this to be the path to the RTC device node */
+$_def_rtc_dev
+
 /* set up max. outburst. use 65536 for ALSA 0.5, for others 16384 is enough */
 #define MAX_OUTBURST 65536
 
--- MPlayer-0.90pre9/mplayer.c	2002-10-23 23:07:11.000000000 +0100
+++ MPlayer-0.90pre9.devfs/mplayer.c	2002-10-25 20:28:18.000000000 +0100
@@ -711,9 +711,11 @@
   if(!nortc)
   {
     // seteuid(0); /* Can't hurt to try to get root here */
-    if ((rtc_fd = open("/dev/rtc", O_RDONLY)) < 0)
-	mp_msg(MSGT_CPLAYER, MSGL_WARN, "Failed to open /dev/rtc: %s (mplayer should be setuid root or /dev/rtc should be readable by the user.)\n", strerror(errno));
-     else {
+    if ((rtc_fd = open(PATH_DEV_RTC, O_RDONLY)) < 0)
+    {
+	mp_msg(MSGT_CPLAYER, MSGL_WARN, "Failed to open " PATH_DEV_RTC ": %s\n", strerror(errno));
+	mp_msg(MSGT_CPLAYER, MSGL_HINT, "See the RTC section of the documentation for help.\n");
+    } else {
 	unsigned long irqp = 1024; /* 512 seemed OK. 128 is jerky. */
 
 	if (ioctl(rtc_fd, RTC_IRQP_SET, irqp) < 0) {




More information about the MPlayer-dev-eng mailing list