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