Mercurial > mplayer.hg
annotate stream/vcd_read_darwin.h @ 36058:ecd7b4e543bf
Remove GTK_WIDGET_SET_FLAGS(, GTK_CAN_DEFAULT).
It's pointless to set this on the window.
There is an accelerator set for the return key.
author | ib |
---|---|
date | Thu, 04 Apr 2013 18:01:27 +0000 |
parents | 3ab3212fb624 |
children | 3a192d8ecc56 |
rev | line source |
---|---|
30426
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
1 /* |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
2 * This file is part of MPlayer. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
3 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
7 * (at your option) any later version. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
8 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
12 * GNU General Public License for more details. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
13 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
17 */ |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
30165
diff
changeset
|
18 |
26029 | 19 #ifndef MPLAYER_VCD_READ_DARWIN_H |
20 #define MPLAYER_VCD_READ_DARWIN_H | |
26012 | 21 |
30165 | 22 #define _XOPEN_SOURCE 500 |
23 | |
26184
7ee4ae1648e6
Add missing header #includes to fix 'make checkheaders'.
diego
parents:
26029
diff
changeset
|
24 #include <stdlib.h> |
7ee4ae1648e6
Add missing header #includes to fix 'make checkheaders'.
diego
parents:
26029
diff
changeset
|
25 #include <string.h> |
7ee4ae1648e6
Add missing header #includes to fix 'make checkheaders'.
diego
parents:
26029
diff
changeset
|
26 #include <errno.h> |
13842 | 27 #include <sys/types.h> |
26186
49df679a7c1a
Add missing header #includes to fix 'make checkheaders'.
diego
parents:
26184
diff
changeset
|
28 #include <sys/uio.h> |
49df679a7c1a
Add missing header #includes to fix 'make checkheaders'.
diego
parents:
26184
diff
changeset
|
29 #include <unistd.h> |
13842 | 30 #include <CoreFoundation/CFBase.h> |
31 #include <IOKit/IOKitLib.h> | |
32 #include <IOKit/storage/IOCDTypes.h> | |
33 #include <IOKit/storage/IOCDMedia.h> | |
13682 | 34 #include <IOKit/storage/IOCDMediaBSDClient.h> |
23896 | 35 #include "mpbswap.h" |
26184
7ee4ae1648e6
Add missing header #includes to fix 'make checkheaders'.
diego
parents:
26029
diff
changeset
|
36 #include "mp_msg.h" |
26186
49df679a7c1a
Add missing header #includes to fix 'make checkheaders'.
diego
parents:
26184
diff
changeset
|
37 #include "stream.h" |
13682 | 38 |
39 //=================== VideoCD ========================== | |
40 #define CDROM_LEADOUT 0xAA | |
41 | |
42 typedef struct | |
43 { | |
44 uint8_t sync [12]; | |
45 uint8_t header [4]; | |
46 uint8_t subheader [8]; | |
47 uint8_t data [2324]; | |
48 uint8_t spare [4]; | |
49 } cdsector_t; | |
50 | |
51 typedef struct mp_vcd_priv_st | |
52 { | |
53 int fd; | |
25376
382aeacc771f
The buffer used for pread need be aligned, but currently it got an offset 23
ulion
parents:
25375
diff
changeset
|
54 cdsector_t buf; |
13682 | 55 dk_cd_read_track_info_t entry; |
25378
f0f03ec41cd3
Only read disc info once and save it for later using.
ulion
parents:
25376
diff
changeset
|
56 struct CDDiscInfo hdr; |
13682 | 57 CDMSF msf; |
58 } mp_vcd_priv_t; | |
59 | |
60 static inline void vcd_set_msf(mp_vcd_priv_t* vcd, unsigned int sect) | |
61 { | |
23898
3a5f766397b5
Simplify and fix missing offset for Darwin vcd_get/set_msf functions
reimar
parents:
23896
diff
changeset
|
62 vcd->msf = CDConvertLBAToMSF(sect); |
13682 | 63 } |
64 | |
65 static inline unsigned int vcd_get_msf(mp_vcd_priv_t* vcd) | |
66 { | |
23898
3a5f766397b5
Simplify and fix missing offset for Darwin vcd_get/set_msf functions
reimar
parents:
23896
diff
changeset
|
67 return CDConvertMSFToLBA(vcd->msf); |
13682 | 68 } |
69 | |
33349
3ab3212fb624
Make vcd_seek_to_track static, the GUI no longer needs to
reimar
parents:
30981
diff
changeset
|
70 static int vcd_seek_to_track(mp_vcd_priv_t* vcd, int track) |
13682 | 71 { |
72 struct CDTrackInfo entry; | |
73 | |
74 memset( &vcd->entry, 0, sizeof(vcd->entry)); | |
75 vcd->entry.addressType = kCDTrackInfoAddressTypeTrackNumber; | |
76 vcd->entry.address = track; | |
77 vcd->entry.bufferLength = sizeof(entry); | |
78 vcd->entry.buffer = &entry; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
79 |
13682 | 80 if (ioctl(vcd->fd, DKIOCCDREADTRACKINFO, &vcd->entry)) |
81 { | |
82 mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif1: %s\n",strerror(errno)); | |
83 return -1; | |
84 } | |
23896 | 85 vcd->msf = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress)); |
13682 | 86 return VCD_SECTOR_DATA*vcd_get_msf(vcd); |
87 } | |
88 | |
30670
fbd6ba7e0e14
Mark vcd_get_track_end () and vcd_read_toc() as static.
diego
parents:
30426
diff
changeset
|
89 static int vcd_get_track_end(mp_vcd_priv_t* vcd, int track) |
13682 | 90 { |
91 struct CDTrackInfo entry; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
92 |
25378
f0f03ec41cd3
Only read disc info once and save it for later using.
ulion
parents:
25376
diff
changeset
|
93 if (track > vcd->hdr.lastTrackNumberInLastSessionLSB) { |
25375
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
94 mp_msg(MSGT_OPEN, MSGL_ERR, |
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
95 "track number %d greater than last track number %d\n", |
25378
f0f03ec41cd3
Only read disc info once and save it for later using.
ulion
parents:
25376
diff
changeset
|
96 track, vcd->hdr.lastTrackNumberInLastSessionLSB); |
25375
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
97 return -1; |
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
98 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
99 |
13682 | 100 //read track info |
101 memset( &vcd->entry, 0, sizeof(vcd->entry)); | |
102 vcd->entry.addressType = kCDTrackInfoAddressTypeTrackNumber; | |
25378
f0f03ec41cd3
Only read disc info once and save it for later using.
ulion
parents:
25376
diff
changeset
|
103 vcd->entry.address = track<vcd->hdr.lastTrackNumberInLastSessionLSB?track+1:vcd->hdr.lastTrackNumberInLastSessionLSB; |
13682 | 104 vcd->entry.bufferLength = sizeof(entry); |
105 vcd->entry.buffer = &entry; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
106 |
13682 | 107 if (ioctl(vcd->fd, DKIOCCDREADTRACKINFO, &vcd->entry)) |
108 { | |
109 mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif2: %s\n",strerror(errno)); | |
110 return -1; | |
111 } | |
25378
f0f03ec41cd3
Only read disc info once and save it for later using.
ulion
parents:
25376
diff
changeset
|
112 if (track == vcd->hdr.lastTrackNumberInLastSessionLSB) |
25375
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
113 vcd->msf = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress) + |
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
114 be2me_32(entry.trackSize)); |
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
115 else |
23896 | 116 vcd->msf = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress)); |
13682 | 117 return VCD_SECTOR_DATA*vcd_get_msf(vcd); |
118 } | |
119 | |
30670
fbd6ba7e0e14
Mark vcd_get_track_end () and vcd_read_toc() as static.
diego
parents:
30426
diff
changeset
|
120 static mp_vcd_priv_t* vcd_read_toc(int fd) |
13682 | 121 { |
122 dk_cd_read_disc_info_t tochdr; | |
123 struct CDDiscInfo hdr; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
124 |
13682 | 125 dk_cd_read_track_info_t tocentry; |
126 struct CDTrackInfo entry; | |
127 CDMSF trackMSF; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
128 |
13682 | 129 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
|
130 int i, min = 0, sec = 0, frame = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
131 |
13682 | 132 //read toc header |
133 memset(&tochdr, 0, sizeof(tochdr)); | |
134 tochdr.buffer = &hdr; | |
135 tochdr.bufferLength = sizeof(hdr); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
136 |
13682 | 137 if (ioctl(fd, DKIOCCDREADDISCINFO, &tochdr) < 0) |
138 { | |
139 mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno)); | |
140 return NULL; | |
141 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
142 |
13682 | 143 //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
|
144 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
|
145 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
|
146 for (i=hdr.firstTrackNumberInLastSessionLSB ; i<=hdr.lastTrackNumberInLastSessionLSB + 1; i++) |
13682 | 147 { |
25375
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
148 if (i <= hdr.lastTrackNumberInLastSessionLSB) { |
13682 | 149 memset( &tocentry, 0, sizeof(tocentry)); |
150 tocentry.addressType = kCDTrackInfoAddressTypeTrackNumber; | |
25375
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
151 tocentry.address = i; |
13682 | 152 tocentry.bufferLength = sizeof(entry); |
153 tocentry.buffer = &entry; | |
154 | |
155 if (ioctl(fd,DKIOCCDREADTRACKINFO,&tocentry)==-1) | |
156 { | |
157 mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc entry: %s\n",strerror(errno)); | |
158 return NULL; | |
159 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
160 |
23896 | 161 trackMSF = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress)); |
25375
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
162 } |
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
163 else |
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
164 trackMSF = CDConvertLBAToMSF(be2me_32(entry.trackStartAddress) |
e1884244ba98
Get end position of last track by adding its starting address with track size.
ulion
parents:
23898
diff
changeset
|
165 + be2me_32(entry.trackSize)); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
166 |
13682 | 167 //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
|
168 if (i<=hdr.lastTrackNumberInLastSessionLSB) |
13682 | 169 mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: format=%d %02d:%02d:%02d\n", |
170 (int)tocentry.address, | |
171 //(int)tocentry.entry.addr_type, | |
172 //(int)tocentry.entry.control, | |
173 (int)tocentry.addressType, | |
174 (int)trackMSF.minute, | |
175 (int)trackMSF.second, | |
176 (int)trackMSF.frame | |
177 ); | |
16547
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
178 |
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
|
179 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
|
180 { |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
181 if (i > hdr.firstTrackNumberInLastSessionLSB) |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
182 { |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
183 min = trackMSF.minute - min; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
184 sec = trackMSF.second - sec; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
185 frame = trackMSF.frame - frame; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
186 if ( frame < 0 ) |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
187 { |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
188 frame += 75; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
189 sec --; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
190 } |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
191 if ( sec < 0 ) |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
192 { |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
193 sec += 60; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
194 min --; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
195 } |
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
|
196 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
|
197 } |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
198 min = trackMSF.minute; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
199 sec = trackMSF.second; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
200 frame = trackMSF.frame; |
aa15d627a00b
Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents:
13842
diff
changeset
|
201 } |
13682 | 202 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
203 |
13682 | 204 vcd = malloc(sizeof(mp_vcd_priv_t)); |
205 vcd->fd = fd; | |
25378
f0f03ec41cd3
Only read disc info once and save it for later using.
ulion
parents:
25376
diff
changeset
|
206 vcd->hdr = hdr; |
13682 | 207 vcd->msf = trackMSF; |
208 return vcd; | |
209 } | |
210 | |
30981 | 211 static int vcd_end_track(mp_vcd_priv_t* vcd) |
212 { | |
213 return vcd->hdr.lastTrackNumberInLastSessionLSB; | |
214 } | |
215 | |
13682 | 216 static int vcd_read(mp_vcd_priv_t* vcd,char *mem) |
217 { | |
218 if (pread(vcd->fd,&vcd->buf,VCD_SECTOR_SIZE,vcd_get_msf(vcd)*VCD_SECTOR_SIZE) != VCD_SECTOR_SIZE) | |
219 return 0; // EOF? | |
220 | |
221 vcd->msf.frame++; | |
222 if (vcd->msf.frame==75) | |
223 { | |
224 vcd->msf.frame=0; | |
225 vcd->msf.second++; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
226 |
13682 | 227 if (vcd->msf.second==60) |
228 { | |
229 vcd->msf.second=0; | |
230 vcd->msf.minute++; | |
231 } | |
232 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26186
diff
changeset
|
233 |
13682 | 234 memcpy(mem,vcd->buf.data,VCD_SECTOR_DATA); |
235 return VCD_SECTOR_DATA; | |
236 } | |
237 | |
26029 | 238 #endif /* MPLAYER_VCD_READ_DARWIN_H */ |