Mercurial > mplayer.hg
annotate stream/vcd_read_fbsd.h @ 34115:3d7ee643b110
Port to Wine.
This makes MPlayer and the GUI compile and run as a Wine executable,
which is mainly to allow Windows code checking in a Linux environment.
In Makefile: Generalize the windres call by specifying option "-o" for
the output file.
In gui/win32/interface.c: Use the same function to create a thread as
Cygwin, and convert Windows style file names so that they are accessible
in the Linux environment.
In osdep/priority.c: Include windows.h.
In configure: Add system "Wine" which shall be considered (mostly) a
win32 system. Since winegcc by default compiles all files with the
"-fpic" flag, remove it, and remove all MinGW compatibility WIN32
defines, because we're not compiling for real Windows. Define to not use
Windows sockets (Wine uses different ones) and replace Windows' stricmp
by strcasecmp. Ensure that yasm's object format isn't win32 and that
HAVE_LINUX_DVD_STRUCT will be defined.
In stream/tvi_dshow.c: Define MP_DEFINE_LOCAL_GUID, because Wine's
DEFINE_GUID macro isn't compatible using "static" with it.
In loader/com.h: Rename the IIDs to become local ones, because Wine's
unknwn.h not only declares but defines them.
In mplayer.c: Don't define a SIGSEGV signal handler, or the Wine
executable will crash.
author | ib |
---|---|
date | Sat, 15 Oct 2011 13:20:52 +0000 |
parents | 3ab3212fb624 |
children | 3a192d8ecc56 |
rev | line source |
---|---|
30426
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
1 /* |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
2 * This file is part of MPlayer. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
3 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
7 * (at your option) any later version. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
8 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
12 * GNU General Public License for more details. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
13 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
17 */ |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
18 |
26029 | 19 #ifndef MPLAYER_VCD_READ_FBSD_H |
20 #define MPLAYER_VCD_READ_FBSD_H | |
26012 | 21 |
30165 | 22 #define _XOPEN_SOURCE 500 |
23 | |
23857 | 24 #include <sys/types.h> |
25 #include <inttypes.h> | |
30165 | 26 #include <unistd.h> |
23857 | 27 #include "libavutil/intreadwrite.h" |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
958
diff
changeset
|
28 #include <sys/cdio.h> |
30165 | 29 #include <sys/ioctl.h> |
23857 | 30 #if defined(__NetBSD__) || defined(__OpenBSD__) |
31 #define VCD_NETBSD 1 | |
32 #endif | |
33 #ifdef VCD_NETBSD | |
34 #include <sys/scsiio.h> | |
35 #define TOCADDR(te) ((te).data->addr) | |
36 #define READ_TOC CDIOREADTOCENTRYS | |
37 #else | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
958
diff
changeset
|
38 #include <sys/cdrio.h> |
23857 | 39 #define TOCADDR(te) ((te).entry.addr) |
40 #define READ_TOC CDIOREADTOCENTRY | |
41 #endif | |
26184
7ee4ae1648e6
Add missing header #includes to fix 'make checkheaders'.
diego
parents:
26029
diff
changeset
|
42 #include "mp_msg.h" |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
958
diff
changeset
|
43 |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
44 //=================== VideoCD ========================== |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
45 #define CDROM_LEADOUT 0xAA |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
46 |
1177
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1038
diff
changeset
|
47 typedef struct { |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1038
diff
changeset
|
48 uint8_t sync [12]; |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1038
diff
changeset
|
49 uint8_t header [4]; |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1038
diff
changeset
|
50 uint8_t subheader [8]; |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1038
diff
changeset
|
51 uint8_t data [2324]; |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1038
diff
changeset
|
52 uint8_t spare [4]; |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1038
diff
changeset
|
53 } cdsector_t; |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
54 |
23858 | 55 #ifdef VCD_NETBSD |
23859 | 56 typedef struct ioc_read_toc_entry vcd_tocentry; |
23858 | 57 #else |
23859 | 58 typedef struct ioc_read_toc_single_entry vcd_tocentry; |
23858 | 59 #endif |
60 | |
9887 | 61 typedef struct mp_vcd_priv_st { |
62 int fd; | |
23858 | 63 vcd_tocentry entry; |
23857 | 64 #ifdef VCD_NETBSD |
65 struct cd_toc_entry entry_data; | |
66 #else | |
9887 | 67 cdsector_t buf; |
23857 | 68 #endif |
25411
aef6ff061c9a
Caching toc header in vcd private structure for later use.
ulion
parents:
23862
diff
changeset
|
69 struct ioc_toc_header tochdr; |
9887 | 70 } mp_vcd_priv_t; |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
71 |
23849
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
72 static inline void |
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
73 vcd_set_msf(mp_vcd_priv_t* vcd, unsigned int sect) |
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
74 { |
23857 | 75 #ifdef VCD_NETBSD |
76 vcd->entry.data = &vcd->entry_data; | |
77 #endif | |
23862 | 78 sect += 150; |
23849
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
79 TOCADDR(vcd->entry).msf.frame = sect % 75; |
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
80 sect = sect / 75; |
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
81 TOCADDR(vcd->entry).msf.second = sect % 60; |
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
82 sect = sect / 60; |
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
83 TOCADDR(vcd->entry).msf.minute = sect; |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
84 } |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
85 |
23852 | 86 static inline void |
87 vcd_inc_msf(mp_vcd_priv_t* vcd) | |
88 { | |
23857 | 89 #ifdef VCD_NETBSD |
90 vcd->entry.data = &vcd->entry_data; | |
91 #endif | |
23852 | 92 TOCADDR(vcd->entry).msf.frame++; |
93 if (TOCADDR(vcd->entry).msf.frame==75){ | |
94 TOCADDR(vcd->entry).msf.frame=0; | |
95 TOCADDR(vcd->entry).msf.second++; | |
96 if (TOCADDR(vcd->entry).msf.second==60){ | |
97 TOCADDR(vcd->entry).msf.second=0; | |
98 TOCADDR(vcd->entry).msf.minute++; | |
99 } | |
100 } | |
101 } | |
102 | |
23849
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
103 static inline unsigned int |
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
104 vcd_get_msf(mp_vcd_priv_t* vcd) |
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
105 { |
23857 | 106 #ifdef VCD_NETBSD |
107 vcd->entry.data = &vcd->entry_data; | |
108 #endif | |
23847
773e6c50d1b8
TOCADDR macro as first step to common *BSD vcd reading code
reimar
parents:
19271
diff
changeset
|
109 return TOCADDR(vcd->entry).msf.frame + |
23849
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
110 (TOCADDR(vcd->entry).msf.second + |
23862 | 111 TOCADDR(vcd->entry).msf.minute * 60) * 75 - 150; |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
112 } |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
113 |
23858 | 114 /** |
115 * \brief read a TOC entry | |
116 * \param fd device to read from | |
117 * \param dst buffer to read data into | |
118 * \param nr track number to read info for | |
119 * \return 1 on success, 0 on failure | |
120 */ | |
121 static int | |
23860 | 122 read_toc_entry(mp_vcd_priv_t *vcd, int nr) |
23858 | 123 { |
23860 | 124 vcd->entry.address_format = CD_MSF_FORMAT; |
23858 | 125 #ifdef VCD_NETBSD |
23860 | 126 vcd->entry.data_len = sizeof(struct cd_toc_entry); |
127 vcd->entry.data = &vcd->entry_data; | |
128 vcd->entry.starting_track = nr; | |
23858 | 129 #else |
23860 | 130 vcd->entry.track = nr; |
23858 | 131 #endif |
23860 | 132 if (ioctl(vcd->fd, READ_TOC, &vcd->entry) == -1) { |
23858 | 133 mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc entry: %s\n",strerror(errno)); |
134 return 0; | |
135 } | |
136 return 1; | |
137 } | |
138 | |
33349
3ab3212fb624
Make vcd_seek_to_track static, the GUI no longer needs to
reimar
parents:
30981
diff
changeset
|
139 static int |
23849
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
140 vcd_seek_to_track(mp_vcd_priv_t* vcd, int track) |
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
141 { |
23860 | 142 if (!read_toc_entry(vcd, track)) |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
143 return -1; |
23849
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
144 return VCD_SECTOR_DATA * vcd_get_msf(vcd); |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
145 } |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
146 |
30670
fbd6ba7e0e14
Mark vcd_get_track_end () and vcd_read_toc() as static.
diego
parents:
30426
diff
changeset
|
147 static int |
23849
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
148 vcd_get_track_end(mp_vcd_priv_t* vcd, int track) |
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
149 { |
23860 | 150 if (!read_toc_entry(vcd, |
25411
aef6ff061c9a
Caching toc header in vcd private structure for later use.
ulion
parents:
23862
diff
changeset
|
151 track < vcd->tochdr.ending_track ? track + 1 : CDROM_LEADOUT)) |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
152 return -1; |
23849
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
153 return VCD_SECTOR_DATA * vcd_get_msf(vcd); |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
154 } |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
155 |
30670
fbd6ba7e0e14
Mark vcd_get_track_end () and vcd_read_toc() as static.
diego
parents:
30426
diff
changeset
|
156 static mp_vcd_priv_t* |
23849
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
157 vcd_read_toc(int fd) |
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
158 { |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
159 struct ioc_toc_header tochdr; |
9887 | 160 mp_vcd_priv_t* vcd; |
23861 | 161 int i, last_startsect; |
23849
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
162 if (ioctl(fd, CDIOREADTOCHEADER, &tochdr) == -1) { |
9887 | 163 mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno)); |
164 return NULL; | |
165 } | |
18237
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
16547
diff
changeset
|
166 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_START_TRACK=%d\n", tochdr.starting_track); |
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
16547
diff
changeset
|
167 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_END_TRACK=%d\n", tochdr.ending_track); |
23860 | 168 vcd = malloc(sizeof(mp_vcd_priv_t)); |
169 vcd->fd = fd; | |
25411
aef6ff061c9a
Caching toc header in vcd private structure for later use.
ulion
parents:
23862
diff
changeset
|
170 vcd->tochdr = tochdr; |
23849
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
171 for (i = tochdr.starting_track; i <= tochdr.ending_track + 1; i++) { |
23860 | 172 if (!read_toc_entry(vcd, |
173 i <= tochdr.ending_track ? i : CDROM_LEADOUT)) { | |
174 free(vcd); | |
23849
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
175 return NULL; |
23860 | 176 } |
23851 | 177 |
23849
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
178 if (i <= tochdr.ending_track) |
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
179 mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n", |
23857 | 180 #ifdef VCD_NETBSD |
23860 | 181 (int)vcd->entry.starting_track, |
182 (int)vcd->entry.data->addr_type, | |
183 (int)vcd->entry.data->control, | |
23857 | 184 #else |
23860 | 185 (int)vcd->entry.track, |
186 (int)vcd->entry.entry.addr_type, | |
187 (int)vcd->entry.entry.control, | |
23857 | 188 #endif |
23860 | 189 (int)vcd->entry.address_format, |
190 (int)TOCADDR(vcd->entry).msf.minute, | |
191 (int)TOCADDR(vcd->entry).msf.second, | |
192 (int)TOCADDR(vcd->entry).msf.frame | |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
193 ); |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
194 |
23849
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
195 if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO)) |
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
196 { |
23861 | 197 int startsect = vcd_get_msf(vcd); |
23849
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
198 if (i > tochdr.starting_track) |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
199 { |
23861 | 200 // convert duraion to MSF |
201 vcd_set_msf(vcd, startsect - last_startsect); | |
202 mp_msg(MSGT_IDENTIFY, MSGL_INFO, | |
203 "ID_VCD_TRACK_%d_MSF=%02d:%02d:%02d\n", | |
204 i - 1, | |
205 TOCADDR(vcd->entry).msf.minute, | |
206 TOCADDR(vcd->entry).msf.second, | |
207 TOCADDR(vcd->entry).msf.frame); | |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
9899
diff
changeset
|
208 } |
23861 | 209 last_startsect = startsect; |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
210 } |
23849
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
211 } |
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
212 return vcd; |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
213 } |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
214 |
30981 | 215 static int vcd_end_track(mp_vcd_priv_t* vcd) |
216 { | |
217 return vcd->tochdr.ending_track; | |
218 } | |
219 | |
23849
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
220 static int |
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
221 vcd_read(mp_vcd_priv_t* vcd, char *mem) |
2911a78219a8
Cosmetics to reduce diff between Free- and netBSD vcd stuff
reimar
parents:
23847
diff
changeset
|
222 { |
23857 | 223 #ifdef VCD_NETBSD |
224 struct scsireq sc; | |
225 int lba = vcd_get_msf(vcd); | |
226 int blocks; | |
227 int rc; | |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
228 |
23857 | 229 blocks = 1; |
230 | |
231 memset(&sc, 0, sizeof(sc)); | |
232 sc.cmd[0] = 0xBE; | |
233 sc.cmd[1] = 5 << 2; // mode2/form2 | |
234 AV_WB32(&sc.cmd[2], lba); | |
235 AV_WB24(&sc.cmd[6], blocks); | |
236 sc.cmd[9] = 1 << 4; // user data only | |
237 sc.cmd[10] = 0; // no subchannel | |
238 sc.cmdlen = 12; | |
239 sc.databuf = (caddr_t) mem; | |
25873 | 240 sc.datalen = VCD_SECTOR_DATA; |
23857 | 241 sc.senselen = sizeof(sc.sense); |
242 sc.flags = SCCMD_READ; | |
243 sc.timeout = 10000; | |
244 rc = ioctl(vcd->fd, SCIOCCOMMAND, &sc); | |
245 if (rc == -1) { | |
246 mp_msg(MSGT_STREAM,MSGL_ERR,"SCIOCCOMMAND: %s\n",strerror(errno)); | |
247 return -1; | |
248 } | |
249 if (sc.retsts || sc.error) { | |
250 mp_msg(MSGT_STREAM,MSGL_ERR,"scsi command failed: status %d error %d\n", | |
251 sc.retsts,sc.error); | |
252 return -1; | |
253 } | |
254 #else | |
23851 | 255 if (pread(vcd->fd,&vcd->buf,VCD_SECTOR_SIZE,vcd_get_msf(vcd)*VCD_SECTOR_SIZE) |
256 != VCD_SECTOR_SIZE) return 0; // EOF? | |
1177
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1038
diff
changeset
|
257 |
23857 | 258 memcpy(mem,vcd->buf.data,VCD_SECTOR_DATA); |
259 #endif | |
23852 | 260 vcd_inc_msf(vcd); |
23851 | 261 return VCD_SECTOR_DATA; |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
262 } |
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff
changeset
|
263 |
26029 | 264 #endif /* MPLAYER_VCD_READ_FBSD_H */ |