annotate libmpdemux/vcd_read.h @ 10368:6fb8a6a4a071

removing my (nonworking) email address
author alex
date Thu, 03 Jul 2003 20:22:51 +0000
parents 134e4332f550
children aa15d627a00b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 //=================== VideoCD ==========================
2089
d7920c8257e2 BSD/OS support
arpi
parents: 1973
diff changeset
2 #if defined(linux) || defined(sun) || defined(__bsdi__)
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
3
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
4 typedef struct mp_vcd_priv_st mp_vcd_priv_t;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
5
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
6 #if defined(linux)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
7 #include <linux/cdrom.h>
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
8 #elif defined(sun)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
9 #include <sys/cdio.h>
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
10 static int sun_vcd_read(mp_vcd_priv_t*, int*);
2089
d7920c8257e2 BSD/OS support
arpi
parents: 1973
diff changeset
11 #elif defined(__bsdi__)
d7920c8257e2 BSD/OS support
arpi
parents: 1973
diff changeset
12 #include <dvd.h>
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
13 #endif
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
14
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
15 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 cdrom_tocentry entry;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
18 char buf[VCD_SECTOR_SIZE];
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
19 };
1
3b5f5d1c5041 Initial revision
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.cdte_addr.msf.frame=sect%75;
1
3b5f5d1c5041 Initial revision
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.cdte_addr.msf.second=sect%60;
1
3b5f5d1c5041 Initial revision
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.cdte_addr.msf.minute=sect;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 }
3b5f5d1c5041 Initial revision
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.cdte_addr.msf.frame +
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
31 (vcd->entry.cdte_addr.msf.second+
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
32 vcd->entry.cdte_addr.msf.minute*60)*75;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 }
3b5f5d1c5041 Initial revision
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.cdte_format = CDROM_MSF;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
37 vcd->entry.cdte_track = track;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
38 if (ioctl(vcd->fd, CDROMREADTOCENTRY, &vcd->entry)) {
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));
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 1
diff changeset
40 return -1;
1
3b5f5d1c5041 Initial revision
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);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 }
3b5f5d1c5041 Initial revision
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){
598
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
46 struct cdrom_tochdr tochdr;
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
47 if (ioctl(vcd->fd,CDROMREADTOCHDR,&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.cdte_format = CDROM_MSF;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
52 vcd->entry.cdte_track = track<tochdr.cdth_trk1?(track+1):CDROM_LEADOUT;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
53 if (ioctl(vcd->fd, CDROMREADTOCENTRY, &vcd->entry)) {
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));
598
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
55 return -1;
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
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);
598
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
58 }
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
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){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 struct cdrom_tochdr tochdr;
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
62 mp_vcd_priv_t* vcd;
1
3b5f5d1c5041 Initial revision
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,CDROMREADTOCHDR,&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 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 for (i=tochdr.cdth_trk0 ; i<=tochdr.cdth_trk1 ; i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 struct cdrom_tocentry tocentry;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 tocentry.cdte_track = i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 tocentry.cdte_format = CDROM_MSF;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
74 if (ioctl(fd,CDROMREADTOCENTRY,&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 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1105
diff changeset
79 mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d mode: %d\n",
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 (int)tocentry.cdte_track,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 (int)tocentry.cdte_adr,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 (int)tocentry.cdte_ctrl,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 (int)tocentry.cdte_format,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 (int)tocentry.cdte_addr.msf.minute,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85 (int)tocentry.cdte_addr.msf.second,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 (int)tocentry.cdte_addr.msf.frame,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 (int)tocentry.cdte_datamode
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 }
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
90 vcd = malloc(sizeof(mp_vcd_priv_t));
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
91 vcd->fd = fd;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
92 return vcd;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
95 static int vcd_read(mp_vcd_priv_t* vcd,char *mem){
2089
d7920c8257e2 BSD/OS support
arpi
parents: 1973
diff changeset
96 #if defined(linux) || defined(__bsdi__)
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
97 memcpy(vcd->buf,&vcd->entry.cdte_addr.msf,sizeof(struct cdrom_msf));
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
98 if(ioctl(vcd->fd,CDROMREADRAW,vcd->buf)==-1) return 0; // EOF?
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
99 memcpy(mem,&vcd->buf[VCD_SECTOR_OFFS],VCD_SECTOR_DATA);
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
100 #elif defined(sun)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
101 {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
102 int offset;
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
103 if (sun_vcd_read(vcd->fd, &offset) <= 0) return 0;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
104 memcpy(mem,&vcd->buf[offset],VCD_SECTOR_DATA);
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
105 }
1020
72cacd3b8f30 Solaris 8 support - patch by Marcus Comstedt <marcus@idonex.se>
arpi_esp
parents: 598
diff changeset
106 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
108 vcd->entry.cdte_addr.msf.frame++;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
109 if (vcd->entry.cdte_addr.msf.frame==75){
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
110 vcd->entry.cdte_addr.msf.frame=0;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
111 vcd->entry.cdte_addr.msf.second++;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
112 if (vcd->entry.cdte_addr.msf.second==60){
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
113 vcd->entry.cdte_addr.msf.second=0;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
114 vcd->entry.cdte_addr.msf.minute++;
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
115 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
116 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
117
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
118 return VCD_SECTOR_DATA;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
119 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
120
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
121
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
122 #ifdef sun
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
123 #include <sys/scsi/generic/commands.h>
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
124 #include <sys/scsi/impl/uscsi.h>
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
125
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
126 #define SUN_XAREAD 1 /*fails on atapi drives*/
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
127 #define SUN_MODE2READ 2 /*fails on atapi drives*/
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
128 #define SUN_SCSIREAD 3
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
129 #define SUN_VCDREAD SUN_SCSIREAD
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
130
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
131 static int sun_vcd_read(mp_vcd_priv_t* vcd, int *offset)
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
132 {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
133 #if SUN_VCDREAD == SUN_XAREAD
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
134 struct cdrom_cdxa cdxa;
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
135 cdxa.cdxa_addr = vcd_get_msf(vcd);
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
136 cdxa.cdxa_length = 1;
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
137 cdxa.cdxa_data = vcd->buf;
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
138 cdxa.cdxa_format = CDROM_XA_SECTOR_DATA;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
139
10300
134e4332f550 solaris fix by Gtz Waschk <waschk@informatik.uni-rostock.de>
alex
parents: 9887
diff changeset
140 if(ioctl(vcd->fd,CDROMCDXA,&cdxa)==-1) {
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
141 mp_msg(MSGT_STREAM,MSGL_ERR,"CDROMCDXA: %s\n",strerror(errno));
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
142 return 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
143 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
144 *offset = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
145 #elif SUN_VCDREAD == SUN_MODE2READ
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
146 struct cdrom_read cdread;
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
147 cdread.cdread_lba = 4*vcd_get_msf(vcd);
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
148 cdread.cdread_bufaddr = vcd->buf;
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
149 cdread.cdread_buflen = 2336;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150
10300
134e4332f550 solaris fix by Gtz Waschk <waschk@informatik.uni-rostock.de>
alex
parents: 9887
diff changeset
151 if(ioctl(vcd->fd,CDROMREADMODE2,&cdread)==-1) {
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
152 mp_msg(MSGT_STREAM,MSGL_ERR,"CDROMREADMODE2: %s\n",strerror(errno));
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
153 return 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
154 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
155 *offset = 8;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
156 #elif SUN_VCDREAD == SUN_SCSIREAD
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
157 struct uscsi_cmd sc;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
158 union scsi_cdb cdb;
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
159 int lba = vcd_get_msf(vcd);
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
160 int blocks = 1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
161 int sector_type;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
162 int sync, header_code, user_data, edc_ecc, error_field;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
163 int sub_channel;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
164
1105
6121410e667f Remove compiler warning.
atmosfear
parents: 1061
diff changeset
165 /* sector_type = 3; *//* mode2 */
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
166 sector_type = 5; /* mode2/form2 */
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
167 sync = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
168 header_code = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
169 user_data = 1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
170 edc_ecc = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
171 error_field = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
172 sub_channel = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
173
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
174 memset(&cdb, 0, sizeof(cdb));
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
175 memset(&sc, 0, sizeof(sc));
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
176 cdb.scc_cmd = 0xBE;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
177 cdb.cdb_opaque[1] = (sector_type) << 2;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
178 cdb.cdb_opaque[2] = (lba >> 24) & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
179 cdb.cdb_opaque[3] = (lba >> 16) & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
180 cdb.cdb_opaque[4] = (lba >> 8) & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
181 cdb.cdb_opaque[5] = lba & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
182 cdb.cdb_opaque[6] = (blocks >> 16) & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
183 cdb.cdb_opaque[7] = (blocks >> 8) & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
184 cdb.cdb_opaque[8] = blocks & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
185 cdb.cdb_opaque[9] = (sync << 7) |
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
186 (header_code << 5) |
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
187 (user_data << 4) |
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
188 (edc_ecc << 3) |
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
189 (error_field << 1);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
190 cdb.cdb_opaque[10] = sub_channel;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
191
1061
0f7be115a4db patch by J¸«ärgen Keil
arpi_esp
parents: 1038
diff changeset
192 sc.uscsi_cdb = (caddr_t)&cdb;
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
193 sc.uscsi_cdblen = 12;
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
194 sc.uscsi_bufaddr = vcd->buf;
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
195 sc.uscsi_buflen = 2336;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
196 sc.uscsi_flags = USCSI_ISOLATE | USCSI_READ;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
197 sc.uscsi_timeout = 20;
10300
134e4332f550 solaris fix by Gtz Waschk <waschk@informatik.uni-rostock.de>
alex
parents: 9887
diff changeset
198 if (ioctl(vcd->fd, USCSICMD, &sc)) {
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
199 mp_msg(MSGT_STREAM,MSGL_ERR,"USCSICMD: READ CD: %s\n",strerror(errno));
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
200 return -1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
201 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
202 if (sc.uscsi_status) {
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 7406
diff changeset
203 mp_msg(MSGT_STREAM,MSGL_ERR,"scsi command failed with status %d\n", sc.uscsi_status);
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
204 return -1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
205 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
206 *offset = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
207 return 1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
208 #else
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
209 #error SUN_VCDREAD
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
210 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 }
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
212 #endif /*sun*/
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
213
3261
caac174877b7 using #ifdef HAVE_VCD
arpi
parents: 2450
diff changeset
214 #else /* linux || sun || __bsdi__ */
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
215
3261
caac174877b7 using #ifdef HAVE_VCD
arpi
parents: 2450
diff changeset
216 #error vcd is not yet supported on this arch...
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
217
3261
caac174877b7 using #ifdef HAVE_VCD
arpi
parents: 2450
diff changeset
218 #endif