annotate stream/vcd_read_darwin.h @ 25101:10a3f5b4ee20

Rename timer-lx.c --> timer-linux.c.
author diego
date Wed, 21 Nov 2007 09:25:10 +0000
parents 3a5f766397b5
children e1884244ba98
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>
23896
ae9ebf311ffd Make VCD work on little-endian macs
reimar
parents: 23895
diff changeset
7 #include "mpbswap.h"
13682
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
8
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
9 //=================== VideoCD ==========================
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
10 #define CDROM_LEADOUT 0xAA
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
11
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
12 typedef struct
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
13 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
14 uint8_t sync [12];
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
15 uint8_t header [4];
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
16 uint8_t subheader [8];
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
17 uint8_t data [2324];
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
18 uint8_t spare [4];
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
19 } cdsector_t;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
20
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
21 typedef struct mp_vcd_priv_st
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
22 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
23 int fd;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
24 dk_cd_read_track_info_t entry;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
25 CDMSF msf;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
26 cdsector_t buf;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
27 } mp_vcd_priv_t;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
28
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
29 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
30 {
23898
3a5f766397b5 Simplify and fix missing offset for Darwin vcd_get/set_msf functions
reimar
parents: 23896
diff changeset
31 vcd->msf = CDConvertLBAToMSF(sect);
13682
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
32 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
33
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
34 static inline unsigned int vcd_get_msf(mp_vcd_priv_t* vcd)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
35 {
23898
3a5f766397b5 Simplify and fix missing offset for Darwin vcd_get/set_msf functions
reimar
parents: 23896
diff changeset
36 return CDConvertMSFToLBA(vcd->msf);
13682
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
37 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
38
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
39 int vcd_seek_to_track(mp_vcd_priv_t* vcd, int track)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
40 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
41 struct CDTrackInfo entry;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
42
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
43 memset( &vcd->entry, 0, sizeof(vcd->entry));
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
44 vcd->entry.addressType = kCDTrackInfoAddressTypeTrackNumber;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
45 vcd->entry.address = track;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
46 vcd->entry.bufferLength = sizeof(entry);
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
47 vcd->entry.buffer = &entry;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
48
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
49 if (ioctl(vcd->fd, DKIOCCDREADTRACKINFO, &vcd->entry))
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
50 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
51 mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif1: %s\n",strerror(errno));
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
52 return -1;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
53 }
23896
ae9ebf311ffd Make VCD work on little-endian macs
reimar
parents: 23895
diff changeset
54 vcd->msf = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress));
13682
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
55 return VCD_SECTOR_DATA*vcd_get_msf(vcd);
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
56 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
57
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
58 int vcd_get_track_end(mp_vcd_priv_t* vcd, int track)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
59 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
60 dk_cd_read_disc_info_t tochdr;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
61 struct CDDiscInfo hdr;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
62
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
63 struct CDTrackInfo entry;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
64
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
65 //read toc header
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
66 memset(&tochdr, 0, sizeof(tochdr));
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
67 tochdr.buffer = &hdr;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
68 tochdr.bufferLength = sizeof(hdr);
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
69
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
70 if (ioctl(vcd->fd, DKIOCCDREADDISCINFO, &tochdr) < 0)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
71 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
72 mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno));
23891
542d4cda34c3 Fix wrong return type in darwin VCD code
reimar
parents: 23863
diff changeset
73 return -1;
13682
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
74 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
75
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
76 //read track info
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
77 memset( &vcd->entry, 0, sizeof(vcd->entry));
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
78 vcd->entry.addressType = kCDTrackInfoAddressTypeTrackNumber;
23895
5ebab6056efc Make vcd_get_track_end actually return the end, not the start on Darwin
reimar
parents: 23894
diff changeset
79 vcd->entry.address = track<hdr.lastTrackNumberInLastSessionLSB?track+1:CDROM_LEADOUT;
13682
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
80 vcd->entry.bufferLength = sizeof(entry);
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
81 vcd->entry.buffer = &entry;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
82
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
83 if (ioctl(vcd->fd, DKIOCCDREADTRACKINFO, &vcd->entry))
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
84 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
85 mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif2: %s\n",strerror(errno));
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
86 return -1;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
87 }
23896
ae9ebf311ffd Make VCD work on little-endian macs
reimar
parents: 23895
diff changeset
88 vcd->msf = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress));
13682
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
89 return VCD_SECTOR_DATA*vcd_get_msf(vcd);
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
90 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
91
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
92 mp_vcd_priv_t* vcd_read_toc(int fd)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
93 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
94 dk_cd_read_disc_info_t tochdr;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
95 struct CDDiscInfo hdr;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
96
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
97 dk_cd_read_track_info_t tocentry;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
98 struct CDTrackInfo entry;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
99 CDMSF trackMSF;
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;
16547
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
102 int i, min = 0, sec = 0, frame = 0;
13682
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
103
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
104 //read toc header
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
105 memset(&tochdr, 0, sizeof(tochdr));
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
106 tochdr.buffer = &hdr;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
107 tochdr.bufferLength = sizeof(hdr);
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
108
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
109 if (ioctl(fd, DKIOCCDREADDISCINFO, &tochdr) < 0)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
110 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
111 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
112 return NULL;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
113 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
114
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
115 //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
116 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
117 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
118 for (i=hdr.firstTrackNumberInLastSessionLSB ; i<=hdr.lastTrackNumberInLastSessionLSB + 1; i++)
13682
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
119 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
120 memset( &tocentry, 0, sizeof(tocentry));
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
121 tocentry.addressType = kCDTrackInfoAddressTypeTrackNumber;
16547
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
122 tocentry.address = i<=hdr.lastTrackNumberInLastSessionLSB ? i : CDROM_LEADOUT;
13682
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
123 tocentry.bufferLength = sizeof(entry);
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
124 tocentry.buffer = &entry;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
125
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
126 if (ioctl(fd,DKIOCCDREADTRACKINFO,&tocentry)==-1)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
127 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
128 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
129 return NULL;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
130 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
131
23896
ae9ebf311ffd Make VCD work on little-endian macs
reimar
parents: 23895
diff changeset
132 trackMSF = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress));
13682
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
133
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
134 //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
135 if (i<=hdr.lastTrackNumberInLastSessionLSB)
13682
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
136 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
137 (int)tocentry.address,
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
138 //(int)tocentry.entry.addr_type,
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
139 //(int)tocentry.entry.control,
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
140 (int)tocentry.addressType,
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
141 (int)trackMSF.minute,
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
142 (int)trackMSF.second,
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
143 (int)trackMSF.frame
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
144 );
16547
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
145
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
146 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
147 {
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
148 if (i > hdr.firstTrackNumberInLastSessionLSB)
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
149 {
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
150 min = trackMSF.minute - min;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
151 sec = trackMSF.second - sec;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
152 frame = trackMSF.frame - frame;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
153 if ( frame < 0 )
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
154 {
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
155 frame += 75;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
156 sec --;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
157 }
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
158 if ( sec < 0 )
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
159 {
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
160 sec += 60;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
161 min --;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
162 }
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
163 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
164 }
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
165 min = trackMSF.minute;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
166 sec = trackMSF.second;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
167 frame = trackMSF.frame;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 13842
diff changeset
168 }
13682
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
169 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
170
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
171 vcd = malloc(sizeof(mp_vcd_priv_t));
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
172 vcd->fd = fd;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
173 vcd->msf = trackMSF;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
174 return vcd;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
175 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
176
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
177 static int vcd_read(mp_vcd_priv_t* vcd,char *mem)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
178 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
179 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
180 return 0; // EOF?
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
181
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
182 vcd->msf.frame++;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
183 if (vcd->msf.frame==75)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
184 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
185 vcd->msf.frame=0;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
186 vcd->msf.second++;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
187
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
188 if (vcd->msf.second==60)
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
189 {
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
190 vcd->msf.second=0;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
191 vcd->msf.minute++;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
192 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
193 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
194
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
195 memcpy(mem,vcd->buf.data,VCD_SECTOR_DATA);
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
196 return VCD_SECTOR_DATA;
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
197 }
aedf94d36d2a support function for vcd on darwin
nplourde
parents:
diff changeset
198