From 36ec82183681b5c751026e2c2d121cb4bd5bc87b Mon Sep 17 00:00:00 2001 From: reimar Date: Tue, 10 Nov 2009 23:15:48 +0000 Subject: Move arrays used by both dvd and dvdnav to dvd_common. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29889 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/stream_dvd_common.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'stream/stream_dvd_common.c') diff --git a/stream/stream_dvd_common.c b/stream/stream_dvd_common.c index 9302b5670b..f28e2c53e5 100644 --- a/stream/stream_dvd_common.c +++ b/stream/stream_dvd_common.c @@ -3,6 +3,9 @@ #include #include "stream_dvd_common.h" +const char * const dvd_audio_stream_types[8] = { "ac3","unknown","mpeg1","mpeg2ext","lpcm","unknown","dts" }; +const char * const dvd_audio_stream_channels[6] = { "mono", "stereo", "unknown", "unknown", "5.1/6.1", "5.1" }; + /** \brief Converts DVD time structure to milliseconds. \param *dev the DVD time structure to convert -- cgit v1.2.3 From 0d40667c8cf05c8957ad2e1bfec41ca41c88888a Mon Sep 17 00:00:00 2001 From: reimar Date: Tue, 10 Nov 2009 23:20:05 +0000 Subject: Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed support for dvdnav. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29890 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/stream_dvd.c | 73 --------------------------------------------- stream/stream_dvd_common.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++ stream/stream_dvd_common.h | 2 ++ stream/stream_dvdnav.c | 3 ++ 4 files changed, 79 insertions(+), 73 deletions(-) (limited to 'stream/stream_dvd_common.c') diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index baa535500e..557cdaa4be 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -43,79 +43,6 @@ static char* dvd_device_current; int dvd_angle=1; -int dvd_speed=0; /* 0 => don't touch speed */ - -static void dvd_set_speed(char *device, unsigned speed) -{ -#if defined(__linux__) && defined(SG_IO) && defined(GPCMD_SET_STREAMING) - int fd; - unsigned char buffer[28]; - unsigned char cmd[12]; - struct sg_io_hdr sghdr; - struct stat st; - - memset(&st, 0, sizeof(st)); - - if (stat(device, &st) == -1) return; - - if (!S_ISBLK(st.st_mode)) return; /* not a block device */ - - switch (speed) { - case 0: /* don't touch speed setting */ - return; - case -1: /* restore default value */ - if (dvd_speed == 0) return; /* we haven't touched the speed setting */ - mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_DVDrestoreSpeed); - break; - default: /* limit to KB/s */ - // speed < 100 is multiple of DVD single speed (1350KB/s) - if (speed < 100) - speed *= 1350; - mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_DVDlimitSpeed, speed); - break; - } - - memset(&sghdr, 0, sizeof(sghdr)); - sghdr.interface_id = 'S'; - sghdr.timeout = 5000; - sghdr.dxfer_direction = SG_DXFER_TO_DEV; - sghdr.dxfer_len = sizeof(buffer); - sghdr.dxferp = buffer; - sghdr.cmd_len = sizeof(cmd); - sghdr.cmdp = cmd; - - memset(cmd, 0, sizeof(cmd)); - cmd[0] = GPCMD_SET_STREAMING; - cmd[10] = sizeof(buffer); - - memset(buffer, 0, sizeof(buffer)); - /* first sector 0, last sector 0xffffffff */ - AV_WB32(buffer + 8, 0xffffffff); - if (speed == -1) - buffer[0] = 4; /* restore default */ - else { - /* kilobyte */ - AV_WB32(buffer + 12, speed); - AV_WB32(buffer + 20, speed); - } - /* 1 second */ - AV_WB16(buffer + 18, 1000); - AV_WB16(buffer + 26, 1000); - - fd = open(device, O_RDWR | O_NONBLOCK); - if (fd == -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 - mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_DVDlimitOk); - - close(fd); -#endif -} #define LIBDVDREAD_VERSION(maj,min,micro) ((maj)*10000 + (min)*100 + (micro)) /* diff --git a/stream/stream_dvd_common.c b/stream/stream_dvd_common.c index f28e2c53e5..330ace9b62 100644 --- a/stream/stream_dvd_common.c +++ b/stream/stream_dvd_common.c @@ -6,6 +6,80 @@ const char * const dvd_audio_stream_types[8] = { "ac3","unknown","mpeg1","mpeg2ext","lpcm","unknown","dts" }; const char * const dvd_audio_stream_channels[6] = { "mono", "stereo", "unknown", "unknown", "5.1/6.1", "5.1" }; +int dvd_speed=0; /* 0 => don't touch speed */ + +void dvd_set_speed(char *device, unsigned speed) +{ +#if defined(__linux__) && defined(SG_IO) && defined(GPCMD_SET_STREAMING) + int fd; + unsigned char buffer[28]; + unsigned char cmd[12]; + struct sg_io_hdr sghdr; + struct stat st; + + memset(&st, 0, sizeof(st)); + + if (stat(device, &st) == -1) return; + + if (!S_ISBLK(st.st_mode)) return; /* not a block device */ + + switch (speed) { + case 0: /* don't touch speed setting */ + return; + case -1: /* restore default value */ + if (dvd_speed == 0) return; /* we haven't touched the speed setting */ + mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_DVDrestoreSpeed); + break; + default: /* limit to KB/s */ + // speed < 100 is multiple of DVD single speed (1350KB/s) + if (speed < 100) + speed *= 1350; + mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_DVDlimitSpeed, speed); + break; + } + + memset(&sghdr, 0, sizeof(sghdr)); + sghdr.interface_id = 'S'; + sghdr.timeout = 5000; + sghdr.dxfer_direction = SG_DXFER_TO_DEV; + sghdr.dxfer_len = sizeof(buffer); + sghdr.dxferp = buffer; + sghdr.cmd_len = sizeof(cmd); + sghdr.cmdp = cmd; + + memset(cmd, 0, sizeof(cmd)); + cmd[0] = GPCMD_SET_STREAMING; + cmd[10] = sizeof(buffer); + + memset(buffer, 0, sizeof(buffer)); + /* first sector 0, last sector 0xffffffff */ + AV_WB32(buffer + 8, 0xffffffff); + if (speed == -1) + buffer[0] = 4; /* restore default */ + else { + /* kilobyte */ + AV_WB32(buffer + 12, speed); + AV_WB32(buffer + 20, speed); + } + /* 1 second */ + AV_WB16(buffer + 18, 1000); + AV_WB16(buffer + 26, 1000); + + fd = open(device, O_RDWR | O_NONBLOCK); + if (fd == -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 + mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_DVDlimitOk); + + close(fd); +#endif +} + /** \brief Converts DVD time structure to milliseconds. \param *dev the DVD time structure to convert diff --git a/stream/stream_dvd_common.h b/stream/stream_dvd_common.h index c320e27e22..b5e86c1162 100644 --- a/stream/stream_dvd_common.h +++ b/stream/stream_dvd_common.h @@ -9,6 +9,8 @@ extern char *dvd_device; extern const char * const dvd_audio_stream_channels[6]; extern const char * const dvd_audio_stream_types[8]; +extern int dvd_speed; +void dvd_set_speed(char *device, unsigned speed); int mp_dvdtimetomsec(dvd_time_t *dt); #endif /* MPLAYER_STREAM_DVD_COMMON_H */ diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c index 1a93611182..eafc922f80 100644 --- a/stream/stream_dvdnav.c +++ b/stream/stream_dvdnav.c @@ -87,6 +87,8 @@ static dvdnav_priv_t * new_dvdnav_stream(char * filename) { return NULL; } + dvd_set_speed(priv->filename, dvd_speed); + if(dvdnav_open(&(priv->dvdnav),priv->filename)!=DVDNAV_STATUS_OK) { free(priv->filename); @@ -291,6 +293,7 @@ static void stream_dvdnav_close(stream_t *s) { dvdnav_priv_t *priv = s->priv; dvdnav_close(priv->dvdnav); priv->dvdnav = NULL; + dvd_set_speed(priv->filename, -1); free(priv); } -- cgit v1.2.3 From 7694e9074d0242a0abe4d772cc54e334c80d049b Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 11 Nov 2009 09:28:21 +0000 Subject: Move headers related to setting dvd speed to dvd_common. This makes -dvd-speed work again. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29894 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/stream_dvd.c | 14 -------------- stream/stream_dvd_common.c | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 14 deletions(-) (limited to 'stream/stream_dvd_common.c') diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index 557cdaa4be..46e7100ec1 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -5,25 +5,12 @@ #include #include #include -#include #include #include "config.h" #include "mp_msg.h" #include "help_mp.h" -#ifdef __FreeBSD__ -#include -#endif - -#ifdef __linux__ -#include -#include -#include -#include -#include -#endif - #include #include @@ -39,7 +26,6 @@ #include "stream_dvd.h" #include "stream_dvd_common.h" #include "libmpdemux/demuxer.h" -#include "libavutil/intreadwrite.h" static char* dvd_device_current; int dvd_angle=1; diff --git a/stream/stream_dvd_common.c b/stream/stream_dvd_common.c index 330ace9b62..9e4da0955d 100644 --- a/stream/stream_dvd_common.c +++ b/stream/stream_dvd_common.c @@ -1,7 +1,26 @@ #include "config.h" +#include #include +#include +#include +#include #include +#ifdef __FreeBSD__ +#include +#endif + +#ifdef __linux__ +#include +#include +#include +#include +#include +#endif + +#include "mp_msg.h" +#include "help_mp.h" #include "stream_dvd_common.h" +#include "libavutil/intreadwrite.h" const char * const dvd_audio_stream_types[8] = { "ac3","unknown","mpeg1","mpeg2ext","lpcm","unknown","dts" }; const char * const dvd_audio_stream_channels[6] = { "mono", "stereo", "unknown", "unknown", "5.1/6.1", "5.1" }; -- cgit v1.2.3