annotate stream/vcd_read_darwin.h @ 23586:16db18293ebd

unbreak armv6 previously broken by me...
author lu_zero
date Fri, 22 Jun 2007 19:58:44 +0000
parents 300e9b7c499f
children 78f77927050c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13842
78e5886bc211 fix build on darwin ppc
nplourde
parents: 13682
diff changeset
1 #include <sys/types.h>
78e5886bc211 fix build on darwin ppc
nplourde
parents: 13682
diff changeset
2 #include <CoreFoundation/CFBase.h>
78e5886bc211 fix build on darwin ppc
nplourde
parents: 13682
diff changeset
3 #include <IOKit/IOKitLib.h>
78e5886bc211 fix build on darwin ppc
nplourde
parents: 13682
diff changeset
4 #include <IOKit/storage/IOCDTypes.h>
78e5886bc211 fix build on darwin ppc
nplourde
parents: 13682
diff changeset
5 #include <IOKit/storage/IOCDMedia.h>
13682
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
6 #include <IOKit/storage/IOCDMediaBSDClient.h>
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
7
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
8 //=================== VideoCD ==========================
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
9 #define CDROM_LEADOUT 0xAA
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
10
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
11 typedef struct
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
12 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
13 uint8_t sync [12];
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
14 uint8_t header [4];
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
15 uint8_t subheader [8];
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
16 uint8_t data [2324];
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
17 uint8_t spare [4];
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
18 } cdsector_t;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
19
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
20 typedef struct mp_vcd_priv_st
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
21 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
22 int fd;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
23 dk_cd_read_track_info_t entry;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
24 CDMSF msf;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
25 cdsector_t buf;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
26 } mp_vcd_priv_t;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
27
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
28 static inline void vcd_set_msf(mp_vcd_priv_t* vcd, unsigned int sect)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
29 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
30 vcd->msf.frame=sect%75;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
31 sect=sect/75;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
32 vcd->msf.second=sect%60;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
33 sect=sect/60;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
34 vcd->msf.minute=sect;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
35 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
36
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
37 static inline unsigned int vcd_get_msf(mp_vcd_priv_t* vcd)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
38 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
39 return vcd->msf.frame +
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
40 (vcd->msf.second+
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
41 vcd->msf.minute*60)*75;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
42
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
43 return 0;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
44 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
45
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
46 int vcd_seek_to_track(mp_vcd_priv_t* vcd, int track)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
47 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
48 struct CDTrackInfo entry;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
49
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
50 memset( &vcd->entry, 0, sizeof(vcd->entry));
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
51 vcd->entry.addressType = kCDTrackInfoAddressTypeTrackNumber;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
52 vcd->entry.address = track;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
53 vcd->entry.bufferLength = sizeof(entry);
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
54 vcd->entry.buffer = &entry;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
55
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
56 if (ioctl(vcd->fd, DKIOCCDREADTRACKINFO, &vcd->entry))
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
57 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
58 mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif1: %s\n",strerror(errno));
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
59 return -1;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
60 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
61 return VCD_SECTOR_DATA*vcd_get_msf(vcd);
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
62
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
63 return -1;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
64 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
65
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
66 int vcd_get_track_end(mp_vcd_priv_t* vcd, int track)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
67 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
68 dk_cd_read_disc_info_t tochdr;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
69 struct CDDiscInfo hdr;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
70
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
71 struct CDTrackInfo entry;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
72
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
73 //read toc header
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
74 memset(&tochdr, 0, sizeof(tochdr));
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
75 tochdr.buffer = &hdr;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
76 tochdr.bufferLength = sizeof(hdr);
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
77
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
78 if (ioctl(vcd->fd, DKIOCCDREADDISCINFO, &tochdr) < 0)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
79 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
80 mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno));
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
81 return NULL;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
82 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
83
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
84 //read track info
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
85 memset( &vcd->entry, 0, sizeof(vcd->entry));
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
86 vcd->entry.addressType = kCDTrackInfoAddressTypeTrackNumber;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
87 vcd->entry.address = track<(hdr.lastTrackNumberInLastSessionLSB+1)?(track):CDROM_LEADOUT;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
88 vcd->entry.bufferLength = sizeof(entry);
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
89 vcd->entry.buffer = &entry;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
90
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
91 if (ioctl(vcd->fd, DKIOCCDREADTRACKINFO, &vcd->entry))
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
92 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
93 mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif2: %s\n",strerror(errno));
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
94 return -1;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
95 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
96 return VCD_SECTOR_DATA*vcd_get_msf(vcd);
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
97
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
98 return -1;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
99 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
100
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
101 mp_vcd_priv_t* vcd_read_toc(int fd)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
102 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
103 dk_cd_read_disc_info_t tochdr;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
104 struct CDDiscInfo hdr;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
105
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
106 dk_cd_read_track_info_t tocentry;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
107 struct CDTrackInfo entry;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
108 CDMSF trackMSF;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
109
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
110 mp_vcd_priv_t* vcd;
16547
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
111 int i, min = 0, sec = 0, frame = 0;
13682
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
112
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
113 //read toc header
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
114 memset(&tochdr, 0, sizeof(tochdr));
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
115 tochdr.buffer = &hdr;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
116 tochdr.bufferLength = sizeof(hdr);
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
117
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
118 if (ioctl(fd, DKIOCCDREADDISCINFO, &tochdr) < 0)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
119 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
120 mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno));
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
121 return NULL;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
122 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
123
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
124 //print all track info
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
125 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_START_TRACK=%d\n", hdr.firstTrackNumberInLastSessionLSB);
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
126 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_END_TRACK=%d\n", hdr.lastTrackNumberInLastSessionLSB);
16547
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
127 for (i=hdr.firstTrackNumberInLastSessionLSB ; i<=hdr.lastTrackNumberInLastSessionLSB + 1; i++)
13682
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
128 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
129 memset( &tocentry, 0, sizeof(tocentry));
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
130 tocentry.addressType = kCDTrackInfoAddressTypeTrackNumber;
16547
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
131 tocentry.address = i<=hdr.lastTrackNumberInLastSessionLSB ? i : CDROM_LEADOUT;
13682
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
132 tocentry.bufferLength = sizeof(entry);
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
133 tocentry.buffer = &entry;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
134
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
135 if (ioctl(fd,DKIOCCDREADTRACKINFO,&tocentry)==-1)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
136 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
137 mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc entry: %s\n",strerror(errno));
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
138 return NULL;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
139 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
140
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
141 trackMSF = CDConvertLBAToMSF(entry.trackStartAddress);
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
142
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
143 //mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n",
16547
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
144 if (i<=hdr.lastTrackNumberInLastSessionLSB)
13682
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
145 mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: format=%d %02d:%02d:%02d\n",
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
146 (int)tocentry.address,
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
147 //(int)tocentry.entry.addr_type,
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
148 //(int)tocentry.entry.control,
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
149 (int)tocentry.addressType,
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
150 (int)trackMSF.minute,
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
151 (int)trackMSF.second,
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
152 (int)trackMSF.frame
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
153 );
16547
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
154
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
155 if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO))
16547
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
156 {
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
157 if (i > hdr.firstTrackNumberInLastSessionLSB)
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
158 {
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
159 min = trackMSF.minute - min;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
160 sec = trackMSF.second - sec;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
161 frame = trackMSF.frame - frame;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
162 if ( frame < 0 )
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
163 {
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
164 frame += 75;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
165 sec --;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
166 }
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
167 if ( sec < 0 )
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
168 {
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
169 sec += 60;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
170 min --;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
171 }
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
172 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_TRACK_%d_MSF=%02d:%02d:%02d\n", i - 1, min, sec, frame);
16547
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
173 }
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
174 min = trackMSF.minute;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
175 sec = trackMSF.second;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
176 frame = trackMSF.frame;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
177 }
13682
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
178 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
179
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
180 vcd = malloc(sizeof(mp_vcd_priv_t));
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
181 vcd->fd = fd;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
182 vcd->msf = trackMSF;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
183 return vcd;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
184
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
185 return NULL;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
186 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
187
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
188 static int vcd_read(mp_vcd_priv_t* vcd,char *mem)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
189 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
190 if (pread(vcd->fd,&vcd->buf,VCD_SECTOR_SIZE,vcd_get_msf(vcd)*VCD_SECTOR_SIZE) != VCD_SECTOR_SIZE)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
191 return 0; // EOF?
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
192
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
193 vcd->msf.frame++;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
194 if (vcd->msf.frame==75)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
195 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
196 vcd->msf.frame=0;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
197 vcd->msf.second++;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
198
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
199 if (vcd->msf.second==60)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
200 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
201 vcd->msf.second=0;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
202 vcd->msf.minute++;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
203 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
204 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
205
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
206 memcpy(mem,vcd->buf.data,VCD_SECTOR_DATA);
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
207 return VCD_SECTOR_DATA;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
208 return 0;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
209 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
210