|
Added
Link Here
|
| 1 |
--- ./cd_linux.c.orig Sat Jun 10 12:08:13 2006 |
| 2 |
+++ ./cd_linux.c Sat Jun 10 12:08:13 2006 |
| 3 |
@@ -31,7 +31,7 @@ |
| 4 |
#include <time.h> |
| 5 |
#include <errno.h> |
| 6 |
|
| 7 |
-#include <linux/cdrom.h> |
| 8 |
+#include <sys/cdio.h> |
| 9 |
|
| 10 |
#include "quakedef.h" |
| 11 |
|
| 12 |
@@ -54,8 +54,8 @@ |
| 13 |
if (cdfile == -1 || !enabled) |
| 14 |
return; // no cd init'd |
| 15 |
|
| 16 |
- if ( ioctl(cdfile, CDROMEJECT) == -1 ) |
| 17 |
- Con_DPrintf("ioctl cdromeject failed\n"); |
| 18 |
+ if ( ioctl(cdfile, CDIOCEJECT) == -1 ) |
| 19 |
+ Con_DPrintf("ioctl CDIOCEJECT failed\n"); |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
@@ -64,30 +64,30 @@ |
| 24 |
if (cdfile == -1 || !enabled) |
| 25 |
return; // no cd init'd |
| 26 |
|
| 27 |
- if ( ioctl(cdfile, CDROMCLOSETRAY) == -1 ) |
| 28 |
- Con_DPrintf("ioctl cdromclosetray failed\n"); |
| 29 |
+ if ( ioctl(cdfile, CDIOCCLOSE) == -1 ) |
| 30 |
+ Con_DPrintf("ioctl CDIOCCLOSE failed\n"); |
| 31 |
} |
| 32 |
|
| 33 |
static int CDAudio_GetAudioDiskInfo(void) |
| 34 |
{ |
| 35 |
- struct cdrom_tochdr tochdr; |
| 36 |
+ struct ioc_toc_header tochdr; |
| 37 |
|
| 38 |
cdValid = false; |
| 39 |
|
| 40 |
- if ( ioctl(cdfile, CDROMREADTOCHDR, &tochdr) == -1 ) |
| 41 |
+ if ( ioctl(cdfile, CDIOREADTOCHEADER, &tochdr) == -1 ) |
| 42 |
{ |
| 43 |
- Con_DPrintf("ioctl cdromreadtochdr failed\n"); |
| 44 |
+ Con_DPrintf("ioctl CDIOREADTOCHEADER failed\n"); |
| 45 |
return -1; |
| 46 |
} |
| 47 |
|
| 48 |
- if (tochdr.cdth_trk0 < 1) |
| 49 |
+ if (tochdr.starting_track < 1) |
| 50 |
{ |
| 51 |
Con_DPrintf("CDAudio: no music tracks\n"); |
| 52 |
return -1; |
| 53 |
} |
| 54 |
|
| 55 |
cdValid = true; |
| 56 |
- maxTrack = tochdr.cdth_trk1; |
| 57 |
+ maxTrack = tochdr.ending_track; |
| 58 |
|
| 59 |
return 0; |
| 60 |
} |
| 61 |
@@ -95,8 +95,8 @@ |
| 62 |
|
| 63 |
void CDAudio_Play(byte track, qboolean looping) |
| 64 |
{ |
| 65 |
- struct cdrom_tocentry entry; |
| 66 |
- struct cdrom_ti ti; |
| 67 |
+ struct ioc_read_toc_single_entry entry; |
| 68 |
+ struct ioc_play_track ti; |
| 69 |
|
| 70 |
if (cdfile == -1 || !enabled) |
| 71 |
return; |
| 72 |
@@ -115,7 +115,7 @@ |
| 73 |
Con_DPrintf("CDAudio: Bad track number %u.\n", track); |
| 74 |
return; |
| 75 |
} |
| 76 |
- |
| 77 |
+/* |
| 78 |
// don't try to play a non-audio track |
| 79 |
entry.cdte_track = track; |
| 80 |
entry.cdte_format = CDROM_MSF; |
| 81 |
@@ -129,7 +129,7 @@ |
| 82 |
Con_Printf("CDAudio: track %i is not audio\n", track); |
| 83 |
return; |
| 84 |
} |
| 85 |
- |
| 86 |
+*/ |
| 87 |
if (playing) |
| 88 |
{ |
| 89 |
if (playTrack == track) |
| 90 |
@@ -137,19 +137,19 @@ |
| 91 |
CDAudio_Stop(); |
| 92 |
} |
| 93 |
|
| 94 |
- ti.cdti_trk0 = track; |
| 95 |
- ti.cdti_trk1 = track; |
| 96 |
- ti.cdti_ind0 = 1; |
| 97 |
- ti.cdti_ind1 = 99; |
| 98 |
- |
| 99 |
- if ( ioctl(cdfile, CDROMPLAYTRKIND, &ti) == -1 ) |
| 100 |
+ ti.start_track = track; |
| 101 |
+ ti.end_track = track; |
| 102 |
+ ti.start_index = 1; |
| 103 |
+ ti.end_index = 99; |
| 104 |
+ |
| 105 |
+ if ( ioctl(cdfile, CDIOCPLAYTRACKS, &ti) == -1 ) |
| 106 |
{ |
| 107 |
- Con_DPrintf("ioctl cdromplaytrkind failed\n"); |
| 108 |
+ Con_DPrintf("ioctl CDIOCPLAYTRACKS failed\n"); |
| 109 |
return; |
| 110 |
} |
| 111 |
|
| 112 |
- if ( ioctl(cdfile, CDROMRESUME) == -1 ) |
| 113 |
- Con_DPrintf("ioctl cdromresume failed\n"); |
| 114 |
+ if ( ioctl(cdfile, CDIOCRESUME) == -1 ) |
| 115 |
+ Con_DPrintf("ioctl CDIOCRESUME failed\n"); |
| 116 |
|
| 117 |
playLooping = looping; |
| 118 |
playTrack = track; |
| 119 |
@@ -168,8 +168,8 @@ |
| 120 |
if (!playing) |
| 121 |
return; |
| 122 |
|
| 123 |
- if ( ioctl(cdfile, CDROMSTOP) == -1 ) |
| 124 |
- Con_DPrintf("ioctl cdromstop failed (%d)\n", errno); |
| 125 |
+ if ( ioctl(cdfile, CDIOCSTOP) == -1 ) |
| 126 |
+ Con_DPrintf("ioctl CDIOCSTOP failed (%d)\n", errno); |
| 127 |
|
| 128 |
wasPlaying = false; |
| 129 |
playing = false; |
| 130 |
@@ -183,8 +183,8 @@ |
| 131 |
if (!playing) |
| 132 |
return; |
| 133 |
|
| 134 |
- if ( ioctl(cdfile, CDROMPAUSE) == -1 ) |
| 135 |
- Con_DPrintf("ioctl cdrompause failed\n"); |
| 136 |
+ if ( ioctl(cdfile, CDIOCPAUSE) == -1 ) |
| 137 |
+ Con_DPrintf("ioctl CDIOCPAUSE failed\n"); |
| 138 |
|
| 139 |
wasPlaying = playing; |
| 140 |
playing = false; |
| 141 |
@@ -202,8 +202,8 @@ |
| 142 |
if (!wasPlaying) |
| 143 |
return; |
| 144 |
|
| 145 |
- if ( ioctl(cdfile, CDROMRESUME) == -1 ) |
| 146 |
- Con_DPrintf("ioctl cdromresume failed\n"); |
| 147 |
+ if ( ioctl(cdfile, CDIOCRESUME) == -1 ) |
| 148 |
+ Con_DPrintf("ioctl CDIOCRESUME failed\n"); |
| 149 |
playing = true; |
| 150 |
} |
| 151 |
|
| 152 |
@@ -327,7 +327,8 @@ |
| 153 |
|
| 154 |
void CDAudio_Update(void) |
| 155 |
{ |
| 156 |
- struct cdrom_subchnl subchnl; |
| 157 |
+ struct ioc_read_subchannel subchnl; |
| 158 |
+ struct cd_sub_channel_info data; |
| 159 |
static time_t lastchk; |
| 160 |
|
| 161 |
if (!enabled) |
| 162 |
@@ -351,14 +352,17 @@ |
| 163 |
|
| 164 |
if (playing && lastchk < time(NULL)) { |
| 165 |
lastchk = time(NULL) + 2; //two seconds between chks |
| 166 |
- subchnl.cdsc_format = CDROM_MSF; |
| 167 |
- if (ioctl(cdfile, CDROMSUBCHNL, &subchnl) == -1 ) { |
| 168 |
- Con_DPrintf("ioctl cdromsubchnl failed\n"); |
| 169 |
+ subchnl.data = &data; |
| 170 |
+ subchnl.data_len = sizeof(data); |
| 171 |
+ subchnl.address_format = CD_MSF_FORMAT; |
| 172 |
+ subchnl.data_format = CD_CURRENT_POSITION; |
| 173 |
+ if (ioctl(cdfile, CDIOCREADSUBCHANNEL, (char*) &subchnl) == -1 ) { |
| 174 |
+ Con_DPrintf("ioctl CDIOCREADSUBCHANNEL failed\n"); |
| 175 |
playing = false; |
| 176 |
return; |
| 177 |
} |
| 178 |
- if (subchnl.cdsc_audiostatus != CDROM_AUDIO_PLAY && |
| 179 |
- subchnl.cdsc_audiostatus != CDROM_AUDIO_PAUSED) { |
| 180 |
+ if (subchnl.data->header.audio_status != CD_AS_PLAY_IN_PROGRESS && |
| 181 |
+ subchnl.data->header.audio_status != CD_AS_PLAY_PAUSED) { |
| 182 |
playing = false; |
| 183 |
if (playLooping) |
| 184 |
CDAudio_Play(playTrack, true); |