Mercurial > mplayer.hg
annotate stream/vcd_read_os2.h @ 36721:e9044aed2250
Fix issue with testing of the help message header files.
In order for all definitions to be checked properly, we cannot rely
on config.h, but must assure that all conditional symbolic constants
are defined.
author | ib |
---|---|
date | Sun, 09 Feb 2014 09:22:09 +0000 |
parents | 3a192d8ecc56 |
children | 1471cf0a74f7 |
rev | line source |
---|---|
30777 | 1 /* |
2 * implementation of VCD IO for OS/2 | |
3 * | |
4 * Copyright (c) 2009 KO Myung-Hun (komh@chollian.net) | |
5 * | |
6 * This file is part of MPlayer. | |
7 * | |
8 * MPlayer is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * MPlayer is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License along | |
19 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
21 */ | |
22 | |
23 #ifndef MPLAYER_VCD_READ_OS2_H | |
24 #define MPLAYER_VCD_READ_OS2_H | |
25 | |
26 #include "mp_msg.h" | |
27 | |
28 struct __attribute__((packed)) msf { | |
29 BYTE bFrame; | |
30 BYTE bSecond; | |
31 BYTE bMinute; | |
32 BYTE bReserved; | |
33 }; | |
34 | |
35 typedef struct { | |
36 HFILE hcd; | |
37 struct msf msfCurrent; | |
38 int iFirstTrack; | |
39 int iLastTrack; | |
40 struct msf msfLeadOut; | |
41 BYTE abVCDSector[VCD_SECTOR_SIZE]; | |
36433 | 42 unsigned int track; |
30777 | 43 } mp_vcd_priv_t; |
44 | |
45 static inline void vcd_set_msf(mp_vcd_priv_t *vcd, unsigned sect) | |
46 { | |
47 sect += 150; | |
48 vcd->msfCurrent.bFrame = sect % 75; | |
49 sect = sect / 75; | |
50 vcd->msfCurrent.bSecond = sect % 60; | |
51 sect = sect / 60; | |
52 vcd->msfCurrent.bMinute = sect; | |
53 } | |
54 | |
55 static inline unsigned vcd_get_msf(mp_vcd_priv_t *vcd) | |
56 { | |
57 return vcd->msfCurrent.bFrame + | |
58 (vcd->msfCurrent.bSecond + vcd->msfCurrent.bMinute * 60) * 75 - 150; | |
59 } | |
60 | |
33349
3ab3212fb624
Make vcd_seek_to_track static, the GUI no longer needs to
reimar
parents:
30981
diff
changeset
|
61 static int vcd_seek_to_track(mp_vcd_priv_t *vcd, int track) |
30777 | 62 { |
63 struct { | |
64 UCHAR auchSign[4]; | |
65 BYTE bTrack; | |
66 } __attribute__((packed)) sParam = {{'C', 'D', '0', '1'},}; | |
67 | |
68 struct { | |
69 struct msf msfStart; | |
70 BYTE bControlInfo; | |
71 } __attribute__((packed)) sData; | |
72 | |
73 ULONG ulParamLen; | |
74 ULONG ulDataLen; | |
75 ULONG rc; | |
76 | |
77 sParam.bTrack = track; | |
78 rc = DosDevIOCtl(vcd->hcd, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIOTRACK, | |
79 &sParam, sizeof(sParam), &ulParamLen, | |
80 &sData, sizeof(sData), &ulDataLen); | |
81 if (rc) { | |
82 mp_msg(MSGT_STREAM, MSGL_ERR, "DosDevIOCtl(GETAUDIOTRACK) = 0x%lx\n", rc); | |
83 return -1; | |
84 } | |
85 | |
86 vcd->msfCurrent = sData.msfStart; | |
87 | |
88 return VCD_SECTOR_DATA * vcd_get_msf(vcd); | |
89 } | |
90 | |
91 static int vcd_get_track_end(mp_vcd_priv_t *vcd, int track) | |
92 { | |
93 if (track < vcd->iLastTrack) | |
94 return vcd_seek_to_track(vcd, track + 1); | |
95 | |
96 vcd->msfCurrent = vcd->msfLeadOut; | |
97 | |
98 return VCD_SECTOR_DATA * vcd_get_msf(vcd); | |
99 } | |
100 | |
101 static mp_vcd_priv_t *vcd_read_toc(int fd) | |
102 { | |
103 mp_vcd_priv_t *vcd; | |
104 | |
105 UCHAR auchParamDisk[4] = {'C', 'D', '0', '1'}; | |
106 | |
107 struct { | |
108 BYTE bFirstTrack; | |
109 BYTE bLastTrack; | |
110 struct msf msfLeadOut; | |
111 } __attribute__((packed)) sDataDisk; | |
112 | |
113 struct { | |
114 UCHAR auchSign[4]; | |
115 BYTE bTrack; | |
116 } __attribute__((packed)) sParamTrack = {{'C', 'D', '0', '1'},}; | |
117 | |
118 struct { | |
119 struct msf msfStart; | |
120 BYTE bControlInfo; | |
121 } __attribute__((packed)) sDataTrack; | |
122 | |
123 ULONG ulParamLen; | |
124 ULONG ulDataLen; | |
125 ULONG rc; | |
126 int i, iMinute = 0, iSecond = 0, iFrame = 0; | |
127 | |
128 rc = DosDevIOCtl(fd, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIODISK, | |
129 auchParamDisk, sizeof(auchParamDisk), &ulParamLen, | |
130 &sDataDisk, sizeof(sDataDisk), &ulDataLen); | |
131 if (rc) { | |
132 mp_msg(MSGT_OPEN, MSGL_ERR, "DosDevIOCtl(GETAUDIODISK) = 0x%lx\n", rc); | |
133 return NULL; | |
134 } | |
135 | |
136 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_START_TRACK=%d\n", sDataDisk.bFirstTrack); | |
137 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_END_TRACK=%d\n", sDataDisk.bLastTrack); | |
138 | |
139 for (i = sDataDisk.bFirstTrack; i <= sDataDisk.bLastTrack + 1; i++) { | |
140 if (i <= sDataDisk.bLastTrack) { | |
141 sParamTrack.bTrack = i; | |
142 rc = DosDevIOCtl(fd, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIOTRACK, | |
143 &sParamTrack, sizeof(sParamTrack), &ulParamLen, | |
144 &sDataTrack, sizeof(sDataTrack), &ulDataLen); | |
145 if (rc) { | |
146 mp_msg(MSGT_OPEN, MSGL_ERR, "DosDevIOCtl(GETAUDIOTRACK) = 0x%lx\n", rc); | |
147 return NULL; | |
148 } | |
149 | |
150 mp_msg(MSGT_OPEN, MSGL_INFO, "track %02d: adr=%d ctrl=%d %02d:%02d:%02d\n", | |
151 i, | |
152 sDataTrack.bControlInfo & 0x0F, | |
153 sDataTrack.bControlInfo >> 4, | |
154 sDataTrack.msfStart.bMinute, | |
155 sDataTrack.msfStart.bSecond, | |
156 sDataTrack.msfStart.bFrame); | |
157 } else | |
158 sDataTrack.msfStart = sDataDisk.msfLeadOut; | |
159 | |
160 if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO)) { | |
161 if (i > sDataDisk.bFirstTrack) { | |
162 iMinute = sDataTrack.msfStart.bMinute - iMinute; | |
163 iSecond = sDataTrack.msfStart.bSecond - iSecond; | |
164 iFrame = sDataTrack.msfStart.bFrame - iFrame; | |
165 if (iFrame < 0) { | |
166 iFrame += 75; | |
167 iSecond--; | |
168 } | |
169 if (iSecond < 0) { | |
170 iSecond += 60; | |
171 iMinute--; | |
172 } | |
173 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_TRACK_%d_MSF=%02d:%02d:%02d\n", | |
174 i - 1, iMinute, iSecond, iFrame); | |
175 } | |
176 | |
177 iMinute = sDataTrack.msfStart.bMinute; | |
178 iSecond = sDataTrack.msfStart.bSecond; | |
179 iFrame = sDataTrack.msfStart.bFrame; | |
180 } | |
181 } | |
182 | |
183 vcd = calloc(1, sizeof(mp_vcd_priv_t)); | |
184 vcd->hcd = fd; | |
185 vcd->iFirstTrack = sDataDisk.bFirstTrack; | |
186 vcd->iLastTrack = sDataDisk.bLastTrack; | |
187 vcd->msfLeadOut = sDataDisk.msfLeadOut; | |
188 | |
189 return vcd; | |
190 } | |
191 | |
30981 | 192 static int vcd_end_track(mp_vcd_priv_t* vcd) |
193 { | |
194 return vcd->iLastTrack; | |
195 } | |
196 | |
30777 | 197 static int vcd_read(mp_vcd_priv_t *vcd, char *mem) |
198 { | |
199 struct { | |
200 UCHAR auchSign[4]; | |
201 BYTE bAddrMode; | |
202 USHORT usSectors; | |
203 struct msf msfStart; | |
204 BYTE bReserved; | |
205 BYTE bInterleavedSize; | |
206 } __attribute__((packed)) sParam = {{'C', 'D', '0', '1'}, 1, 1,}; | |
207 | |
208 ULONG ulParamLen; | |
209 ULONG ulDataLen; | |
210 ULONG rc; | |
211 | |
212 /* lead-out ? */ | |
213 if (vcd->msfCurrent.bMinute == vcd->msfLeadOut.bMinute && | |
214 vcd->msfCurrent.bSecond == vcd->msfLeadOut.bSecond && | |
215 vcd->msfCurrent.bFrame == vcd->msfLeadOut.bFrame) | |
216 return 0; | |
217 | |
218 sParam.msfStart = vcd->msfCurrent; | |
219 rc = DosDevIOCtl(vcd->hcd, IOCTL_CDROMDISK, CDROMDISK_READLONG, | |
220 &sParam, sizeof(sParam), &ulParamLen, | |
221 vcd->abVCDSector, sizeof(vcd->abVCDSector), &ulDataLen); | |
222 if (rc) { | |
223 mp_msg(MSGT_STREAM, MSGL_ERR, "DosDevIOCtl(READLONG) = 0x%lx\n", rc); | |
224 return 0; | |
225 } | |
226 | |
227 memcpy(mem, &vcd->abVCDSector[VCD_SECTOR_OFFS], VCD_SECTOR_DATA); | |
228 | |
229 vcd->msfCurrent.bFrame++; | |
230 if (vcd->msfCurrent.bFrame == 75) { | |
231 vcd->msfCurrent.bFrame = 0; | |
232 vcd->msfCurrent.bSecond++; | |
233 if (vcd->msfCurrent.bSecond == 60) { | |
234 vcd->msfCurrent.bSecond = 0; | |
235 vcd->msfCurrent.bMinute++; | |
236 } | |
237 } | |
238 | |
239 return VCD_SECTOR_DATA; | |
240 } | |
241 | |
242 #endif /* MPLAYER_VCD_READ_OS2_H */ | |
243 |