aboutsummaryrefslogtreecommitdiffstats
path: root/audio/cdplay/files/patch-ab
blob: 11783cdcd366c5e47a70a99acc526ca529ef52dc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143

$FreeBSD$

--- cd.c.orig   Mon May 19 15:44:40 2003
+++ cd.c    Mon May 19 15:53:44 2003
@@ -98,8 +98,16 @@
   cd_play.end_s=cdinfo.s_sec[cdinfo.l_track-1];
   cd_play.end_f=cdinfo.s_frame[cdinfo.l_track-1];
   
-  if(ioctl (cd_fd, CDIOCPLAYMSF, (char *) &cd_play)<0)
-    per();
+  if(ioctl (cd_fd, CDIOCPLAYMSF, (char *) &cd_play)<0) {
+    /* Hack for IDE CD-ROMs */
+    if (cd_play.start_s < 2) {
+      cd_play.start_s=2;
+      if(ioctl (cd_fd, CDIOCPLAYMSF, (char *) &cd_play)<0)
+        per();
+    } else
+      per();
+  }
+  cdinfo.pause=0;
 }
 
 /* Skips one track forward */
@@ -111,7 +119,7 @@
 /* Quess */
 void prev(void)
 {
-  if(cdinfo.c_sec<1)
+  if(cdinfo.c_sec<4)
     play_track(cdinfo.c_track-1);
   else play_track(cdinfo.c_track);
 }
@@ -141,17 +149,59 @@
   }
 }
 
+/* Softly pauses the cd, or unpauses, as appropriate */
+void cdsoftpause(void)
+{
+  struct ioc_vol real_vol, cur_vol;
+  int i;
+
+  if(ioctl(cd_fd,CDIOCGETVOL,(char *) &real_vol)) per();
+  cur_vol = real_vol;
+
+  if(cdinfo.pause){
+    message="continue";
+    memset (cur_vol.vol, 0, sizeof(cur_vol.vol));
+    if(ioctl(cd_fd,CDIOCSETVOL,(char *) &cur_vol)) per();
+    if(ioctl(cd_fd,CDIOCRESUME)<0) per(); else cdinfo.pause=0;
+    for (i=0; i<20; usleep(21), i++) {
+      cur_vol.vol[0] += (real_vol.vol[0] / 20);
+      cur_vol.vol[1] += (real_vol.vol[1] / 20);
+      cur_vol.vol[2] += (real_vol.vol[2] / 20);
+      cur_vol.vol[3] += (real_vol.vol[3] / 20);
+      if(ioctl(cd_fd,CDIOCSETVOL,(char *) &cur_vol)) per();
+    }
+    if(ioctl(cd_fd,CDIOCSETVOL,(char *) &real_vol)) per();
+  }
+  else {
+    message="pause";
+    for (i=0; i<20; usleep(21), i++) {
+      cur_vol.vol[0] -= (real_vol.vol[0] / 20);
+      cur_vol.vol[1] -= (real_vol.vol[1] / 20);
+      cur_vol.vol[2] -= (real_vol.vol[2] / 20);
+      cur_vol.vol[3] -= (real_vol.vol[3] / 20);
+      if(ioctl(cd_fd,CDIOCSETVOL,(char *) &cur_vol)) per();
+    }
+    if(ioctl (cd_fd, CDIOCPAUSE)<0) per(); else cdinfo.pause=1;
+    if(ioctl (cd_fd, CDIOCSETVOL,(char *) &real_vol)) per();
+  }
+}
+  
 /* Huge kludge */
-void ff(void)
+void ff(int n_times)
 {
+  int secs;
   struct ioc_play_msf cd_play;
 
-  if(cdinfo.c_seca%60+5>=60){
-    cd_play.start_s=((cdinfo.c_seca%60)+5)%60;
+  secs=4*n_times;
+
+  if (secs > 59) secs=59;
+
+  if(cdinfo.c_seca%60+secs>=60){
+    cd_play.start_s=((cdinfo.c_seca%60)+secs)%60;
     cd_play.start_m=cdinfo.c_seca/60+1;
   }
   else {
-    cd_play.start_s=(cdinfo.c_seca%60)+5;
+    cd_play.start_s=(cdinfo.c_seca%60)+secs;
     cd_play.start_m=cdinfo.c_seca/60;
   }
   cd_play.start_f=1;
@@ -160,19 +210,25 @@
   cd_play.end_f=cdinfo.s_frame[cdinfo.l_track-1];
 
   if(ioctl(cd_fd,CDIOCPLAYMSF,(char *) &cd_play)<0) per();
+  cdinfo.pause=0;
 }
 
 /* Hi mom!! */
-void rew(void)
+void rew(int n_times)
 {
+  int secs;
   struct ioc_play_msf cd_play;
 
-  if(cdinfo.c_seca%60-5<0){
-    cd_play.start_s=((cdinfo.c_seca%60)-5)+60;
+  secs=4*n_times;
+
+  if (secs > 59) secs=59;
+
+  if(cdinfo.c_seca%60-secs<0){
+    cd_play.start_s=((cdinfo.c_seca%60)-secs)+60;
     cd_play.start_m=cdinfo.c_seca/60-1;
   }
   else {
-    cd_play.start_s=(cdinfo.c_seca%60)-5;
+    cd_play.start_s=(cdinfo.c_seca%60)-secs;
     cd_play.start_m=cdinfo.c_seca/60;
   }
   cd_play.start_f=1;
@@ -181,6 +237,7 @@
   cd_play.end_f=cdinfo.s_frame[cdinfo.l_track-1];
 
   if(ioctl(cd_fd,CDIOCPLAYMSF,(char *) &cd_play)<0) per();
+  cdinfo.pause=0;
 }
 
 /* Spit cd out */
@@ -192,6 +249,7 @@
     per();
   close(cd_fd);
   cdinfo.eject=1;
+  cdinfo.pause=1;
 }