| 1 | /* -*- tab-width: 8; c-basic-offset: 4 -*- */
|
|---|
| 2 | /*
|
|---|
| 3 | * MCI CDAUDIO Driver for OS/2. Interface to OS/2 DosIOCtrl()
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright 2000 Chris Wohlgemuth
|
|---|
| 6 | *
|
|---|
| 7 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 8 | *
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 | #define INCL_DOSDEVICES
|
|---|
| 13 | #define INCL_DOSDEVIOCTL
|
|---|
| 14 | #define INCL_DOS
|
|---|
| 15 |
|
|---|
| 16 | #include <os2wrap.h>
|
|---|
| 17 | //#include <cdrom.h>
|
|---|
| 18 |
|
|---|
| 19 | #pragma pack(1)
|
|---|
| 20 |
|
|---|
| 21 | typedef struct{
|
|---|
| 22 | UCHAR ucFirstTrack;
|
|---|
| 23 | UCHAR ucLastTrack;
|
|---|
| 24 | ULONG ulLeadOut;
|
|---|
| 25 | }CDINFO;
|
|---|
| 26 |
|
|---|
| 27 | typedef struct
|
|---|
| 28 | {
|
|---|
| 29 | ULONG ulTrackAddress;
|
|---|
| 30 | UCHAR ucTCInfo;
|
|---|
| 31 | }CDTRACKINFO;
|
|---|
| 32 |
|
|---|
| 33 | typedef struct
|
|---|
| 34 | {
|
|---|
| 35 | UCHAR signature[4];
|
|---|
| 36 | UCHAR ucTrackNum;
|
|---|
| 37 | }TINFOPARAM;
|
|---|
| 38 |
|
|---|
| 39 | typedef struct
|
|---|
| 40 | {
|
|---|
| 41 | UCHAR ucFrames;
|
|---|
| 42 | UCHAR ucSeconds;
|
|---|
| 43 | UCHAR ucMinutes;
|
|---|
| 44 | UCHAR ucNotUsed;
|
|---|
| 45 | }MSF;
|
|---|
| 46 |
|
|---|
| 47 | typedef struct
|
|---|
| 48 | {
|
|---|
| 49 | USHORT usStatusBits;
|
|---|
| 50 | ULONG ulStarting;
|
|---|
| 51 | ULONG ulEnding;
|
|---|
| 52 | }AUDIOSTATUS;
|
|---|
| 53 |
|
|---|
| 54 | typedef struct
|
|---|
| 55 | {
|
|---|
| 56 | UCHAR signature[4];
|
|---|
| 57 | UCHAR ucAddressMode;
|
|---|
| 58 | ULONG ulStartSector;
|
|---|
| 59 | ULONG ulEndSector;
|
|---|
| 60 | }PLAYPARAM2;
|
|---|
| 61 |
|
|---|
| 62 | typedef struct
|
|---|
| 63 | {
|
|---|
| 64 | UCHAR signature[4];
|
|---|
| 65 | UCHAR ucAddressMode;
|
|---|
| 66 | ULONG ulTo;
|
|---|
| 67 | }SEEKPARAM;
|
|---|
| 68 |
|
|---|
| 69 | typedef struct
|
|---|
| 70 | {
|
|---|
| 71 | UCHAR ucCtrlAdr;
|
|---|
| 72 | UCHAR ucTrack;
|
|---|
| 73 | UCHAR ucIndex;
|
|---|
| 74 | UCHAR ucTrackMins;
|
|---|
| 75 | UCHAR ucTrackSecs;
|
|---|
| 76 | UCHAR UCTrackFrames;
|
|---|
| 77 | UCHAR ucNull;
|
|---|
| 78 | UCHAR ucDiskMins;
|
|---|
| 79 | UCHAR ucDiskSecs;
|
|---|
| 80 | UCHAR ucDiskFrames;
|
|---|
| 81 | }SUBCHANNELQ;
|
|---|
| 82 |
|
|---|
| 83 | #pragma pack()
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 | LONG static _CDCalculateSector(MSF* msf1)
|
|---|
| 87 | {
|
|---|
| 88 | return ((msf1->ucMinutes*60+msf1->ucSeconds)*75+msf1->ucFrames);
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 | HFILE os2CDOpen(char *drive)
|
|---|
| 93 | {
|
|---|
| 94 | HFILE hfDrive = 0;
|
|---|
| 95 | ULONG ulAction;
|
|---|
| 96 | ULONG rc;
|
|---|
| 97 |
|
|---|
| 98 | rc = DosOpen(drive, &hfDrive, &ulAction, 0,
|
|---|
| 99 | FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS,
|
|---|
| 100 | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY |
|
|---|
| 101 | OPEN_FLAGS_DASD|OPEN_FLAGS_FAIL_ON_ERROR, NULL);
|
|---|
| 102 |
|
|---|
| 103 | if(rc)
|
|---|
| 104 | return 0;//Error
|
|---|
| 105 |
|
|---|
| 106 | return hfDrive;
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | ULONG os2CDClose(ULONG hfOS2Handle)
|
|---|
| 110 | {
|
|---|
| 111 | return DosClose(hfOS2Handle);
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | /******************************************/
|
|---|
| 115 | /* Result:
|
|---|
| 116 | 0: Error
|
|---|
| 117 | -1: CD is Data Disk
|
|---|
| 118 | other: # Audio tracks */
|
|---|
| 119 | /******************************************/
|
|---|
| 120 | int os2GetNumTracks(HFILE hfOS2Handle, ULONG *ulLeadOut)
|
|---|
| 121 | {
|
|---|
| 122 | ULONG ulParamLen;
|
|---|
| 123 | ULONG ulDataLen;
|
|---|
| 124 | ULONG rc;
|
|---|
| 125 | CDINFO cdInfo;
|
|---|
| 126 | TINFOPARAM tip;
|
|---|
| 127 | CDTRACKINFO trackInfo;
|
|---|
| 128 |
|
|---|
| 129 | ulDataLen=sizeof(cdInfo);
|
|---|
| 130 | ulParamLen=4;
|
|---|
| 131 |
|
|---|
| 132 | if(!hfOS2Handle)
|
|---|
| 133 | return 0;
|
|---|
| 134 |
|
|---|
| 135 | rc = DosDevIOCtl(hfOS2Handle, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIODISK,
|
|---|
| 136 | "CD01", 4, &ulParamLen, &cdInfo,
|
|---|
| 137 | sizeof(cdInfo), &ulDataLen);
|
|---|
| 138 |
|
|---|
| 139 | if(rc) {
|
|---|
| 140 | return 0;//Error
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 | ulDataLen=sizeof(trackInfo);
|
|---|
| 144 | ulParamLen=sizeof(TINFOPARAM);
|
|---|
| 145 | tip.signature[0]='C';
|
|---|
| 146 | tip.signature[1]='D';
|
|---|
| 147 | tip.signature[2]='0';
|
|---|
| 148 | tip.signature[3]='1';
|
|---|
| 149 | tip.ucTrackNum=1;
|
|---|
| 150 |
|
|---|
| 151 | /* We have a disc. Check if it's audio */
|
|---|
| 152 | rc = DosDevIOCtl(hfOS2Handle, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIOTRACK,
|
|---|
| 153 | &tip, sizeof(tip), &ulParamLen, &trackInfo,
|
|---|
| 154 | sizeof(trackInfo), &ulDataLen);
|
|---|
| 155 |
|
|---|
| 156 | if(rc) {
|
|---|
| 157 | return 0;//Error
|
|---|
| 158 | }
|
|---|
| 159 |
|
|---|
| 160 | if(trackInfo.ucTCInfo & 0x40) {
|
|---|
| 161 | return -1;//It's a data track
|
|---|
| 162 | }
|
|---|
| 163 | *ulLeadOut=cdInfo.ulLeadOut;
|
|---|
| 164 | return cdInfo.ucLastTrack-cdInfo.ucFirstTrack+1;
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 | BOOL os2GetCDStatus(HFILE hfOS2Handle, ULONG *ulStatus)
|
|---|
| 168 | {
|
|---|
| 169 | ULONG ulParamLen;
|
|---|
| 170 | ULONG ulDeviceStatus;
|
|---|
| 171 | ULONG ulDataLen;
|
|---|
| 172 | ULONG rc;
|
|---|
| 173 |
|
|---|
| 174 | ulDeviceStatus=0;
|
|---|
| 175 |
|
|---|
| 176 | /* Get status */
|
|---|
| 177 | ulDataLen=sizeof(ulDeviceStatus);
|
|---|
| 178 | ulParamLen=4;
|
|---|
| 179 | rc = DosDevIOCtl(hfOS2Handle, IOCTL_CDROMDISK, CDROMDISK_DEVICESTATUS,
|
|---|
| 180 | "CD01", 4, &ulParamLen, &ulDeviceStatus,
|
|---|
| 181 | sizeof(ulDeviceStatus), &ulDataLen);
|
|---|
| 182 | if(rc) {
|
|---|
| 183 | return FALSE;//Error
|
|---|
| 184 | }
|
|---|
| 185 |
|
|---|
| 186 | *ulStatus=ulDeviceStatus;
|
|---|
| 187 | return TRUE;
|
|---|
| 188 | }
|
|---|
| 189 |
|
|---|
| 190 | BOOL os2GetCDAudioStatus(HFILE hfOS2Handle, USHORT *usStatus)
|
|---|
| 191 | {
|
|---|
| 192 | AUDIOSTATUS asStatus;
|
|---|
| 193 | ULONG ulParamLen;
|
|---|
| 194 | ULONG ulDataLen;
|
|---|
| 195 | ULONG rc;
|
|---|
| 196 |
|
|---|
| 197 | /* Get status */
|
|---|
| 198 |
|
|---|
| 199 | ulDataLen=sizeof(asStatus);
|
|---|
| 200 | ulParamLen=4;
|
|---|
| 201 |
|
|---|
| 202 | /* Get information */
|
|---|
| 203 | rc = DosDevIOCtl(hfOS2Handle, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIOSTATUS,
|
|---|
| 204 | "CD01", 4, &ulParamLen, &asStatus,
|
|---|
| 205 | sizeof(asStatus), &ulDataLen);
|
|---|
| 206 | if(rc) {
|
|---|
| 207 | *usStatus=rc;
|
|---|
| 208 | return FALSE;//Error
|
|---|
| 209 | }
|
|---|
| 210 | *usStatus=asStatus.usStatusBits;
|
|---|
| 211 | return TRUE;
|
|---|
| 212 | }
|
|---|
| 213 |
|
|---|
| 214 | /* Returns sector info of track #numTrack */
|
|---|
| 215 | /* Starting with track 0 */
|
|---|
| 216 | ULONG os2CDQueryTrackStartSector( HFILE hfDrive, ULONG numTrack)
|
|---|
| 217 | {
|
|---|
| 218 | ULONG ulParamLen;
|
|---|
| 219 | ULONG ulDataLen;
|
|---|
| 220 | ULONG rc;
|
|---|
| 221 | CDINFO cdInfo;
|
|---|
| 222 | TINFOPARAM tip;
|
|---|
| 223 | CDTRACKINFO trackInfo[2];
|
|---|
| 224 |
|
|---|
| 225 | do {
|
|---|
| 226 | if(!hfDrive)
|
|---|
| 227 | break;
|
|---|
| 228 |
|
|---|
| 229 | /* Get cd info */
|
|---|
| 230 | ulDataLen=sizeof(cdInfo);
|
|---|
| 231 | ulParamLen=4;
|
|---|
| 232 | rc = DosDevIOCtl(hfDrive, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIODISK,
|
|---|
| 233 | "CD01", 4, &ulParamLen, &cdInfo,
|
|---|
| 234 | sizeof(cdInfo), &ulDataLen);
|
|---|
| 235 | if(rc)
|
|---|
| 236 | break;//Error
|
|---|
| 237 |
|
|---|
| 238 | ulDataLen=sizeof(trackInfo);
|
|---|
| 239 | ulParamLen=sizeof(TINFOPARAM);
|
|---|
| 240 | tip.signature[0]='C';
|
|---|
| 241 | tip.signature[1]='D';
|
|---|
| 242 | tip.signature[2]='0';
|
|---|
| 243 | tip.signature[3]='1';
|
|---|
| 244 | /* Get information about our track */
|
|---|
| 245 | tip.ucTrackNum=numTrack+1;
|
|---|
| 246 | if(tip.ucTrackNum<=cdInfo.ucLastTrack) {
|
|---|
| 247 | rc = DosDevIOCtl(hfDrive, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIOTRACK,
|
|---|
| 248 | &tip, sizeof(tip), &ulParamLen, &trackInfo[0],
|
|---|
| 249 | sizeof(trackInfo[0]), &ulDataLen);
|
|---|
| 250 | if(rc)
|
|---|
| 251 | break;//Error
|
|---|
| 252 | }else
|
|---|
| 253 | return _CDCalculateSector((MSF*)&cdInfo.ulLeadOut);
|
|---|
| 254 |
|
|---|
| 255 |
|
|---|
| 256 | return _CDCalculateSector((MSF*)&trackInfo[0].ulTrackAddress);
|
|---|
| 257 |
|
|---|
| 258 | }while(TRUE);
|
|---|
| 259 |
|
|---|
| 260 | /* error */
|
|---|
| 261 | return 0;
|
|---|
| 262 | }
|
|---|
| 263 |
|
|---|
| 264 |
|
|---|
| 265 | BOOL os2CDEject(HFILE hfDrive)
|
|---|
| 266 | {
|
|---|
| 267 | ULONG ulParamLen;
|
|---|
| 268 | ULONG rc;
|
|---|
| 269 |
|
|---|
| 270 | if(!hfDrive)
|
|---|
| 271 | return FALSE;
|
|---|
| 272 |
|
|---|
| 273 | ulParamLen=4;
|
|---|
| 274 | rc = DosDevIOCtl(hfDrive, IOCTL_CDROMDISK, CDROMDISK_EJECTDISK,
|
|---|
| 275 | "CD01", 4, &ulParamLen,0,
|
|---|
| 276 | 0, 0);
|
|---|
| 277 | if(rc)
|
|---|
| 278 | return FALSE;//Error
|
|---|
| 279 |
|
|---|
| 280 | return TRUE;
|
|---|
| 281 | }
|
|---|
| 282 |
|
|---|
| 283 | #ifndef CDROMDISK_CLOSETRAY
|
|---|
| 284 | #define CDROMDISK_CLOSETRAY 0x0045
|
|---|
| 285 | #endif
|
|---|
| 286 |
|
|---|
| 287 | BOOL os2CDCloseTray(HFILE hfDrive)
|
|---|
| 288 | {
|
|---|
| 289 | ULONG ulParamLen;
|
|---|
| 290 | ULONG rc;
|
|---|
| 291 |
|
|---|
| 292 | if(!hfDrive)
|
|---|
| 293 | return FALSE;
|
|---|
| 294 |
|
|---|
| 295 | ulParamLen=4;
|
|---|
| 296 | rc = DosDevIOCtl(hfDrive, IOCTL_CDROMDISK, CDROMDISK_CLOSETRAY,
|
|---|
| 297 | "CD01", 4, &ulParamLen,0,
|
|---|
| 298 | 0, 0);
|
|---|
| 299 | if(rc)
|
|---|
| 300 | return FALSE;//Error
|
|---|
| 301 |
|
|---|
| 302 | return TRUE;
|
|---|
| 303 | }
|
|---|
| 304 |
|
|---|
| 305 | BOOL os2CDStop(HFILE hfDrive)
|
|---|
| 306 | {
|
|---|
| 307 | ULONG ulParamLen;
|
|---|
| 308 | ULONG rc;
|
|---|
| 309 |
|
|---|
| 310 | if(!hfDrive)
|
|---|
| 311 | return FALSE;
|
|---|
| 312 |
|
|---|
| 313 |
|
|---|
| 314 |
|
|---|
| 315 | /* Stop CD */
|
|---|
| 316 | ulParamLen=4;
|
|---|
| 317 | rc = DosDevIOCtl(hfDrive, IOCTL_CDROMAUDIO, CDROMAUDIO_STOPAUDIO,
|
|---|
| 318 | "CD01", 4, &ulParamLen,0,
|
|---|
| 319 | 0, 0);
|
|---|
| 320 | if(rc)
|
|---|
| 321 | return FALSE;//Error
|
|---|
| 322 |
|
|---|
| 323 | return TRUE;
|
|---|
| 324 | }
|
|---|
| 325 |
|
|---|
| 326 |
|
|---|
| 327 | /*****************************************/
|
|---|
| 328 | /* */
|
|---|
| 329 | /* Plays frame range */
|
|---|
| 330 | /* */
|
|---|
| 331 | /* Returns TRUE if successful */
|
|---|
| 332 | /* */
|
|---|
| 333 | /*****************************************/
|
|---|
| 334 | BOOL os2CDPlayRange(HFILE hfDrive ,ULONG ulFrom, ULONG ulTo)
|
|---|
| 335 | {
|
|---|
| 336 | ULONG ulParamLen;
|
|---|
| 337 | ULONG ulDataLen;
|
|---|
| 338 | ULONG rc;
|
|---|
| 339 | CDINFO cdInfo;
|
|---|
| 340 | TINFOPARAM tip;
|
|---|
| 341 | CDTRACKINFO trackInfo[2];
|
|---|
| 342 | PLAYPARAM2 playParam={0};
|
|---|
| 343 |
|
|---|
| 344 | if(!hfDrive)
|
|---|
| 345 | return FALSE;
|
|---|
| 346 |
|
|---|
| 347 | //memcpy(&playParam,PlayParam, sizeof(playParam));
|
|---|
| 348 | /* Play the Track... */
|
|---|
| 349 | ulParamLen=sizeof(PLAYPARAM2);
|
|---|
| 350 | playParam.signature[0]='C';
|
|---|
| 351 | playParam.signature[1]='D';
|
|---|
| 352 | playParam.signature[2]='0';
|
|---|
| 353 | playParam.signature[3]='1';
|
|---|
| 354 | //playParam.ucAddressMode=01;
|
|---|
| 355 | playParam.ulStartSector=ulFrom;
|
|---|
| 356 | playParam.ulEndSector=ulTo;
|
|---|
| 357 |
|
|---|
| 358 | rc = DosDevIOCtl(hfDrive, IOCTL_CDROMAUDIO, CDROMAUDIO_PLAYAUDIO,
|
|---|
| 359 | &playParam, sizeof(playParam), &ulParamLen,0,
|
|---|
| 360 | 0, 0);
|
|---|
| 361 | return rc;
|
|---|
| 362 | if(rc)
|
|---|
| 363 | return FALSE;
|
|---|
| 364 |
|
|---|
| 365 | return TRUE;
|
|---|
| 366 | }
|
|---|
| 367 |
|
|---|
| 368 | BOOL os2CDResume(HFILE hfDrive)
|
|---|
| 369 | {
|
|---|
| 370 | ULONG ulParamLen;
|
|---|
| 371 | ULONG rc;
|
|---|
| 372 |
|
|---|
| 373 | if(!hfDrive)
|
|---|
| 374 | return FALSE;
|
|---|
| 375 |
|
|---|
| 376 | /* Stop CD */
|
|---|
| 377 | ulParamLen=4;
|
|---|
| 378 | rc = DosDevIOCtl(hfDrive, IOCTL_CDROMAUDIO, CDROMAUDIO_RESUMEAUDIO,
|
|---|
| 379 | "CD01", 4, &ulParamLen,0,
|
|---|
| 380 | 0, 0);
|
|---|
| 381 | if(rc)
|
|---|
| 382 | return FALSE;//Error
|
|---|
| 383 |
|
|---|
| 384 | return TRUE;
|
|---|
| 385 | }
|
|---|
| 386 |
|
|---|
| 387 | BOOL os2CDGetHeadLocation(HFILE hfOS2Handle, ULONG *ulHeadLocation)
|
|---|
| 388 | {
|
|---|
| 389 | UCHAR ucParam[5]={0};
|
|---|
| 390 | ULONG ulParamLen;
|
|---|
| 391 | ULONG ulDeviceStatus;
|
|---|
| 392 | ULONG ulDataLen;
|
|---|
| 393 | ULONG rc;
|
|---|
| 394 |
|
|---|
| 395 | ulDeviceStatus=0;
|
|---|
| 396 |
|
|---|
| 397 | if(!hfOS2Handle)
|
|---|
| 398 | return FALSE;
|
|---|
| 399 |
|
|---|
| 400 | /* Get Location */
|
|---|
| 401 | ulDataLen=sizeof(ulDeviceStatus);
|
|---|
| 402 | ulParamLen=5;
|
|---|
| 403 | ucParam[0]='C';
|
|---|
| 404 | ucParam[1]='D';
|
|---|
| 405 | ucParam[2]='0';
|
|---|
| 406 | ucParam[3]='1';
|
|---|
| 407 | ucParam[4]=0;
|
|---|
| 408 |
|
|---|
| 409 | rc = DosDevIOCtl(hfOS2Handle, IOCTL_CDROMDISK, CDROMDISK_GETHEADLOC,
|
|---|
| 410 | &ucParam, 5, &ulParamLen, &ulDeviceStatus,
|
|---|
| 411 | sizeof(ulDeviceStatus), &ulDataLen);
|
|---|
| 412 | if(rc) {
|
|---|
| 413 | return FALSE;//Error
|
|---|
| 414 | }
|
|---|
| 415 |
|
|---|
| 416 | *ulHeadLocation=ulDeviceStatus;
|
|---|
| 417 | return TRUE;
|
|---|
| 418 |
|
|---|
| 419 | }
|
|---|
| 420 |
|
|---|
| 421 | BOOL os2CDSeek(HFILE hfOS2Handle, ULONG ulTo)
|
|---|
| 422 | {
|
|---|
| 423 | SEEKPARAM sp={0};
|
|---|
| 424 | ULONG ulParamLen;
|
|---|
| 425 | ULONG rc;
|
|---|
| 426 |
|
|---|
| 427 | if(!hfOS2Handle)
|
|---|
| 428 | return FALSE;
|
|---|
| 429 |
|
|---|
| 430 | sp.signature[0]='C';
|
|---|
| 431 | sp.signature[1]='D';
|
|---|
| 432 | sp.signature[2]='0';
|
|---|
| 433 | sp.signature[3]='1';
|
|---|
| 434 | sp.ulTo=ulTo;
|
|---|
| 435 |
|
|---|
| 436 | ulParamLen=sizeof(sp);
|
|---|
| 437 |
|
|---|
| 438 | /* We have a disc. Check if it's audio */
|
|---|
| 439 | rc = DosDevIOCtl(hfOS2Handle, IOCTL_CDROMDISK, CDROMDISK_SEEK,
|
|---|
| 440 | &sp, sizeof(sp), &ulParamLen, 0,
|
|---|
| 441 | 0, 0);
|
|---|
| 442 |
|
|---|
| 443 | if(rc) {
|
|---|
| 444 | return FALSE;//Error
|
|---|
| 445 | }
|
|---|
| 446 |
|
|---|
| 447 | return TRUE;
|
|---|
| 448 | }
|
|---|
| 449 |
|
|---|
| 450 | BOOL os2CDQueryCurTrack(HFILE hfOS2Handle, UINT * uiCurTrack)
|
|---|
| 451 | {
|
|---|
| 452 | ULONG ulParamLen;
|
|---|
| 453 | ULONG ulDeviceStatus;
|
|---|
| 454 | ULONG ulDataLen;
|
|---|
| 455 | ULONG rc;
|
|---|
| 456 | SUBCHANNELQ scq;
|
|---|
| 457 |
|
|---|
| 458 |
|
|---|
| 459 | if(!hfOS2Handle)
|
|---|
| 460 | return FALSE;
|
|---|
| 461 |
|
|---|
| 462 |
|
|---|
| 463 | /* Get status */
|
|---|
| 464 | ulDataLen=sizeof(scq);
|
|---|
| 465 | ulParamLen=4;
|
|---|
| 466 | rc = DosDevIOCtl(hfOS2Handle, IOCTL_CDROMAUDIO, CDROMAUDIO_GETSUBCHANNELQ,
|
|---|
| 467 | "CD01", 4, &ulParamLen, &scq,
|
|---|
| 468 | sizeof(scq), &ulDataLen);
|
|---|
| 469 | if(rc) {
|
|---|
| 470 | return FALSE;//Error
|
|---|
| 471 | }
|
|---|
| 472 | *uiCurTrack=(scq.ucTrack & 0xF)+(scq.ucTrack & 0xF0)*10;
|
|---|
| 473 | return TRUE;
|
|---|
| 474 | }
|
|---|
| 475 |
|
|---|
| 476 | /**************************************************************/
|
|---|
| 477 | /* */
|
|---|
| 478 | /* This funktion returns the CD-Drives in the system */
|
|---|
| 479 | /* */
|
|---|
| 480 | /* iNumCD (output): # of CD-Drives */
|
|---|
| 481 | /* cFirstDrive (output): first cd-Drive letter */
|
|---|
| 482 | /* returns TRUE: We have cd-drives */
|
|---|
| 483 | /* */
|
|---|
| 484 | /**************************************************************/
|
|---|
| 485 | BOOL os2CDQueryCDDrives(int *iNumCD, char * cFirstDrive)
|
|---|
| 486 | {
|
|---|
| 487 | HFILE hfDevice;
|
|---|
| 488 | ULONG ulAction;
|
|---|
| 489 | ULONG ulLen;
|
|---|
| 490 | static char cFirst=0;
|
|---|
| 491 | static int iNumCDLocal=0;
|
|---|
| 492 | static BOOL haveCD=FALSE;
|
|---|
| 493 | static BOOL done=FALSE;
|
|---|
| 494 |
|
|---|
| 495 | struct
|
|---|
| 496 | {
|
|---|
| 497 | USHORT usCountCD;
|
|---|
| 498 | USHORT usFirstCD;
|
|---|
| 499 | } CDInfo;
|
|---|
| 500 |
|
|---|
| 501 | if(!done){
|
|---|
| 502 | ulLen = sizeof(CDInfo);
|
|---|
| 503 | if(!DosOpen("\\DEV\\CD-ROM2$", &hfDevice, &ulAction, 0,
|
|---|
| 504 | FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS,
|
|---|
| 505 | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL))
|
|---|
| 506 | {
|
|---|
| 507 | if(!DosDevIOCtl(hfDevice, 0x82, 0x60, NULL, 0, NULL, &CDInfo, ulLen, &ulLen))
|
|---|
| 508 | {
|
|---|
| 509 | if(CDInfo.usCountCD) {
|
|---|
| 510 | haveCD=TRUE;
|
|---|
| 511 | iNumCDLocal=CDInfo.usCountCD;
|
|---|
| 512 | cFirst='A'+ CDInfo.usFirstCD;
|
|---|
| 513 | }
|
|---|
| 514 | }
|
|---|
| 515 | DosClose(hfDevice);
|
|---|
| 516 | }
|
|---|
| 517 | done=TRUE;
|
|---|
| 518 | }
|
|---|
| 519 | *iNumCD=iNumCDLocal;
|
|---|
| 520 | *cFirstDrive=cFirst;
|
|---|
| 521 | return haveCD;
|
|---|
| 522 | }
|
|---|
| 523 |
|
|---|
| 524 |
|
|---|
| 525 |
|
|---|
| 526 |
|
|---|
| 527 |
|
|---|
| 528 |
|
|---|
| 529 |
|
|---|
| 530 |
|
|---|
| 531 |
|
|---|
| 532 |
|
|---|