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