summaryrefslogtreecommitdiffstats
path: root/stream/stream_dvdnav.c
diff options
context:
space:
mode:
Diffstat (limited to 'stream/stream_dvdnav.c')
-rw-r--r--stream/stream_dvdnav.c134
1 files changed, 66 insertions, 68 deletions
diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c
index d858c51aca..5711d7de02 100644
--- a/stream/stream_dvdnav.c
+++ b/stream/stream_dvdnav.c
@@ -23,9 +23,7 @@
#include <stdlib.h>
#include <stdio.h>
-#include <unistd.h>
#include <string.h>
-#include <strings.h>
#include <errno.h>
#include <assert.h>
@@ -97,71 +95,71 @@ static const char *const mp_dvdnav_events[] = {
static void dvd_set_speed(stream_t *stream, 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 */
- MP_INFO(stream, "Restoring DVD speed... ");
- break;
- default: /* limit to <speed> KB/s */
- // speed < 100 is multiple of DVD single speed (1350KB/s)
- if (speed < 100)
- speed *= 1350;
- MP_INFO(stream, "Limiting DVD speed to %dKB/s... ", 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 {
- /* <speed> 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 | O_CLOEXEC);
- if (fd == -1) {
- MP_INFO(stream, "Couldn't open DVD device for writing, changing DVD speed needs write access.\n");
- return;
- }
-
- if (ioctl(fd, SG_IO, &sghdr) < 0)
- MP_INFO(stream, "failed\n");
- else
- MP_INFO(stream, "successful\n");
-
- close(fd);
+ 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 */
+ MP_INFO(stream, "Restoring DVD speed... ");
+ break;
+ default: /* limit to <speed> KB/s */
+ // speed < 100 is multiple of DVD single speed (1350KB/s)
+ if (speed < 100)
+ speed *= 1350;
+ MP_INFO(stream, "Limiting DVD speed to %dKB/s... ", 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 {
+ /* <speed> 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 | O_CLOEXEC);
+ if (fd == -1) {
+ MP_INFO(stream, "Couldn't open DVD device for writing, changing DVD speed needs write access.\n");
+ return;
+ }
+
+ if (ioctl(fd, SG_IO, &sghdr) < 0)
+ MP_INFO(stream, "failed\n");
+ else
+ MP_INFO(stream, "successful\n");
+
+ close(fd);
#endif
}
@@ -497,7 +495,7 @@ static int control(stream_t *stream, int cmd, void *arg)
struct stream_dvd_info_req *req = arg;
memset(req, 0, sizeof(*req));
req->num_subs = mp_dvdnav_number_of_subs(stream);
- assert(sizeof(uint32_t) == sizeof(unsigned int));
+ static_assert(sizeof(uint32_t) == sizeof(unsigned int), "");
memcpy(req->palette, priv->spu_clut, sizeof(req->palette));
return STREAM_OK;
}