annotate libmpdemux/vcd_read_fbsd.h @ 12190:4e621a212d26

always add versionsinfo and icon on windows
author faust3
date Tue, 13 Apr 2004 11:22:37 +0000
parents 248c478a0699
children aa15d627a00b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 958
diff changeset
1 #include <sys/cdio.h>
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 958
diff changeset
2 #include <sys/cdrio.h>
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 958
diff changeset
3
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
4 //=================== VideoCD ==========================
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
5 #define CDROM_LEADOUT 0xAA
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
6
1177
f2516027a346 FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents: 1038
diff changeset
7 typedef struct {
f2516027a346 FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents: 1038
diff changeset
8 uint8_t sync [12];
f2516027a346 FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents: 1038
diff changeset
9 uint8_t header [4];
f2516027a346 FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents: 1038
diff changeset
10 uint8_t subheader [8];
f2516027a346 FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents: 1038
diff changeset
11 uint8_t data [2324];
f2516027a346 FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents: 1038
diff changeset
12 uint8_t spare [4];
f2516027a346 FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents: 1038
diff changeset
13 } cdsector_t;
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
14
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
15 typedef struct mp_vcd_priv_st {
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
16 int fd;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
17 struct ioc_read_toc_single_entry entry;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
18 cdsector_t buf;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
19 } mp_vcd_priv_t;
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
20
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
21 static inline void vcd_set_msf(mp_vcd_priv_t* vcd, unsigned int sect){
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
22 vcd->entry.entry.addr.msf.frame=sect%75;
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
23 sect=sect/75;
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
24 vcd->entry.entry.addr.msf.second=sect%60;
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
25 sect=sect/60;
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
26 vcd->entry.entry.addr.msf.minute=sect;
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
27 }
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
28
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
29 static inline unsigned int vcd_get_msf(mp_vcd_priv_t* vcd){
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
30 return vcd->entry.entry.addr.msf.frame +
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
31 (vcd->entry.entry.addr.msf.second+
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
32 vcd->entry.entry.addr.msf.minute*60)*75;
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
33 }
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
34
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
35 int vcd_seek_to_track(mp_vcd_priv_t* vcd, int track){
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
36 vcd->entry.address_format = CD_MSF_FORMAT;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
37 vcd->entry.track = track;
9899
248c478a0699 typo fix
nexus
parents: 9887
diff changeset
38 if (ioctl(vcd->fd, CDIOREADTOCENTRY, &vcd->entry)) {
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
39 mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif1: %s\n",strerror(errno));
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
40 return -1;
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
41 }
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
42 return VCD_SECTOR_DATA*vcd_get_msf(vcd);
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
43 }
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
44
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
45 int vcd_get_track_end(mp_vcd_priv_t* vcd, int track){
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
46 struct ioc_toc_header tochdr;
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
47 if (ioctl(vcd->fd,CDIOREADTOCHEADER,&tochdr)==-1) {
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
48 mp_msg(MSGT_STREAM,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno));
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
49 return -1;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
50 }
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
51 vcd->entry.address_format = CD_MSF_FORMAT;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
52 vcd->entry.track = track<tochdr.ending_track?(track+1):CDROM_LEADOUT;
9899
248c478a0699 typo fix
nexus
parents: 9887
diff changeset
53 if (ioctl(vcd->fd, CDIOREADTOCENTRY, &vcd->entry)) {
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
54 mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif2: %s\n",strerror(errno));
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
55 return -1;
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
56 }
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
57 return VCD_SECTOR_DATA*vcd_get_msf(vcd);
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
58 }
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
59
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
60 mp_vcd_priv_t* vcd_read_toc(int fd){
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
61 struct ioc_toc_header tochdr;
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
62 mp_vcd_priv_t* vcd;
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
63 int i;
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
64 if (ioctl(fd,CDIOREADTOCHEADER,&tochdr)==-1) {
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
65 mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno));
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
66 return NULL;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
67 }
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
68 for (i=tochdr.starting_track ; i<=tochdr.ending_track ; i++){
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
69 struct ioc_read_toc_single_entry tocentry;
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
70
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
71 tocentry.track = i;
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
72 tocentry.address_format = CD_MSF_FORMAT;
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
73
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
74 if (ioctl(fd,CDIOREADTOCENTRY,&tocentry)==-1) {
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
75 mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc entry: %s\n",strerror(errno));
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
76 return NULL;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
77 }
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
78
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
79 mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n",
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
80 (int)tocentry.track,
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
81 (int)tocentry.entry.addr_type,
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
82 (int)tocentry.entry.control,
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
83 (int)tocentry.address_format,
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
84 (int)tocentry.entry.addr.msf.minute,
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
85 (int)tocentry.entry.addr.msf.second,
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
86 (int)tocentry.entry.addr.msf.frame
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
87 );
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
88 }
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
89 vcd = malloc(sizeof(mp_vcd_priv_t));
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
90 vcd->fd = fd;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
91 return vcd;
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
92 }
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
93
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
94 static int vcd_read(mp_vcd_priv_t* vcd,char *mem){
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
95
9899
248c478a0699 typo fix
nexus
parents: 9887
diff changeset
96 if (pread(vcd->fd,&vcd->buf,VCD_SECTOR_SIZE,vcd_get_msf(vcd)*VCD_SECTOR_SIZE)
1177
f2516027a346 FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents: 1038
diff changeset
97 != VCD_SECTOR_SIZE) return 0; // EOF?
f2516027a346 FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents: 1038
diff changeset
98
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
99 vcd->entry.entry.addr.msf.frame++;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
100 if (vcd->entry.entry.addr.msf.frame==75){
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
101 vcd->entry.entry.addr.msf.frame=0;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
102 vcd->entry.entry.addr.msf.second++;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
103 if (vcd->entry.entry.addr.msf.second==60){
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
104 vcd->entry.entry.addr.msf.second=0;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
105 vcd->entry.entry.addr.msf.minute++;
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
106 }
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
107 }
9899
248c478a0699 typo fix
nexus
parents: 9887
diff changeset
108 memcpy(mem,vcd->buf.data,VCD_SECTOR_DATA);
958
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
109 return VCD_SECTOR_DATA;
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
110 }
162a78d3cc08 FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
diff changeset
111