Mercurial > mplayer.hg
annotate stream/vcd_read_os2.h @ 37195:ac6c37d85d65 default tip
configure: Fix initialization of variable def_local_aligned_32
It contiained the #define of HAVE_LOCAL_ALIGNED_16 instead
of HAVE_LOCAL_ALIGNED_32.
author | al |
---|---|
date | Sun, 28 Sep 2014 18:38:41 +0000 |
parents | 1b5b0b63de4b |
children |
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 | |
36808
1b5b0b63de4b
vcd_read_os2.h: replace calloc() with _calloc() only in vcd_read_os2.h
komh
parents:
36805
diff
changeset
|
26 #include "mp_msg.h" |
1b5b0b63de4b
vcd_read_os2.h: replace calloc() with _calloc() only in vcd_read_os2.h
komh
parents:
36805
diff
changeset
|
27 |
36805 | 28 #ifdef __KLIBC__ |
29 #include <emx/umalloc.h> | |
30 #define calloc _lcalloc | |
31 #endif | |
32 | |
30777 | 33 struct __attribute__((packed)) msf { |
34 BYTE bFrame; | |
35 BYTE bSecond; | |
36 BYTE bMinute; | |
37 BYTE bReserved; | |
38 }; | |
39 | |
40 typedef struct { | |
41 HFILE hcd; | |
42 struct msf msfCurrent; | |
43 int iFirstTrack; | |
44 int iLastTrack; | |
45 struct msf msfLeadOut; | |
46 BYTE abVCDSector[VCD_SECTOR_SIZE]; | |
36433 | 47 unsigned int track; |
30777 | 48 } mp_vcd_priv_t; |
49 | |
50 static inline void vcd_set_msf(mp_vcd_priv_t *vcd, unsigned sect) | |
51 { | |
52 sect += 150; | |
53 vcd->msfCurrent.bFrame = sect % 75; | |
54 sect = sect / 75; | |
55 vcd->msfCurrent.bSecond = sect % 60; | |
56 sect = sect / 60; | |
57 vcd->msfCurrent.bMinute = sect; | |
58 } | |
59 | |
60 static inline unsigned vcd_get_msf(mp_vcd_priv_t *vcd) | |
61 { | |
62 return vcd->msfCurrent.bFrame + | |
63 (vcd->msfCurrent.bSecond + vcd->msfCurrent.bMinute * 60) * 75 - 150; | |
64 } | |
65 | |
33349
3ab3212fb624
Make vcd_seek_to_track static, the GUI no longer needs to
reimar
parents:
30981
diff
changeset
|
66 static int vcd_seek_to_track(mp_vcd_priv_t *vcd, int track) |
30777 | 67 { |
68 struct { | |
69 UCHAR auchSign[4]; | |
70 BYTE bTrack; | |
71 } __attribute__((packed)) sParam = {{'C', 'D', '0', '1'},}; | |
72 | |
73 struct { | |
74 struct msf msfStart; | |
75 BYTE bControlInfo; | |
76 } __attribute__((packed)) sData; | |
77 | |
78 ULONG ulParamLen; | |
79 ULONG ulDataLen; | |
80 ULONG rc; | |
81 | |
82 sParam.bTrack = track; | |
83 rc = DosDevIOCtl(vcd->hcd, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIOTRACK, | |
84 &sParam, sizeof(sParam), &ulParamLen, | |
85 &sData, sizeof(sData), &ulDataLen); | |
86 if (rc) { | |
87 mp_msg(MSGT_STREAM, MSGL_ERR, "DosDevIOCtl(GETAUDIOTRACK) = 0x%lx\n", rc); | |
88 return -1; | |
89 } | |
90 | |
91 vcd->msfCurrent = sData.msfStart; | |
92 | |
93 return VCD_SECTOR_DATA * vcd_get_msf(vcd); | |
94 } | |
95 | |
96 static int vcd_get_track_end(mp_vcd_priv_t *vcd, int track) | |
97 { | |
98 if (track < vcd->iLastTrack) | |
99 return vcd_seek_to_track(vcd, track + 1); | |
100 | |
101 vcd->msfCurrent = vcd->msfLeadOut; | |
102 | |
103 return VCD_SECTOR_DATA * vcd_get_msf(vcd); | |
104 } | |
105 | |
106 static mp_vcd_priv_t *vcd_read_toc(int fd) | |
107 { | |
108 mp_vcd_priv_t *vcd; | |
109 | |
110 UCHAR auchParamDisk[4] = {'C', 'D', '0', '1'}; | |
111 | |
112 struct { | |
113 BYTE bFirstTrack; | |
114 BYTE bLastTrack; | |
115 struct msf msfLeadOut; | |
116 } __attribute__((packed)) sDataDisk; | |
117 | |
118 struct { | |
119 UCHAR auchSign[4]; | |
120 BYTE bTrack; | |
121 } __attribute__((packed)) sParamTrack = {{'C', 'D', '0', '1'},}; | |
122 | |
123 struct { | |
124 struct msf msfStart; | |
125 BYTE bControlInfo; | |
126 } __attribute__((packed)) sDataTrack; | |
127 | |
128 ULONG ulParamLen; | |
129 ULONG ulDataLen; | |
130 ULONG rc; | |
131 int i, iMinute = 0, iSecond = 0, iFrame = 0; | |
132 | |
133 rc = DosDevIOCtl(fd, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIODISK, | |
134 auchParamDisk, sizeof(auchParamDisk), &ulParamLen, | |
135 &sDataDisk, sizeof(sDataDisk), &ulDataLen); | |
136 if (rc) { | |
137 mp_msg(MSGT_OPEN, MSGL_ERR, "DosDevIOCtl(GETAUDIODISK) = 0x%lx\n", rc); | |
138 return NULL; | |
139 } | |
140 | |
141 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_START_TRACK=%d\n", sDataDisk.bFirstTrack); | |
142 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_END_TRACK=%d\n", sDataDisk.bLastTrack); | |
143 | |
144 for (i = sDataDisk.bFirstTrack; i <= sDataDisk.bLastTrack + 1; i++) { | |
145 if (i <= sDataDisk.bLastTrack) { | |
146 sParamTrack.bTrack = i; | |
147 rc = DosDevIOCtl(fd, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIOTRACK, | |
148 &sParamTrack, sizeof(sParamTrack), &ulParamLen, | |
149 &sDataTrack, sizeof(sDataTrack), &ulDataLen); | |
150 if (rc) { | |
151 mp_msg(MSGT_OPEN, MSGL_ERR, "DosDevIOCtl(GETAUDIOTRACK) = 0x%lx\n", rc); | |
152 return NULL; | |
153 } | |
154 | |
155 mp_msg(MSGT_OPEN, MSGL_INFO, "track %02d: adr=%d ctrl=%d %02d:%02d:%02d\n", | |
156 i, | |
157 sDataTrack.bControlInfo & 0x0F, | |
158 sDataTrack.bControlInfo >> 4, | |
159 sDataTrack.msfStart.bMinute, | |
160 sDataTrack.msfStart.bSecond, | |
161 sDataTrack.msfStart.bFrame); | |
162 } else | |
163 sDataTrack.msfStart = sDataDisk.msfLeadOut; | |
164 | |
165 if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO)) { | |
166 if (i > sDataDisk.bFirstTrack) { | |
167 iMinute = sDataTrack.msfStart.bMinute - iMinute; | |
168 iSecond = sDataTrack.msfStart.bSecond - iSecond; | |
169 iFrame = sDataTrack.msfStart.bFrame - iFrame; | |
170 if (iFrame < 0) { | |
171 iFrame += 75; | |
172 iSecond--; | |
173 } | |
174 if (iSecond < 0) { | |
175 iSecond += 60; | |
176 iMinute--; | |
177 } | |
178 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_TRACK_%d_MSF=%02d:%02d:%02d\n", | |
179 i - 1, iMinute, iSecond, iFrame); | |
180 } | |
181 | |
182 iMinute = sDataTrack.msfStart.bMinute; | |
183 iSecond = sDataTrack.msfStart.bSecond; | |
184 iFrame = sDataTrack.msfStart.bFrame; | |
185 } | |
186 } | |
187 | |
188 vcd = calloc(1, sizeof(mp_vcd_priv_t)); | |
189 vcd->hcd = fd; | |
190 vcd->iFirstTrack = sDataDisk.bFirstTrack; | |
191 vcd->iLastTrack = sDataDisk.bLastTrack; | |
192 vcd->msfLeadOut = sDataDisk.msfLeadOut; | |
193 | |
194 return vcd; | |
195 } | |
196 | |
30981 | 197 static int vcd_end_track(mp_vcd_priv_t* vcd) |
198 { | |
199 return vcd->iLastTrack; | |
200 } | |
201 | |
30777 | 202 static int vcd_read(mp_vcd_priv_t *vcd, char *mem) |
203 { | |
204 struct { | |
205 UCHAR auchSign[4]; | |
206 BYTE bAddrMode; | |
207 USHORT usSectors; | |
208 struct msf msfStart; | |
209 BYTE bReserved; | |
210 BYTE bInterleavedSize; | |
211 } __attribute__((packed)) sParam = {{'C', 'D', '0', '1'}, 1, 1,}; | |
212 | |
213 ULONG ulParamLen; | |
214 ULONG ulDataLen; | |
215 ULONG rc; | |
216 | |
217 /* lead-out ? */ | |
218 if (vcd->msfCurrent.bMinute == vcd->msfLeadOut.bMinute && | |
219 vcd->msfCurrent.bSecond == vcd->msfLeadOut.bSecond && | |
220 vcd->msfCurrent.bFrame == vcd->msfLeadOut.bFrame) | |
221 return 0; | |
222 | |
223 sParam.msfStart = vcd->msfCurrent; | |
224 rc = DosDevIOCtl(vcd->hcd, IOCTL_CDROMDISK, CDROMDISK_READLONG, | |
225 &sParam, sizeof(sParam), &ulParamLen, | |
226 vcd->abVCDSector, sizeof(vcd->abVCDSector), &ulDataLen); | |
227 if (rc) { | |
228 mp_msg(MSGT_STREAM, MSGL_ERR, "DosDevIOCtl(READLONG) = 0x%lx\n", rc); | |
229 return 0; | |
230 } | |
231 | |
232 memcpy(mem, &vcd->abVCDSector[VCD_SECTOR_OFFS], VCD_SECTOR_DATA); | |
233 | |
234 vcd->msfCurrent.bFrame++; | |
235 if (vcd->msfCurrent.bFrame == 75) { | |
236 vcd->msfCurrent.bFrame = 0; | |
237 vcd->msfCurrent.bSecond++; | |
238 if (vcd->msfCurrent.bSecond == 60) { | |
239 vcd->msfCurrent.bSecond = 0; | |
240 vcd->msfCurrent.bMinute++; | |
241 } | |
242 } | |
243 | |
244 return VCD_SECTOR_DATA; | |
245 } | |
246 | |
36808
1b5b0b63de4b
vcd_read_os2.h: replace calloc() with _calloc() only in vcd_read_os2.h
komh
parents:
36805
diff
changeset
|
247 #ifdef __KLIBC__ |
1b5b0b63de4b
vcd_read_os2.h: replace calloc() with _calloc() only in vcd_read_os2.h
komh
parents:
36805
diff
changeset
|
248 #undef calloc |
1b5b0b63de4b
vcd_read_os2.h: replace calloc() with _calloc() only in vcd_read_os2.h
komh
parents:
36805
diff
changeset
|
249 #endif |
1b5b0b63de4b
vcd_read_os2.h: replace calloc() with _calloc() only in vcd_read_os2.h
komh
parents:
36805
diff
changeset
|
250 |
30777 | 251 #endif /* MPLAYER_VCD_READ_OS2_H */ |
252 |