|
||||
|
vbAccelerator - Contents of code file: cCDDriveInfo.clsThis file is part of the download VB5 CD Ripper, which is described in the article CD Ripping in VB Part 1. VERSION 1.0 CLASS BEGIN MultiUse = -1 'True END Attribute VB_Name = "cDrive" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Option Explicit ' ------------------------------------------------------------ ' Name: cDrive ' Author: Steve McMahon (steve@vbaccelerator.com) ' Date: 2004-05-06 ' Description: ' Wrapper around the CDRip.DLL API describing a drive ' capable of playing CDs. ' ' See http://vbaccelerator.com/ ' ------------------------------------------------------------ Public Enum ECDRipDriveType GENERIC = 0 TOSHIBA TOSHIBANEW IBM NEC DEC IMS KODAK RICOH HP PHILIPS PLASMON GRUNDIGCDR100IPW MITSUMICDR PLEXTOR SONY YAMAHA NRC IMSCDD5 CUSTOMDRIVE NUMDRIVETYPES End Enum Public Enum ECDRipReadMethod READMMC = 0 READ10 READNEC READSONY READMMC2 READMMC3 READC1 READC2 READC3 READMMC4 NUMREADMETHODS End Enum Public Enum ECDRipSetSpeed SPEEDNONE = 0 SPEEDMMC SPEEDSONY SPEEDYAMAHA SPEEDTOSHIBA SPEEDPHILIPS SPEEDNEC NUMSPEEDMETHODS End Enum Public Enum ECDRipENDIAN BIGENDIAN = 0 LITTLEENDIAN NUMENDIAN End Enum Public Enum ECDRipENABLEMODE ENABLENONE = 0 ENABLESTD NUMENABLEMODES End Enum Public Enum ECDRipOUTPUTFORMAT STEREO44100 = 0 MONO44100 STEREO22050 MONO22050 STEREO11025 MONO11025 NUMOUTPUTFORMATS End Enum Private Type tDRIVETABLE DriveType As ECDRipDriveType readMethod As ECDRipReadMethod setSpeed As ECDRipSetSpeed endian As ECDRipENDIAN enableMode As ECDRipENABLEMODE nDensity As Long bAtapi As Long ' BOOL End Type Private Const TRANSPLAYER_ASPI = (0) Private Const TRANSPLAYER_NTSCSI = (1) Private Const CR_RIPPING_MODE_NORMAL = (0) Private Const CR_RIPPING_MODE_PARANOIA = (1) Private Type tSENSKEY SK As Byte ASC As Byte ASCQ As Byte End Type ' hmmm this looks rather VB-hostile if it is byte aligned Private Type CDROMPARAMS lpszCDROMID As String * 255 '// CD-ROM ID, must be unique to index settings in INI file nNumReadSectors As Long '// Number of sector to read per burst nNumOverlapSectors As Long '// Number of overlap sectors for jitter correction nNumCompareSectors As Long '// Number of sector to compare for jitter correction nOffsetStart As Long '// Fudge factor at start of ripping in sectors nOffsetEnd As Long '// Fudge factor at the end of ripping in sectors nSpeed As Long '// CD-ROM speed factor 0 .. 32 x nSpinUpTime As Long ' // CD-ROM spin up time in seconds bJitterCorrection As Long '// Boolean indicates whether to use Jitter Correction bSwapLefRightChannel As Long '// Swap left and right channel ? driveTable As tDRIVETABLE '// Drive specific parameters btTargetID As Byte '// SCSI target ID btAdapterID As Byte '// SCSI Adapter ID btLunID As Byte '// SCSI LUN ID bAspiPosting As Long '// When set ASPI posting is used, otherwhiese ASPI polling is used nAspiRetries As Integer nAspiTimeOut As Integer bEnableMultiRead As Long '// Enables Multiple Read Verify Feature bMultiReadFirstOnly As Long '// Only do the multiple reads on the first block nMultiReadCount As Integer '// Number of times to reread and compare bLockDuringRead As Long '// Number of times to reread and compare nRippingMode As Integer nParanoiaMode As Integer bJunk(0 To 1024) As Byte End Type Private Declare Function CR_SetCDROMParameters Lib "cdrip.dll" (pParam As CDROMPARAMS) As Long Private Declare Function CR_GetCDROMParameters Lib "cdrip.dll" (pParam As CDROMPARAMS) As Long Private Declare Sub CR_SetActiveCDROM Lib "cdrip.dll" (ByVal nActiveDrive As Long) '// Checks if the unit is ready (i.e. is the CD media present) Private Declare Function CR_IsUnitReady Lib "cdrip.dll" () As Long '// Eject the CD, bEject=TRUE=> the CD will be ejected, bEject=FALSE=> the CD will be loaded Private Declare Function CR_EjectCD Lib "cdrip.dll" (ByVal bEject As Long) As Long '// Check if the CD is playing Private Declare Function CR_IsAudioPlaying Lib "cdrip.dll" () As Long '// Play track Private Declare Function CR_PlayTrack Lib "cdrip.dll" (ByVal nTrack As Long) As Long '// Stop Play track Private Declare Function CR_StopPlayTrack Lib "cdrip.dll" () '// Pause Play track Private Declare Function CR_PauseCD Lib "cdrip.dll" (ByVal bPause As Long) Private m_index As Long Private m_tP As CDROMPARAMS Private m_bDirty As Boolean Friend Property Get fCDIndex() As Long fCDIndex = m_index End Property Public Property Get IsUnitReady() As Boolean CR_SetActiveCDROM m_index IsUnitReady = IIf(CR_IsUnitReady() = 0, False, True) End Property Public Property Get IsAudioPlaying() As Boolean CR_SetActiveCDROM m_index IsAudioPlaying = IIf(CR_IsAudioPlaying() = 0, False, True) End Property Public Sub EjectCD() CR_SetActiveCDROM m_index CR_EjectCD 1 End Sub Public Sub CloseCD() CR_SetActiveCDROM m_index CR_EjectCD 0 End Sub Public Sub PlayCDTrack(ByVal nIndex As Long) CDRipErrHandler "cDrive.PlayCDTrack", CR_PlayTrack(nIndex - 1), True End Sub Public Sub UnpauseCD() CDRipErrHandler "cDrive.UnPauseCD", CR_PauseCD(0), True End Sub Public Sub PauseCD() CDRipErrHandler "cDrive.UnPauseCD", CR_PauseCD(1), True End Sub Public Sub StopCD() CDRipErrHandler "cDrive.UnPauseCD", CR_StopPlayTrack, True End Sub Public Property Get Name() As String Name = StripNull(m_tP.lpszCDROMID) End Property Public Property Get ReadSectors() As Long ReadSectors = m_tP.nNumReadSectors End Property Public Property Let ReadSectors(ByVal value As Long) If Not (m_tP.nNumReadSectors = value) Then m_tP.nNumReadSectors = value m_bDirty = True End If End Property Public Property Get ReadOverlap() As Long ReadOverlap = m_tP.nNumOverlapSectors End Property Public Property Let ReadOverlap(ByVal value As Long) If Not (m_tP.nNumOverlapSectors = value) Then m_tP.nNumOverlapSectors = value m_bDirty = True End If End Property Public Property Get BlockCompare() As Long BlockCompare = m_tP.nNumCompareSectors End Property Public Property Let BlockCompare(ByVal value As Long) If Not (m_tP.nNumCompareSectors = value) Then m_tP.nNumCompareSectors = value m_bDirty = True End If End Property Public Property Get StartOffset() As Long StartOffset = m_tP.nOffsetStart End Property Public Property Let StartOffset(ByVal value As Long) If Not (m_tP.nOffsetStart = value) Then m_tP.nOffsetStart = value m_bDirty = True End If End Property Public Property Get EndOffset() As Long EndOffset = m_tP.nOffsetEnd End Property Public Property Let EndOffset(ByVal value As Long) If Not (m_tP.nOffsetEnd = value) Then m_tP.nOffsetEnd = value m_bDirty = True End If End Property Public Property Get CDSpeed() As Long CDSpeed = m_tP.nSpeed End Property Public Property Let CDSpeed(ByVal value As Long) If Not (m_tP.nSpeed = value) Then m_tP.nSpeed = value m_bDirty = True End If End Property Public Property Get SpinUpTime() As Long SpinUpTime = m_tP.nSpinUpTime End Property Public Property Let SpinUpTime(ByVal value As Long) If Not (m_tP.nSpinUpTime = value) Then m_tP.nSpinUpTime = value m_bDirty = True End If End Property Public Property Get Retries() As Long Retries = m_tP.nAspiRetries End Property Public Property Let Retries(ByVal value As Long) If Not (m_tP.nAspiRetries = value) Then m_tP.nAspiRetries = value m_bDirty = True End If End Property Public Property Get DriveType() As ECDRipDriveType DriveType = m_tP.driveTable.DriveType End Property Public Property Let DriveType(ByVal value As ECDRipDriveType) If Not (m_tP.driveTable.DriveType = value) Then m_tP.driveTable.DriveType = value m_bDirty = True End If End Property Public Property Get RippingMethod() As ECDRipDriveType RippingMethod = m_tP.driveTable.readMethod End Property Public Property Let RippingMethod(ByVal value As ECDRipDriveType) If Not (m_tP.driveTable.readMethod = value) Then m_tP.driveTable.readMethod = value m_bDirty = True End If End Property Public Property Get TOC() As cToc Dim cToc As New cToc CR_SetActiveCDROM m_index cToc.fInit m_index Set TOC = cToc End Property Public Sub Refresh() fInit m_index End Sub Public Sub Apply() If (m_bDirty) Then CDRipErrHandler "cCDDriveInfo.Apply", CR_SetCDROMParameters(m_tP), True m_bDirty = False End If End Sub Friend Sub fInit(ByVal index As Long) m_bDirty = False m_index = index CR_SetActiveCDROM m_index CDRipErrHandler "cCDDriveInfo.fInit", CR_GetCDROMParameters(m_tP), True End Sub Private Function StripNull(ByVal sz As String) As String Dim i As Long i = InStr(sz, vbNullChar) If (i > 0) And (i < Len(sz)) Then StripNull = left(sz, i - 1) Else StripNull = sz End If End Function
|
|||
|