annotate stream/vcd_read_os2.h @ 37043:43a8e37a3dcf

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