1998-12-16 04:43:28 +00:00
|
|
|
--- cdctl.h.orig Sun Dec 13 12:43:20 1998
|
|
|
|
+++ cdctl.h Sun Dec 13 12:43:20 1998
|
|
|
|
@@ -30,7 +30,8 @@
|
1998-12-09 05:44:06 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
-#include <linux/cdrom.h>
|
|
|
|
+#include <sys/cdio.h>
|
1998-12-16 04:43:28 +00:00
|
|
|
+#define CD_MSF_OFFSET 150
|
1998-12-09 05:44:06 +00:00
|
|
|
|
|
|
|
// CD status values
|
|
|
|
#define ssData 0
|
1998-12-16 04:43:28 +00:00
|
|
|
@@ -113,10 +114,10 @@
|
1998-12-09 05:44:06 +00:00
|
|
|
case acStop:
|
|
|
|
|
1998-12-16 04:43:28 +00:00
|
|
|
#ifdef _CDCTL_SOFT_STOP
|
1998-12-09 05:44:06 +00:00
|
|
|
- ioctl(cdfd,CDROMSTART);
|
|
|
|
+ ioctl(cdfd,CDIOCSTART);
|
|
|
|
#endif
|
1998-12-16 04:43:28 +00:00
|
|
|
#ifndef _CDCTL_SOFT_STOP
|
|
|
|
- ioctl(cdfd,CDROMSTOP);
|
|
|
|
+ ioctl(cdfd,CDIOCSTOP);
|
|
|
|
#endif
|
|
|
|
tskOurPlay=false;
|
|
|
|
|
|
|
|
@@ -127,10 +128,10 @@
|
|
|
|
tskOurPlay=true;
|
1998-12-09 05:44:06 +00:00
|
|
|
break;
|
|
|
|
case acPause:
|
|
|
|
- ioctl(cdfd,CDROMPAUSE);
|
|
|
|
+ ioctl(cdfd,CDIOCPAUSE);
|
|
|
|
break;
|
|
|
|
case acResume:
|
|
|
|
- ioctl(cdfd,CDROMRESUME);
|
|
|
|
+ ioctl(cdfd,CDIOCRESUME);
|
|
|
|
break;
|
|
|
|
case acPrev:
|
|
|
|
newtrk--;
|
1998-12-16 04:43:28 +00:00
|
|
|
@@ -157,13 +158,13 @@
|
1998-12-09 05:44:06 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case acEject:
|
|
|
|
- if(ioctl(cdfd,CDROMEJECT))
|
|
|
|
+ if(ioctl(cdfd,CDIOCEJECT))
|
|
|
|
status_state=ssNoCD;
|
|
|
|
else
|
|
|
|
status_state=ssTrayOpen;
|
|
|
|
break;
|
|
|
|
case acClose:
|
|
|
|
- ioctl(cdfd,CDROMCLOSETRAY);
|
|
|
|
+ ioctl(cdfd,CDIOCCLOSE);
|
|
|
|
status_state=ssNoCD;
|
|
|
|
break;
|
|
|
|
}
|
1998-12-16 04:43:28 +00:00
|
|
|
@@ -172,9 +173,13 @@
|
1998-12-09 05:44:06 +00:00
|
|
|
}
|
|
|
|
void doStatus(){
|
|
|
|
if(cdfdopen){
|
|
|
|
- struct cdrom_subchnl sc;
|
1998-12-16 04:43:28 +00:00
|
|
|
- sc.cdsc_format=CDROM_MSF;
|
1998-12-09 05:44:06 +00:00
|
|
|
- if(ioctl(cdfd, CDROMSUBCHNL, &sc)){
|
1998-12-16 04:43:28 +00:00
|
|
|
+ struct ioc_read_subchannel sc;
|
1998-12-09 05:44:06 +00:00
|
|
|
+ struct cd_sub_channel_info csci;
|
1998-12-16 04:43:28 +00:00
|
|
|
+ sc.address_format=CD_MSF_FORMAT;
|
|
|
|
+ sc.data=&csci;
|
|
|
|
+ sc.data_len=sizeof(csci);
|
|
|
|
+ sc.data_format=CD_MEDIA_CATALOG;
|
|
|
|
+ if(ioctl(cdfd, CDIOCREADSUBCHANNEL, &sc)){
|
1998-12-09 05:44:06 +00:00
|
|
|
if(status_state!=ssNoCD)
|
|
|
|
status_state=ssTrayOpen;
|
|
|
|
status_track=0;
|
1998-12-16 04:43:28 +00:00
|
|
|
@@ -185,18 +190,18 @@
|
1998-12-09 05:44:06 +00:00
|
|
|
if(status_state==ssNoCD || status_state==ssTrayOpen)
|
|
|
|
readTOC();
|
1998-12-16 04:43:28 +00:00
|
|
|
int start,now,stop;
|
1998-12-09 05:44:06 +00:00
|
|
|
- switch(sc.cdsc_audiostatus){
|
|
|
|
- case CDROM_AUDIO_PLAY:
|
|
|
|
+ switch(csci.header.audio_status){
|
|
|
|
+ case CD_AS_PLAY_IN_PROGRESS:
|
|
|
|
if(status_state==ssStopped)
|
1998-12-16 04:43:28 +00:00
|
|
|
tskOurPlay=false;
|
1998-12-09 05:44:06 +00:00
|
|
|
status_state=ssPlaying;
|
|
|
|
break;
|
|
|
|
- case CDROM_AUDIO_PAUSED:
|
|
|
|
+ case CD_AS_PLAY_PAUSED:
|
|
|
|
if(status_state==ssStopped)
|
1998-12-16 04:43:28 +00:00
|
|
|
tskOurPlay=false;
|
1998-12-09 05:44:06 +00:00
|
|
|
status_state=ssPaused;
|
|
|
|
break;
|
|
|
|
- case CDROM_AUDIO_COMPLETED:
|
|
|
|
+ case CD_AS_PLAY_COMPLETED:
|
1998-12-16 04:43:28 +00:00
|
|
|
if(tskOurPlay){
|
|
|
|
status_state=ssPlaying;
|
|
|
|
selecttrack();
|
|
|
|
@@ -212,7 +217,7 @@
|
1998-12-09 05:44:06 +00:00
|
|
|
if(tskOurPlay){
|
1998-12-16 04:43:28 +00:00
|
|
|
start = cd_trklist[status_track].track_start;
|
|
|
|
stop = start + cd_trklist[status_track].track_len - _CDCTL_SENSITIVITY;
|
|
|
|
- now = ((sc.cdsc_absaddr.msf.minute) * 60 + sc.cdsc_absaddr.msf.second) * 75 + sc.cdsc_absaddr.msf.frame - CD_MSF_OFFSET;
|
|
|
|
+ now = ((csci.what.position.absaddr.msf.minute) * 60 + csci.what.position.absaddr.msf.second) * 75 + csci.what.position.absaddr.msf.frame - CD_MSF_OFFSET;
|
|
|
|
if(now>0 && (now<start || now>=stop)){
|
|
|
|
status_state=ssPlaying;
|
|
|
|
selecttrack();
|
|
|
|
@@ -227,7 +232,7 @@
|
|
|
|
|
|
|
|
status_state=ssStopped;
|
1998-12-09 05:44:06 +00:00
|
|
|
}
|
|
|
|
- trackinfo(&sc);
|
|
|
|
+ trackinfo(&csci);
|
|
|
|
if(cd_trklist[status_track].track_data)
|
|
|
|
status_state=ssData;
|
|
|
|
}
|
1998-12-16 04:43:28 +00:00
|
|
|
@@ -235,19 +240,21 @@
|
1998-12-09 05:44:06 +00:00
|
|
|
}
|
|
|
|
void setVolume(int l, int r){
|
|
|
|
if(cdfdopen){
|
|
|
|
- struct cdrom_volctrl vol;
|
|
|
|
- vol.channel0=l;
|
|
|
|
- vol.channel1=r;
|
|
|
|
- ioctl(cdfd,CDROMVOLCTRL,&vol);
|
|
|
|
+ struct ioc_vol vol;
|
|
|
|
+ vol.vol[0]=l;
|
|
|
|
+ vol.vol[1]=r;
|
|
|
|
+ vol.vol[2]=0;
|
|
|
|
+ vol.vol[3]=0;
|
|
|
|
+ ioctl(cdfd,CDIOCSETVOL,&vol);
|
|
|
|
readVolume();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void readVolume(){
|
|
|
|
if(cdfdopen){
|
|
|
|
- struct cdrom_volctrl vol;
|
|
|
|
- ioctl(cdfd,CDROMVOLREAD,&vol);
|
|
|
|
- status_volumel=vol.channel0;
|
|
|
|
- status_volumer=vol.channel1;
|
|
|
|
+ struct ioc_vol vol;
|
|
|
|
+ ioctl(cdfd,CDIOCGETVOL,&vol);
|
|
|
|
+ status_volumel=vol.vol[0];
|
|
|
|
+ status_volumer=vol.vol[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int getVolumeL(){
|
1998-12-16 04:43:28 +00:00
|
|
|
@@ -296,12 +303,30 @@
|
1998-12-09 05:44:06 +00:00
|
|
|
void readTOC(){
|
|
|
|
if(cd_trklist!=NULL)
|
|
|
|
free(cd_trklist);
|
|
|
|
- struct cdrom_tochdr hdr;
|
|
|
|
- ioctl(cdfd, CDROMREADTOCHDR, &hdr);
|
|
|
|
- cd_tracks=hdr.cdth_trk1;
|
|
|
|
+ struct ioc_toc_header hdr;
|
|
|
|
+ ioctl(cdfd, CDIOREADTOCHEADER, &hdr);
|
1998-12-16 04:43:28 +00:00
|
|
|
+ cd_tracks=hdr.ending_track;
|
1998-12-09 05:44:06 +00:00
|
|
|
cd_trklist=(struct CDTrack *)malloc(cd_tracks*sizeof(struct CDTrack));
|
1998-12-16 04:43:28 +00:00
|
|
|
+#ifdef __FreeBSD__
|
|
|
|
+ struct ioc_read_toc_entry te;
|
|
|
|
+
|
|
|
|
+ te.data_len = (cd_tracks + 1) * sizeof(struct cd_toc_entry);
|
|
|
|
+ te.data = (struct cd_toc_entry *)malloc(te.data_len);
|
|
|
|
+ te.address_format = CD_LBA_FORMAT;
|
|
|
|
+ te.starting_track = 0;
|
|
|
|
+ ioctl(cdfd, CDIOREADTOCENTRYS, &te);
|
|
|
|
+ for(int i = 0; i < cd_tracks; i++) {
|
|
|
|
+ cd_trklist[i].track_data = te.data[i].control & 4 ? true : false;
|
|
|
|
+ cd_trklist[i].track_start = ntohl(te.data[i].addr.lba);
|
|
|
|
+ cd_trklist[i].track_len = ntohl(te.data[i + 1].addr.lba)
|
|
|
|
+ - cd_trklist[i].track_start;
|
|
|
|
+ }
|
|
|
|
+ cd_len = ntohl(te.data[cd_tracks].addr.lba);
|
|
|
|
+ free(te.data);
|
|
|
|
+#else
|
|
|
|
struct cdrom_tocentry te;
|
1998-12-09 05:44:06 +00:00
|
|
|
int prev_addr=0;
|
1998-12-16 04:43:28 +00:00
|
|
|
+
|
1998-12-09 05:44:06 +00:00
|
|
|
for(int i=0;i<=cd_tracks;i++){
|
|
|
|
if(i==cd_tracks)
|
1998-12-16 04:43:28 +00:00
|
|
|
te.cdte_track=CDROM_LEADOUT;
|
|
|
|
@@ -320,10 +345,11 @@
|
1998-12-09 05:44:06 +00:00
|
|
|
else
|
1998-12-16 04:43:28 +00:00
|
|
|
cd_len = this_addr;
|
1998-12-09 05:44:06 +00:00
|
|
|
}
|
1998-12-16 04:43:28 +00:00
|
|
|
+#endif
|
1998-12-09 05:44:06 +00:00
|
|
|
}
|
|
|
|
- void trackinfo(struct cdrom_subchnl *subchnl){
|
|
|
|
+ void trackinfo(struct cd_sub_channel_info *subchnl){
|
|
|
|
if(status_state==ssPlaying || status_state==ssPaused){
|
1998-12-16 04:43:28 +00:00
|
|
|
- status_pos=((subchnl->cdsc_absaddr.msf.minute) * 60 + subchnl->cdsc_absaddr.msf.second) * 75 + subchnl->cdsc_absaddr.msf.frame - CD_MSF_OFFSET;
|
|
|
|
+ status_pos=((subchnl->what.position.absaddr.msf.minute) * 60 + subchnl->what.position.absaddr.msf.second) * 75 + subchnl->what.position.absaddr.msf.frame - CD_MSF_OFFSET;
|
1998-12-09 05:44:06 +00:00
|
|
|
for(status_track=0;status_track<cd_tracks;status_track++){
|
|
|
|
if(status_pos<cd_trklist[status_track].track_start+cd_trklist[status_track].track_len)
|
|
|
|
break;
|
1998-12-16 04:43:28 +00:00
|
|
|
@@ -331,24 +357,24 @@
|
1998-12-09 05:44:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
void play(){
|
|
|
|
- struct cdrom_msf pmsf;
|
|
|
|
+ struct ioc_play_msf pmsf;
|
1998-12-16 04:43:28 +00:00
|
|
|
int abs0=status_pos + CD_MSF_OFFSET;
|
|
|
|
int abs1=cd_trklist[status_track].track_start + cd_trklist[status_track].track_len - 1 + CD_MSF_OFFSET;
|
1998-12-09 05:44:06 +00:00
|
|
|
- pmsf.cdmsf_min0=abs0/(75*60);
|
|
|
|
- pmsf.cdmsf_min1=abs1/(75*60);
|
|
|
|
- pmsf.cdmsf_sec0=(abs0%(75*60))/75;
|
|
|
|
- pmsf.cdmsf_sec1=(abs1%(75*60))/75;
|
|
|
|
- pmsf.cdmsf_frame0=abs0%75;
|
|
|
|
- pmsf.cdmsf_frame1=abs1%75;
|
|
|
|
+ pmsf.start_m=abs0/(75*60);
|
|
|
|
+ pmsf.end_m=abs1/(75*60);
|
|
|
|
+ pmsf.start_s=(abs0%(75*60))/75;
|
|
|
|
+ pmsf.end_s=(abs1%(75*60))/75;
|
|
|
|
+ pmsf.start_f=abs0%75;
|
|
|
|
+ pmsf.end_f=abs1%75;
|
|
|
|
|
|
|
|
#ifdef _CDCTL_STOP_BEFORE_PLAY
|
|
|
|
- ioctl(cdfd,CDROMSTOP);
|
|
|
|
+ ioctl(cdfd,CDIOCSTOP);
|
|
|
|
#endif
|
|
|
|
#ifdef _CDCTL_START_BEFORE_PLAY
|
|
|
|
- ioctl(cdfd,CDROMSTART);
|
|
|
|
+ ioctl(cdfd,CDIOCSTART);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
- ioctl(cdfd,CDROMPLAYMSF,&pmsf);
|
|
|
|
+ ioctl(cdfd,CDIOCPLAYMSF,&pmsf);
|
|
|
|
}
|
|
|
|
void select(int trk){
|
|
|
|
status_track=trk;
|
1998-12-16 04:43:28 +00:00
|
|
|
@@ -357,10 +383,10 @@
|
|
|
|
if(cd_trklist[status_track].track_data){
|
1998-12-09 05:44:06 +00:00
|
|
|
|
|
|
|
#ifdef _CDCTL_HARD_STOP
|
|
|
|
- ioctl(cdfd,CDROMSTOP);
|
|
|
|
+ ioctl(cdfd,CDIOCSTOP);
|
|
|
|
#endif
|
|
|
|
#ifndef _CDCTL_HARD_STOP
|
|
|
|
- ioctl(cdfd,CDROMSTART);
|
|
|
|
+ ioctl(cdfd,CDIOCSTART);
|
|
|
|
#endif
|
1998-12-16 04:43:28 +00:00
|
|
|
tskOurPlay=false;
|
1998-12-09 05:44:06 +00:00
|
|
|
|