changeset 25040:ea694492cb2e

Open device file only right before we need it, so we do not have to add close to all the abort code-paths
author reimar
date Sat, 17 Nov 2007 18:26:25 +0000
parents b16e023e5751
children 985bb0dc612e
files stream/stream_dvd.c
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/stream/stream_dvd.c	Sat Nov 17 18:23:46 2007 +0000
+++ b/stream/stream_dvd.c	Sat Nov 17 18:26:25 2007 +0000
@@ -65,11 +65,6 @@
 
   if (!S_ISBLK(st.st_mode)) return; /* not a block device */
 
-  if ((fd = open(device, O_RDWR | O_NONBLOCK)) == -1) {
-    mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_DVDspeedCantOpen);
-    return;
-  }
-
   if (speed < 100) { /* speed times 1350KB/s (DVD single speed) */
     speed *= 1350;
   }
@@ -114,6 +109,11 @@
   AV_WB16(buffer + 18, 1000);
   AV_WB16(buffer + 26, 1000);
 
+  if ((fd = open(device, O_RDWR | O_NONBLOCK)) == -1) {
+    mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_DVDspeedCantOpen);
+    return;
+  }
+
   if (ioctl(fd, SG_IO, &sghdr) < 0) {
     mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_DVDlimitFail);
   } else