From 17a2278031d0c6cd44c8778126d22552f1f2eb84 Mon Sep 17 00:00:00 2001 From: reimar Date: Sat, 17 Nov 2007 18:26:25 +0000 Subject: Open device file only right before we need it, so we do not have to add close to all the abort code-paths git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25068 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/stream_dvd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'stream') diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index cc831b5f96..b3c87a108d 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -65,11 +65,6 @@ static void dvd_set_speed(char *device, unsigned speed) 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 @@ static void dvd_set_speed(char *device, unsigned speed) 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 -- cgit v1.2.3