s32 DeviceGetDiskType() { s32 s32result; if (devicehandle == NULL) return(-1); if (devicehandle == INVALID_HANDLE_VALUE) return(-1); if (traystatus == CDVD_TRAY_OPEN) return(disctype); if (disctype != CDVD_TYPE_NODISC) return(disctype); #ifdef VERBOSE_FUNCTION_DEVICE PrintLog("CDVDiso device: DeviceGetDiskType()"); #endif /* VERBOSE_FUNCTION_DEVICE */ disctype = CDVD_TYPE_DETCT; s32result = DVDgetDiskType(); if (s32result != -1) return(disctype); s32result = CDgetDiskType(); if (s32result != -1) return(disctype); disctype = CDVD_TYPE_UNKNOWN; return(disctype); } // END DeviceGetDiskType()
// Called by DeviceTrayStatus() s32 DeviceGetDiskType() { s32 s32result; s32 ioctldisktype; errno = 0; if (devicehandle == -1) return (-1); // ENDIF- Someone forget to open the device? if (traystatus == CDVD_TRAY_OPEN) return (disctype); // ENDIF- Is the device tray open? No disc to check yet. if (disctype != CDVD_TYPE_NODISC) return (disctype); // ENDIF- Already checked? Drive still closed? Disc hasn't changed. #ifdef VERBOSE_FUNCTION_DEVICE PrintLog("CDVD device: DeviceGetDiskType()"); #endif /* VERBOSE_FUNCTION_DEVICE */ disctype = CDVD_TYPE_DETCT; ioctldisktype = ioctl(devicehandle, CDROM_DISC_STATUS); if (errno != 0) { #ifdef VERBOSE_WARNINGS PrintLog("CDVD device: Trouble reading Disc Type!"); PrintLog("CDVD device: Error: %i:%s", errno, strerror(errno)); #endif /* VERBOSE_WARNINGS */ disctype = CDVD_TYPE_UNKNOWN; return (disctype); } // ENDIF- Trouble probing for a disc? s32result = DVDgetDiskType(ioctldisktype); if (s32result != -1) return (disctype); // ENDIF- Did we find a disc type? s32result = CDgetDiskType(ioctldisktype); if (s32result != -1) return (disctype); // ENDIF- Did we find a disc type? disctype = CDVD_TYPE_UNKNOWN; // Not a CD? Not a DVD? Is is peanut butter? return (disctype); } // END CDVDgetDiskType()