annotate libmpdvdkit2/device.c @ 14100:7b764c9e2959

new sync, first was fucked up
author nicolas
date Sat, 04 Dec 2004 11:01:19 +0000
parents 5dc4583b1901
children c2ddedd0619e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
2 * device.h: DVD device access
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
3 *****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
4 * Copyright (C) 1998-2002 VideoLAN
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
5 * $Id$
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
6 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
7 * Authors: Stéphane Borel <stef@via.ecp.fr>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
8 * Samuel Hocevar <sam@zoy.org>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
9 * Håkan Hjort <d95hjort@dtek.chalmers.se>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
10 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
14 * (at your option) any later version.
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
15 *
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
19 * GNU General Public License for more details.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
20 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
24 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
25
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
26 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
27 * Preamble
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
28 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
29 #include "config.h"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
30
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
31 #include <stdio.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
32 #include <stdlib.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
33 #include <string.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
34 #include <sys/types.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
35 #include <sys/stat.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
36 #include <fcntl.h>
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
37 #include <unistd.h>
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
38 #include <limits.h>
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
39
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
40 #if defined( WIN32 ) && !defined( SYS_CYGWIN )
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
41 # include <io.h> /* read() */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
42 #else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
43 # include <sys/uio.h> /* struct iovec */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
44 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
45
7033
596919e4f601 apply mplayer-specific patches
arpi
parents: 7027
diff changeset
46 #include "dvdcss.h"
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
47
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
48 #include "common.h"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
49 #include "css.h"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
50 #include "libdvdcss.h"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
51 #include "ioctl.h"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
52 #include "device.h"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
53
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
54 /*****************************************************************************
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
55 * Device reading prototypes
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
56 *****************************************************************************/
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
57 static int libc_open ( dvdcss_t, char const * );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
58 static int libc_seek ( dvdcss_t, int );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
59 static int libc_read ( dvdcss_t, void *, int );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
60 static int libc_readv ( dvdcss_t, struct iovec *, int );
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
61
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
62 #ifdef WIN32
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
63 static int win2k_open ( dvdcss_t, char const * );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
64 static int aspi_open ( dvdcss_t, char const * );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
65 static int win2k_seek ( dvdcss_t, int );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
66 static int aspi_seek ( dvdcss_t, int );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
67 static int win2k_read ( dvdcss_t, void *, int );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
68 static int aspi_read ( dvdcss_t, void *, int );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
69 static int win_readv ( dvdcss_t, struct iovec *, int );
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
70
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
71 static int aspi_read_internal ( int, void *, int );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
72 #endif
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
73
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
74 int _dvdcss_use_ioctls( dvdcss_t dvdcss )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
75 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
76 #if defined( WIN32 )
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
77 if( dvdcss->b_file )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
78 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
79 return 0;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
80 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
81
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
82 /* FIXME: implement this for Windows */
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
83 if( WIN2K )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
84 {
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
85 return 1;
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
86 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
87 else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
88 {
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
89 return 1;
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
90 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
91 #else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
92 struct stat fileinfo;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
93 int ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
94
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
95 ret = fstat( dvdcss->i_fd, &fileinfo );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
96 if( ret < 0 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
97 {
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
98 return 1; /* What to do? Be conservative and try to use the ioctls */
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
99 }
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
100
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
101 /* Complete this list and check that we test for the right things
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
102 * (I've assumed for all OSs that 'r', (raw) device, are char devices
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
103 * and those that don't contain/use an 'r' in the name are block devices)
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
104 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
105 * Linux needs a block device
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
106 * Solaris needs a char device
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
107 * Darwin needs a char device
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
108 * OpenBSD needs a char device
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
109 * NetBSD needs a char device
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
110 * FreeBSD can use either the block or the char device
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
111 * BSD/OS can use either the block or the char device
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
112 */
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
113
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
114 /* Check if this is a block/char device */
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
115 if( S_ISBLK( fileinfo.st_mode ) ||
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
116 S_ISCHR( fileinfo.st_mode ) )
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
117 {
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
118 return 1;
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
119 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
120 else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
121 {
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
122 return 0;
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
123 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
124 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
125 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
126
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
127 int _dvdcss_open ( dvdcss_t dvdcss )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
128 {
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
129 char psz_debug[200];
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
130 char const *psz_device = dvdcss->psz_device;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
131
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
132 snprintf( psz_debug, 199, "opening target `%s'", psz_device );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
133 psz_debug[199] = '\0';
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
134 _dvdcss_debug( dvdcss, psz_debug );
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
135
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
136 #if defined( WIN32 )
13011
5dc4583b1901 mpdvdkit now accepts X:\ as a device name, as well as X:
joey
parents: 10441
diff changeset
137 dvdcss->b_file = 1;
5dc4583b1901 mpdvdkit now accepts X:\ as a device name, as well as X:
joey
parents: 10441
diff changeset
138 /* If device is "X:" or "X:\", we are not actually opening a file. */
5dc4583b1901 mpdvdkit now accepts X:\ as a device name, as well as X:
joey
parents: 10441
diff changeset
139 if (psz_device[0] && psz_device[1] == ':' &&
5dc4583b1901 mpdvdkit now accepts X:\ as a device name, as well as X:
joey
parents: 10441
diff changeset
140 (!psz_device[2] || (psz_device[2] == '\\' && !psz_device[3])))
5dc4583b1901 mpdvdkit now accepts X:\ as a device name, as well as X:
joey
parents: 10441
diff changeset
141 dvdcss->b_file = 0;
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
142
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
143 /* Initialize readv temporary buffer */
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
144 dvdcss->p_readv_buffer = NULL;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
145 dvdcss->i_readv_buf_size = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
146
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
147 if( !dvdcss->b_file && WIN2K )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
148 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
149 _dvdcss_debug( dvdcss, "using Win2K API for access" );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
150 dvdcss->pf_seek = win2k_seek;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
151 dvdcss->pf_read = win2k_read;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
152 dvdcss->pf_readv = win_readv;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
153 return win2k_open( dvdcss, psz_device );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
154 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
155 else if( !dvdcss->b_file )
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
156 {
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
157 _dvdcss_debug( dvdcss, "using ASPI for access" );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
158 dvdcss->pf_seek = aspi_seek;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
159 dvdcss->pf_read = aspi_read;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
160 dvdcss->pf_readv = win_readv;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
161 return aspi_open( dvdcss, psz_device );
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
162 }
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
163 else
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
164 #endif
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
165 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
166 _dvdcss_debug( dvdcss, "using libc for access" );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
167 dvdcss->pf_seek = libc_seek;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
168 dvdcss->pf_read = libc_read;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
169 dvdcss->pf_readv = libc_readv;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
170 return libc_open( dvdcss, psz_device );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
171 }
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
172 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
173
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
174 #ifndef WIN32
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
175 int _dvdcss_raw_open ( dvdcss_t dvdcss, char const *psz_device )
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
176 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
177 dvdcss->i_raw_fd = open( psz_device, 0 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
178
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
179 if( dvdcss->i_raw_fd == -1 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
180 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
181 _dvdcss_error( dvdcss, "failed opening raw device, continuing" );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
182 return -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
183 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
184 else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
185 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
186 dvdcss->i_read_fd = dvdcss->i_raw_fd;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
187 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
188
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
189 return 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
190 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
191 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
192
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
193 int _dvdcss_close ( dvdcss_t dvdcss )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
194 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
195 #if defined( WIN32 )
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
196 if( dvdcss->b_file )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
197 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
198 close( dvdcss->i_fd );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
199 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
200 else if( WIN2K )
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
201 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
202 CloseHandle( (HANDLE) dvdcss->i_fd );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
203 }
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
204 else /* ASPI */
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
205 {
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
206 struct w32_aspidev *fd = (struct w32_aspidev *) dvdcss->i_fd;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
207
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
208 /* Unload aspi and free w32_aspidev structure */
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
209 FreeLibrary( (HMODULE) fd->hASPI );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
210 free( (void*) dvdcss->i_fd );
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
211 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
212
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
213 /* Free readv temporary buffer */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
214 if( dvdcss->p_readv_buffer )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
215 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
216 free( dvdcss->p_readv_buffer );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
217 dvdcss->p_readv_buffer = NULL;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
218 dvdcss->i_readv_buf_size = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
219 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
220
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
221 return 0;
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
222 #else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
223 close( dvdcss->i_fd );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
224
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
225 if( dvdcss->i_raw_fd >= 0 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
226 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
227 close( dvdcss->i_raw_fd );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
228 dvdcss->i_raw_fd = -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
229 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
230
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
231 return 0;
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
232 #endif
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
233 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
234
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
235 /* Following functions are local */
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
236
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
237 /*****************************************************************************
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
238 * Open commands.
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
239 *****************************************************************************/
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
240 static int libc_open ( dvdcss_t dvdcss, char const *psz_device )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
241 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
242 #if !defined( WIN32 )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
243 dvdcss->i_fd = dvdcss->i_read_fd = open( psz_device, 0 );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
244 #else
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
245 dvdcss->i_fd = dvdcss->i_read_fd = open( psz_device, O_BINARY );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
246 #endif
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
247
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
248 if( dvdcss->i_fd == -1 )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
249 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
250 _dvdcss_error( dvdcss, "failed opening device" );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
251 return -1;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
252 }
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
253
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
254 dvdcss->i_pos = 0;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
255
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
256 return 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
257 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
258
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
259 #if defined( WIN32 )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
260 static int win2k_open ( dvdcss_t dvdcss, char const *psz_device )
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
261 {
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
262 char psz_dvd[7];
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
263 _snprintf( psz_dvd, 7, "\\\\.\\%c:", psz_device[0] );
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
264
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
265 /* To work around an M$ bug in IOCTL_DVD_READ_STRUCTURE, we need read
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
266 * _and_ write access to the device (so we can make SCSI Pass Through
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
267 * Requests). Unfortunately this is only allowed if you have
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
268 * administrator priviledges so we allow for a fallback method with
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
269 * only read access to the device (in this case ioctl_ReadCopyright()
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
270 * won't send back the right result).
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
271 * (See Microsoft Q241374: Read and Write Access Required for SCSI
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
272 * Pass Through Requests) */
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
273 (HANDLE) dvdcss->i_fd =
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
274 CreateFile( psz_dvd, GENERIC_READ | GENERIC_WRITE,
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
275 FILE_SHARE_READ | FILE_SHARE_WRITE,
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
276 NULL, OPEN_EXISTING,
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
277 FILE_FLAG_RANDOM_ACCESS, NULL );
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
278
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
279 if( (HANDLE) dvdcss->i_fd == INVALID_HANDLE_VALUE )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
280 (HANDLE) dvdcss->i_fd =
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
281 CreateFile( psz_dvd, GENERIC_READ, FILE_SHARE_READ,
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
282 NULL, OPEN_EXISTING,
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
283 FILE_FLAG_RANDOM_ACCESS, NULL );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
284
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
285 if( (HANDLE) dvdcss->i_fd == INVALID_HANDLE_VALUE )
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
286 {
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
287 _dvdcss_error( dvdcss, "failed opening device" );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
288 return -1;
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
289 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
290
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
291 dvdcss->i_pos = 0;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
292
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
293 return 0;
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
294 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
295
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
296 static int aspi_open( dvdcss_t dvdcss, char const * psz_device )
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
297 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
298 HMODULE hASPI;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
299 DWORD dwSupportInfo;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
300 struct w32_aspidev *fd;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
301 int i, j, i_hostadapters;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
302 long (*lpGetSupport)( void );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
303 long (*lpSendCommand)( void* );
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
304 char c_drive = psz_device[0];
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
305
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
306 /* load aspi and init w32_aspidev structure */
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
307 hASPI = LoadLibrary( "wnaspi32.dll" );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
308 if( hASPI == NULL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
309 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
310 _dvdcss_error( dvdcss, "unable to load wnaspi32.dll" );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
311 return -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
312 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
313
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
314 (FARPROC) lpGetSupport = GetProcAddress( hASPI, "GetASPI32SupportInfo" );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
315 (FARPROC) lpSendCommand = GetProcAddress( hASPI, "SendASPI32Command" );
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
316
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
317 if(lpGetSupport == NULL || lpSendCommand == NULL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
318 {
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
319 _dvdcss_error( dvdcss, "unable to get aspi function pointers" );
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
320 FreeLibrary( hASPI );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
321 return -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
322 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
323
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
324 dwSupportInfo = lpGetSupport();
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
325
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
326 if( HIBYTE( LOWORD ( dwSupportInfo ) ) == SS_NO_ADAPTERS )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
327 {
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
328 _dvdcss_error( dvdcss, "no ASPI adapters found" );
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
329 FreeLibrary( hASPI );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
330 return -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
331 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
332
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
333 if( HIBYTE( LOWORD ( dwSupportInfo ) ) != SS_COMP )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
334 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
335 _dvdcss_error( dvdcss, "unable to initalize aspi layer" );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
336 FreeLibrary( hASPI );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
337 return -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
338 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
339
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
340 i_hostadapters = LOBYTE( LOWORD( dwSupportInfo ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
341 if( i_hostadapters == 0 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
342 {
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
343 _dvdcss_error( dvdcss, "no ASPI adapters ready" );
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
344 FreeLibrary( hASPI );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
345 return -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
346 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
347
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
348 fd = malloc( sizeof( struct w32_aspidev ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
349 if( fd == NULL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
350 {
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
351 _dvdcss_error( dvdcss, "not enough memory" );
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
352 FreeLibrary( hASPI );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
353 return -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
354 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
355
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
356 fd->i_blocks = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
357 fd->hASPI = (long) hASPI;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
358 fd->lpSendCommand = lpSendCommand;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
359
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
360 c_drive = c_drive > 'Z' ? c_drive - 'a' : c_drive - 'A';
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
361
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
362 for( i = 0; i < i_hostadapters; i++ )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
363 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
364 for( j = 0; j < 15; j++ )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
365 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
366 struct SRB_GetDiskInfo srbDiskInfo;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
367
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
368 srbDiskInfo.SRB_Cmd = SC_GET_DISK_INFO;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
369 srbDiskInfo.SRB_HaId = i;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
370 srbDiskInfo.SRB_Flags = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
371 srbDiskInfo.SRB_Hdr_Rsvd = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
372 srbDiskInfo.SRB_Target = j;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
373 srbDiskInfo.SRB_Lun = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
374
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
375 lpSendCommand( (void*) &srbDiskInfo );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
376
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
377 if( (srbDiskInfo.SRB_Status == SS_COMP) &&
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
378 (srbDiskInfo.SRB_Int13HDriveInfo == c_drive) )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
379 {
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
380 /* Make sure this is a cdrom device */
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
381 struct SRB_GDEVBlock srbGDEVBlock;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
382
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
383 memset( &srbGDEVBlock, 0, sizeof(struct SRB_GDEVBlock) );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
384 srbGDEVBlock.SRB_Cmd = SC_GET_DEV_TYPE;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
385 srbGDEVBlock.SRB_HaId = i;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
386 srbGDEVBlock.SRB_Target = j;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
387
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
388 lpSendCommand( (void*) &srbGDEVBlock );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
389
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
390 if( ( srbGDEVBlock.SRB_Status == SS_COMP ) &&
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
391 ( srbGDEVBlock.SRB_DeviceType == DTYPE_CDROM ) )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
392 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
393 fd->i_sid = MAKEWORD( i, j );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
394 dvdcss->i_fd = (int) fd;
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
395 dvdcss->i_pos = 0;
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
396 return 0;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
397 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
398 else
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
399 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
400 free( (void*) fd );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
401 FreeLibrary( hASPI );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
402 _dvdcss_error( dvdcss,"this is not a cdrom drive" );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
403 return -1;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
404 }
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
405 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
406 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
407 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
408
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
409 free( (void*) fd );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
410 FreeLibrary( hASPI );
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
411 _dvdcss_error( dvdcss, "unable to get haid and target (aspi)" );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
412 return -1;
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
413 }
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
414 #endif
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
415
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
416 /*****************************************************************************
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
417 * Seek commands.
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
418 *****************************************************************************/
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
419 static int libc_seek( dvdcss_t dvdcss, int i_blocks )
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
420 {
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
421 off_t i_seek;
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
422
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
423 if( dvdcss->i_pos == i_blocks )
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
424 {
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
425 /* We are already in position */
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
426 return i_blocks;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
427 }
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
428
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
429 i_seek = lseek( dvdcss->i_read_fd,
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
430 (off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE, SEEK_SET );
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
431
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
432 if( i_seek < 0 )
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
433 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
434 _dvdcss_error( dvdcss, "seek error" );
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
435 dvdcss->i_pos = -1;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
436 return i_seek;
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
437 }
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
438
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
439 dvdcss->i_pos = i_seek / DVDCSS_BLOCK_SIZE;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
440
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
441 return dvdcss->i_pos;
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
442 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
443
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
444 #if defined( WIN32 )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
445 static int win2k_seek( dvdcss_t dvdcss, int i_blocks )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
446 {
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
447 LARGE_INTEGER li_seek;
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
448
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
449 #ifndef INVALID_SET_FILE_POINTER
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
450 # define INVALID_SET_FILE_POINTER ((DWORD)-1)
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
451 #endif
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
452
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
453 if( dvdcss->i_pos == i_blocks )
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
454 {
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
455 /* We are already in position */
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
456 return i_blocks;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
457 }
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
458
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
459 li_seek.QuadPart = (LONGLONG)i_blocks * DVDCSS_BLOCK_SIZE;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
460
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
461 li_seek.LowPart = SetFilePointer( (HANDLE) dvdcss->i_fd,
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
462 li_seek.LowPart,
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
463 &li_seek.HighPart, FILE_BEGIN );
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
464 if( (li_seek.LowPart == INVALID_SET_FILE_POINTER)
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
465 && GetLastError() != NO_ERROR)
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
466 {
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
467 dvdcss->i_pos = -1;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
468 return -1;
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
469 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
470
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
471 dvdcss->i_pos = li_seek.QuadPart / DVDCSS_BLOCK_SIZE;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
472
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
473 return dvdcss->i_pos;
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
474 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
475
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
476 static int aspi_seek( dvdcss_t dvdcss, int i_blocks )
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
477 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
478 int i_old_blocks;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
479 char sz_buf[ DVDCSS_BLOCK_SIZE ];
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
480 struct w32_aspidev *fd = (struct w32_aspidev *) dvdcss->i_fd;
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
481
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
482 if( dvdcss->i_pos == i_blocks )
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
483 {
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
484 /* We are already in position */
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
485 return i_blocks;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
486 }
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
487
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
488 i_old_blocks = fd->i_blocks;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
489 fd->i_blocks = i_blocks;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
490
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
491 if( aspi_read_internal( dvdcss->i_fd, sz_buf, 1 ) == -1 )
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
492 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
493 fd->i_blocks = i_old_blocks;
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
494 dvdcss->i_pos = -1;
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
495 return -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
496 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
497
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
498 (fd->i_blocks)--;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
499
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
500 dvdcss->i_pos = fd->i_blocks;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
501
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
502 return dvdcss->i_pos;
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
503 }
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
504 #endif
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
505
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
506 /*****************************************************************************
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
507 * Read commands.
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
508 *****************************************************************************/
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
509 static int libc_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
510 {
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
511 off_t i_ret;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
512
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
513 i_ret = read( dvdcss->i_read_fd, p_buffer,
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
514 (off_t)i_blocks * DVDCSS_BLOCK_SIZE );
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
515
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
516 if( i_ret < 0 )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
517 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
518 _dvdcss_error( dvdcss, "read error" );
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
519 dvdcss->i_pos = -1;
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
520 return i_ret;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
521 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
522
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
523 /* Handle partial reads */
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
524 if( i_ret != (off_t)i_blocks * DVDCSS_BLOCK_SIZE )
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
525 {
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
526 int i_seek;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
527
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
528 dvdcss->i_pos = -1;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
529 i_seek = libc_seek( dvdcss, i_ret / DVDCSS_BLOCK_SIZE );
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
530 if( i_seek < 0 )
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
531 {
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
532 return i_seek;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
533 }
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
534
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
535 /* We have to return now so that i_pos isn't clobbered */
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
536 return i_ret / DVDCSS_BLOCK_SIZE;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
537 }
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
538
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
539 dvdcss->i_pos += i_ret / DVDCSS_BLOCK_SIZE;
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
540 return i_ret / DVDCSS_BLOCK_SIZE;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
541 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
542
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
543 #if defined( WIN32 )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
544 static int win2k_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
545 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
546 int i_bytes;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
547
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
548 if( !ReadFile( (HANDLE) dvdcss->i_fd, p_buffer,
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
549 i_blocks * DVDCSS_BLOCK_SIZE,
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
550 (LPDWORD)&i_bytes, NULL ) )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
551 {
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
552 dvdcss->i_pos = -1;
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
553 return -1;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
554 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
555
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
556 dvdcss->i_pos += i_bytes / DVDCSS_BLOCK_SIZE;
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
557 return i_bytes / DVDCSS_BLOCK_SIZE;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
558 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
559
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
560 static int aspi_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
561 {
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
562 int i_read = aspi_read_internal( dvdcss->i_fd, p_buffer, i_blocks );
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
563
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
564 if( i_read < 0 )
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
565 {
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
566 dvdcss->i_pos = -1;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
567 return i_read;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
568 }
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
569
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
570 dvdcss->i_pos += i_read;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
571 return i_read;
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
572 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
573 #endif
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
574
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
575 /*****************************************************************************
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
576 * Readv commands.
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
577 *****************************************************************************/
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
578 static int libc_readv ( dvdcss_t dvdcss, struct iovec *p_iovec, int i_blocks )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
579 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
580 #if defined( WIN32 )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
581 int i_index, i_len, i_total = 0;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
582 unsigned char *p_base;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
583 int i_bytes;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
584
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
585 for( i_index = i_blocks;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
586 i_index;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
587 i_index--, p_iovec++ )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
588 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
589 i_len = p_iovec->iov_len;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
590 p_base = p_iovec->iov_base;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
591
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
592 if( i_len <= 0 )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
593 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
594 continue;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
595 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
596
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
597 i_bytes = read( dvdcss->i_fd, p_base, i_len );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
598
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
599 if( i_bytes < 0 )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
600 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
601 /* One of the reads failed, too bad.
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
602 * We won't even bother returning the reads that went ok,
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
603 * and as in the posix spec the file postition is left
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
604 * unspecified after a failure */
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
605 dvdcss->i_pos = -1;
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
606 return -1;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
607 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
608
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
609 i_total += i_bytes;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
610
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
611 if( i_bytes != i_len )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
612 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
613 /* We reached the end of the file or a signal interrupted
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
614 * the read. Return a partial read. */
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
615 int i_seek;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
616
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
617 dvdcss->i_pos = -1;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
618 i_seek = libc_seek( dvdcss, i_total / DVDCSS_BLOCK_SIZE );
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
619 if( i_seek < 0 )
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
620 {
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
621 return i_seek;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
622 }
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
623
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
624 /* We have to return now so that i_pos isn't clobbered */
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
625 return i_total / DVDCSS_BLOCK_SIZE;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
626 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
627 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
628
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
629 dvdcss->i_pos += i_total / DVDCSS_BLOCK_SIZE;
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
630 return i_total / DVDCSS_BLOCK_SIZE;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
631 #else
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
632 int i_read = readv( dvdcss->i_read_fd, p_iovec, i_blocks );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
633
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
634 if( i_read < 0 )
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
635 {
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
636 dvdcss->i_pos = -1;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
637 return i_read;
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
638 }
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
639
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
640 dvdcss->i_pos += i_read / DVDCSS_BLOCK_SIZE;
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
641 return i_read / DVDCSS_BLOCK_SIZE;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
642 #endif
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
643 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
644
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
645 #if defined( WIN32 )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
646 /*****************************************************************************
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
647 * win_readv: vectored read using ReadFile for Win2K and ASPI for win9x
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
648 *****************************************************************************/
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
649 static int win_readv ( dvdcss_t dvdcss, struct iovec *p_iovec, int i_blocks )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
650 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
651 int i_index;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
652 int i_blocks_read, i_blocks_total = 0;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
653
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
654 /* Check the size of the readv temp buffer, just in case we need to
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
655 * realloc something bigger */
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
656 if( dvdcss->i_readv_buf_size < i_blocks * DVDCSS_BLOCK_SIZE )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
657 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
658 dvdcss->i_readv_buf_size = i_blocks * DVDCSS_BLOCK_SIZE;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
659
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
660 if( dvdcss->p_readv_buffer ) free( dvdcss->p_readv_buffer );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
661
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
662 /* Allocate a buffer which will be used as a temporary storage
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
663 * for readv */
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
664 dvdcss->p_readv_buffer = malloc( dvdcss->i_readv_buf_size );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
665 if( !dvdcss->p_readv_buffer )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
666 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
667 _dvdcss_error( dvdcss, " failed (readv)" );
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
668 dvdcss->i_pos = -1;
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
669 return -1;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
670 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
671 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
672
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
673 for( i_index = i_blocks; i_index; i_index-- )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
674 {
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
675 i_blocks_total += p_iovec[i_index-1].iov_len;
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
676 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
677
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
678 if( i_blocks_total <= 0 ) return 0;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
679
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
680 i_blocks_total /= DVDCSS_BLOCK_SIZE;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
681
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
682 if( WIN2K )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
683 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
684 unsigned long int i_bytes;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
685 if( !ReadFile( (HANDLE)dvdcss->i_fd, dvdcss->p_readv_buffer,
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
686 i_blocks_total * DVDCSS_BLOCK_SIZE, &i_bytes, NULL ) )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
687 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
688 /* The read failed... too bad.
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
689 * As in the posix spec the file postition is left
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
690 * unspecified after a failure */
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
691 dvdcss->i_pos = -1;
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
692 return -1;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
693 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
694 i_blocks_read = i_bytes / DVDCSS_BLOCK_SIZE;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
695 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
696 else /* Win9x */
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
697 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
698 i_blocks_read = aspi_read_internal( dvdcss->i_fd,
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
699 dvdcss->p_readv_buffer,
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
700 i_blocks_total );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
701 if( i_blocks_read < 0 )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
702 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
703 /* See above */
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
704 dvdcss->i_pos = -1;
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
705 return -1;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
706 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
707 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
708
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
709 /* We just have to copy the content of the temp buffer into the iovecs */
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
710 for( i_index = 0, i_blocks_total = i_blocks_read;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
711 i_blocks_total > 0;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
712 i_index++ )
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
713 {
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
714 memcpy( p_iovec[i_index].iov_base,
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
715 dvdcss->p_readv_buffer + (i_blocks_read - i_blocks_total)
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
716 * DVDCSS_BLOCK_SIZE,
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
717 p_iovec[i_index].iov_len );
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
718 /* if we read less blocks than asked, we'll just end up copying
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
719 * garbage, this isn't an issue as we return the number of
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
720 * blocks actually read */
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
721 i_blocks_total -= ( p_iovec[i_index].iov_len / DVDCSS_BLOCK_SIZE );
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
722 }
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
723
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
724 dvdcss->i_pos += i_blocks_read;
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
725 return i_blocks_read;
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
726 }
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
727
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
728 static int aspi_read_internal( int i_fd, void *p_data, int i_blocks )
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
729 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
730 HANDLE hEvent;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
731 struct SRB_ExecSCSICmd ssc;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
732 struct w32_aspidev *fd = (struct w32_aspidev *) i_fd;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
733
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
734 /* Create the transfer completion event */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
735 hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
736 if( hEvent == NULL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
737 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
738 return -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
739 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
740
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
741 memset( &ssc, 0, sizeof( ssc ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
742
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
743 ssc.SRB_Cmd = SC_EXEC_SCSI_CMD;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
744 ssc.SRB_Flags = SRB_DIR_IN | SRB_EVENT_NOTIFY;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
745 ssc.SRB_HaId = LOBYTE( fd->i_sid );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
746 ssc.SRB_Target = HIBYTE( fd->i_sid );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
747 ssc.SRB_SenseLen = SENSE_LEN;
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
748
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
749 ssc.SRB_PostProc = (LPVOID) hEvent;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
750 ssc.SRB_BufPointer = p_data;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
751 ssc.SRB_CDBLen = 12;
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
752
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
753 ssc.CDBByte[0] = 0xA8; /* RAW */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
754 ssc.CDBByte[2] = (UCHAR) (fd->i_blocks >> 24);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
755 ssc.CDBByte[3] = (UCHAR) (fd->i_blocks >> 16) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
756 ssc.CDBByte[4] = (UCHAR) (fd->i_blocks >> 8) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
757 ssc.CDBByte[5] = (UCHAR) (fd->i_blocks) & 0xff;
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
758
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
759 /* We have to break down the reads into 64kb pieces (ASPI restriction) */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
760 if( i_blocks > 32 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
761 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
762 ssc.SRB_BufLen = 32 * DVDCSS_BLOCK_SIZE;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
763 ssc.CDBByte[9] = 32;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
764 fd->i_blocks += 32;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
765
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
766 /* Initiate transfer */
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
767 ResetEvent( hEvent );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
768 fd->lpSendCommand( (void*) &ssc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
769
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 7033
diff changeset
770 /* transfer the next 64kb (aspi_read_internal is called recursively)
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
771 * We need to check the status of the read on return */
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
772 if( aspi_read_internal( i_fd,
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
773 (uint8_t*) p_data + 32 * DVDCSS_BLOCK_SIZE,
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
774 i_blocks - 32) < 0 )
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
775 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
776 return -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
777 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
778 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
779 else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
780 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
781 /* This is the last transfer */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
782 ssc.SRB_BufLen = i_blocks * DVDCSS_BLOCK_SIZE;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
783 ssc.CDBByte[9] = (UCHAR) i_blocks;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
784 fd->i_blocks += i_blocks;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
785
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8637
diff changeset
786 /* Initiate transfer */
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
787 ResetEvent( hEvent );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
788 fd->lpSendCommand( (void*) &ssc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
789
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
790 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
791
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
792 /* If the command has still not been processed, wait until it's finished */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
793 if( ssc.SRB_Status == SS_PENDING )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
794 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
795 WaitForSingleObject( hEvent, INFINITE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
796 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
797 CloseHandle( hEvent );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
798
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
799 /* check that the transfer went as planned */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
800 if( ssc.SRB_Status != SS_COMP )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
801 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
802 return -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
803 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
804
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
805 return i_blocks;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
806 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
807 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
808