# HG changeset patch # User reimar # Date 1195323985 0 # Node ID ea694492cb2e0ae57f1905410d66a37fae347aac # Parent b16e023e5751650467a7c3970642b09cf4c619a0 Open device file only right before we need it, so we do not have to add close to all the abort code-paths diff -r b16e023e5751 -r ea694492cb2e stream/stream_dvd.c --- 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