Index » Empathy Jukebox : Blob e2c301 / ripper / akrip32.pas
unit akrip32;
{*
 * akrip32.h - Copyright (C) 1999 Jay A. Key
 *
 * API for akrip32.dll (V0.93)
 *
 * Translated for Borland Delphi by Holger Dors (holger@dors.de)
 *
 * History of Delphi version:
 *
 * 09. January 2000:  First released version
 * 05. February 2000: Updated for new function "CDDBGetServerList"
 *                   in V.093 of akrip32.dll
 *
 **********************************************************************
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 *}

interface

uses Windows;

const

  TRACK_AUDIO = {viewgit}{/viewgit};
  TRACK_DATA = ;

  MAXIDLEN = 64;
  MAXCDLIST = 8;

  {*
   * TRACKBUF
   *
   * This structure should not be allocated directly.  If a buffer containing
   * 27 * 2353 bytes is desired, a buffer should be allocated containing
   * the desired amount + 24 bytes.  The allocated memory can then be
   * typecast to a LPTRACKBUF.  It is the program's responsibility to guard
   * against reading/writing past the end of allocated memory.
   *
   * The following must always apply:
   *   (len + startOffset) <= (numFrames * 2352) <= maxLen
   *}

type
  PTRACKBUF = ^TRACKBUF;
  TRACKBUF = packed record
    startFrame: DWord; {* 00: starting frame number          *}
    numFrames: DWord; {* 04: number of frames read          *}
    maxLen: DWord; {* 08: length of buffer itself        *}
    len: DWord; {* 0C: length of data actually in buf *}
    status: DWord; {* 10: status of last read operation  *}
    startOffset: Integer; {* 14: offset of valid data in buf    *}
    buf: array[0..1024 * 1024 - 1] of Byte; {* 18: the data itself                *}
  end;

  TRACKBUFDUMMY = packed record
    startFrame: DWord; {* 00: starting frame number          *}
    numFrames: DWord; {* 04: number of frames read          *}
    maxLen: DWord; {* 08: length of buffer itself        *}
    len: DWord; {* 0C: length of data actually in buf *}
    status: DWord; {* 10: status of last read operation  *}
    startOffset: Integer; {* 14: offset of valid data in buf    *}
  end;

const
  TRACKBUFEXTRA = SizeOf(TRACKBUFDUMMY);

type
  PCDINFO = ^CDINFO;
  CDINFO = packed record
    vendor: array[0..8] of Char;
    prodId: array[0..16] of Char;
    rev: array[0..4] of Char;
    vendSpec: array[0..20] of Char;
  end;

  PCDREC = ^CDREC;
  CDREC = packed record
    ha: Byte;
    tgt: Byte;
    lun: Byte;
    pad: Byte;
    id: array[0..MAXIDLEN] of Char;
    info: CDINFO;
  end;

  PCDLIST = ^CDLIST;
  CDLIST = packed record
    max: Byte;
    num: Byte;
    cd: array[0..MAXCDLIST - 1] of CDREC;
  end;

    {*
     * TOCTRACK and TOC must be byte-aligned.  If you're not using Mingw32,
     * CygWin, or some other compiler that understands the PACKED keyword,
     * you need to ensure that  these structures are byte aligned.  Usually,
     * this is done using a
     *  #pragma pack(1)
     * See your compiler's documentation for details
     *}
  quad =array[0..3] of Byte;

  TOCTRACK =  packed record
    rsvd: Byte;
    ADR: Byte;
    trackNumber: Byte;
    rsvd2: Byte;
    addr: quad;
  end;

  PTOC = ^TOC;
  TOC = packed record
    tocLen: Word;
    firstTrack: Byte;
    lastTrack: Byte;
    tracks: array[0..99] of TOCTRACK;
  end;

  PTRACK = ^TRACK;
  TRACK =  packed record
    trackNo: Integer;
    startLBA: DWord;
    trackLen: DWord;
    _type: Byte;
    pad: array[0..3] of Byte;
    name: array[0..255] of Char;
  end;

  PREADMSF = ^READMSF;
  READMSF = record
    sm: Byte;
    ss: Byte;
    sf: Byte;
    em: Byte;
    es: Byte;
    ef: Byte;
  end;

const
  {*
   * Error codes set by functions in ASPILIB.C
   *}

  ALERR_NOERROR = 0;
  ALERR_NOWNASPI = 1;
  ALERR_NOGETASPI32SUPP = 2;
  ALERR_NOSENDASPICMD = 3;
  ALERR_ASPI = 4;
  ALERR_NOCDSELECTED = 5;
  ALERR_BUFTOOSMALL = 6;
  ALERR_INVHANDLE = 7;
  ALERR_NOMOREHAND = 8;
  ALERR_BUFPTR = 9;
  ALERR_NOTACD = 10;
  ALERR_LOCK = 11;
  ALERR_DUPHAND = 12;
  ALERR_INVPTR = 13;
  ALERR_INVPARM = 14;
  ALERR_JITTER = 15;

  {*
   * constants used for queryCDParms()
   *}

  CDP_READCDR = {viewgit}{/viewgit}01; // can read CD-R
  CDP_READCDE = {viewgit}{/viewgit}02; // can read CD-E
  CDP_METHOD2 = {viewgit}{/viewgit}03; // can read CD-R wriiten via method 2
  CDP_WRITECDR = {viewgit}{/viewgit}04; // can write CD-R
  CDP_WRITECDE = {viewgit}{/viewgit}05; // can write CD-E
  CDP_AUDIOPLAY = {viewgit}{/viewgit}06; // can play audio
  CDP_COMPOSITE = {viewgit}{/viewgit}07; // composite audio/video stream
  CDP_DIGITAL1 = {viewgit}{/viewgit}08; // digital output (IEC958) on port 1
  CDP_DIGITAL2 = {viewgit}{/viewgit}09; // digital output (IEC958) on port 2
  CDP_M2FORM1 = {viewgit}{/viewgit}0A; // reads Mode 2 Form 1 (XA) format
  CDP_M2FORM2 = {viewgit}{/viewgit}0B; // reads Mode 2 Form 2 format
  CDP_MULTISES = {viewgit}{/viewgit}0C; // reads multi-session or Photo-CD
  CDP_CDDA = {viewgit}{/viewgit}0D; // supports cd-da
  CDP_STREAMACC = {viewgit}{/viewgit}0E; // supports "stream is accurate"
  CDP_RW = {viewgit}{/viewgit}0F; // can return R-W info
  CDP_RWCORR = {viewgit}{/viewgit}10; // returns R-W de-interleaved and err.
  // corrected
  CDP_C2SUPP = {viewgit}{/viewgit}11; // C2 error pointers
  CDP_ISRC = {viewgit}{/viewgit}12; // can return the ISRC info
  CDP_UPC = {viewgit}{/viewgit}13; // can return the Media Catalog Number
  CDP_CANLOCK = {viewgit}{/viewgit}14; // prevent/allow cmd. can lock the media
  CDP_LOCKED = {viewgit}{/viewgit}15; // current lock state (TRUE = LOCKED)
  CDP_PREVJUMP = {viewgit}{/viewgit}16; // prevent/allow jumper state
  CDP_CANEJECT = {viewgit}{/viewgit}17; // drive can eject disk
  CDP_MECHTYPE = {viewgit}{/viewgit}18; // type of disk loading supported
  CDP_SEPVOL = {viewgit}{/viewgit}19; // independent audio level for channels
  CDP_SEPMUTE = {viewgit}{/viewgit}1A; // independent mute for channels
  CDP_SDP = {viewgit}{/viewgit}1B; // supports disk present (SDP)
  CDP_SSS = {viewgit}{/viewgit}1C; // Software Slot Selection
  CDP_MAXSPEED = {viewgit}{/viewgit}1D; // maximum supported speed of drive
  CDP_NUMVOL = {viewgit}{/viewgit}1E; // number of volume levels
  CDP_BUFSIZE = {viewgit}{/viewgit}1F; // size of output buffer
  CDP_CURRSPEED = {viewgit}{/viewgit}20; // current speed of drive
  CDP_SPM = {viewgit}{/viewgit}21; // "S" units per "M" (MSF format)
  CDP_FPS = {viewgit}{/viewgit}22; // "F" units per "S" (MSF format)
  CDP_INACTMULT = {viewgit}{/viewgit}23; // inactivity multiplier ( x 125 ms)
  CDP_MSF = {viewgit}{/viewgit}24; // use MSF format for READ TOC cmd
  CDP_OVERLAP = {viewgit}{/viewgit}25; // number of overlap frames for jitter
  CDP_JITTER = {viewgit}{/viewgit}26; // number of frames to check for jitter
  CDP_READMODE = {viewgit}{/viewgit}27; // mode to attempt jitter corr.

  {*
   * defines for GETCDHAND  readType
   *
   *}
  CDR_ANY = {viewgit}{/viewgit}; // unknown
  CDR_ATAPI1 = ; // ATAPI per spec
  CDR_ATAPI2 = ; // alternate ATAPI
  CDR_READ6 = ; // using SCSI READ(6)
  CDR_READ10 = ; // using SCSI READ(10)
  CDR_READ_D8 = ; // using command 0xD8 (Plextor?)
  CDR_READ_D4 = ; // using command 0xD4 (NEC?)
  CDR_READ_D4_1 = ; // 0xD4 with a mode select
  CDR_READ10_2 = ; // different mode select w/ READ(10)

  {*
   * defines for the read mode (CDP_READMODE)
   *}
  CDRM_NOJITTER = {viewgit}{/viewgit}; // never jitter correct
  CDRM_JITTER = ; // always jitter correct
  CDRM_JITTERONERR = ; // jitter correct only after a read error

type
  HCDROM = THandle;

  PGETCDHAND = ^GETCDHAND;
  GETCDHAND = packed record
    size: Byte; {* set to sizeof(GETCDHAND)            *}
    ver: Byte; {* set to AKRIPVER                     *}
    ha: Byte; {* host adapter                        *}
    tgt: Byte; {* target id                           *}
    lun: Byte; {* LUN                                 *}
    readType: Byte; {* read function to use                *}
    jitterCorr: Bool; {* use built-in jitter correction?     *}
    numJitter: Byte; {* number of frames to try to match    *}
    numOverlap: Byte; {* number of frames to overlap         *}
  end;

const
  // Used by InsertCDCacheItem
  CDDB_NONE = 0;
  CDDB_QUERY = 1;
  CDDB_ENTRY = 2;

  CDDB_OPT_SERVER = 0;
  CDDB_OPT_PROXY = 1;
  CDDB_OPT_USEPROXY = 2;
  CDDB_OPT_AGENT = 3;
  CDDB_OPT_USER = 4;
  CDDB_OPT_PROXYPORT = 5;
  CDDB_OPT_CGI = 6;
  CDDB_OPT_HTTPPORT = 7;

const
  akriplib = 'akrip32.dll';

function AKGetNumAdapters: Integer; cdecl; External akriplib name 'GetNumAdapters'; cdecl;
function AKGetCDList(var cd: CDLIST): Integer; cdecl; External akriplib name 'GetCDList'; cdecl;
function AKGetAspiLibError: Integer; cdecl; External akriplib name 'GetAspiLibError'; cdecl;
function AKGetAspiLibAspiError: Byte; cdecl; External akriplib name 'GetAspiLibAspiError';  cdecl;

function AKGetCDId(hCD: HCDROM; buf: PChar; maxBuf: Integer): DWord; cdecl; External akriplib name 'GetCDId';cdecl;
function AKGetDriveInfo(ha, tgt, lun: byte; var cdrec: CDREC): DWord; cdecl; External akriplib name 'GetDriveInfo';cdecl;
function AKReadTOC(hCD: HCDROM; var MyToc: TOC): DWord; cdecl; External akriplib name 'ReadTOC';cdecl;
function AKReadCDAudioLBA(hCD: HCDROM; TrackBuf: PTRACKBUF): DWord; cdecl; External akriplib name 'ReadCDAudioLBA';cdecl;
function AKQueryCDParms(hCD: HCDROM; which: Integer; var Num: DWord): Bool; cdecl; External akriplib name 'QueryCDParms';cdecl;
function AKModifyCDParms(hCD: HCDROM; which: Integer; val: DWord): Bool; cdecl; External akriplib name 'ModifyCDParms';cdecl;
function AKGetCDHandle(var cd: GETCDHAND): HCDROM; cdecl; External akriplib name 'GetCDHandle';cdecl;
function AKCloseCDHandle(hCD: HCDROM): Bool; cdecl; External akriplib name 'CloseCDHandle';cdecl;
function AKReadCDAudioLBAEx(hCD: HCDROM; TrackBuf, Overlap: PTRACKBUF): DWord; cdecl; External akriplib name 'ReadCDAudioLBAEx';cdecl;
function AKGetAKRipDllVersion: DWORD; cdecl; External akriplib name 'GetAKRipDllVersion';cdecl;


{*
 * CDDB support
 *}
type
  PCDDBQUERYITEM = ^CDDBQUERYITEM;
  CDDBQUERYITEM =   record
    categ: array[0..12] of Char;
    cddbId: array[0..9] of Char;
    bExact: LongBool;
    //scrap : BYTE;
    artist: array[0..80] of Char;
    //scrap2 : array[0..2] of char;   //weird alignment problem
    title: array[0..81] of Char;
  end;

  PCDDBQUERY =  ^TCDDBQUERY;
  TCDDBQUERY =  packed record
    num: integer;
    q: PCDDBQUERYITEM;
  end;

  CDDBQUERYITEMS =  packed record
   items :   array [0..10] of CDDBQUERYITEM;
  end;

  PCDDBSITE = ^CDDBSITE;
  CDDBSITE = packed record
    szServer: array[0..80] of Char;
    bHTTP: Bool;
    iPort: Integer;
    szCGI: array[0..80] of Char;
    szNorth: array[0..15] of Char;
    szSouth: array[0..15] of Char;
    szLocation: array[0..80] of Char;
  end;

  PCDDBSITELIST = ^CDDBSITELIST;
  CDDBSITELIST = packed record
    num: Integer;
    s: PCDDBSITE;
  end;


function AKGetCDDBDiskID(hCD: HCDROM; var pID: array of DWord; numEntries: Integer): DWord; cdecl; External akriplib name 'GetCDDBDiskID';
function AKCDDBQuery(hCD: HCDROM; var lpq: TCDDBQUERY): DWORD; cdecl; External akriplib name 'CDDBQuery';
function AKCDDBGetDiskInfo(var lpq: CDDBQUERYITEM; szCDDBEntry: PChar; maxLen: Integer): DWORD; cdecl; External akriplib name 'CDDBGetDiskInfo';
procedure AKCDDBSetOption(what: Integer; szVal: PChar; iVal: Integer); cdecl; External akriplib name 'CDDBSetOption';
function AKCDDBGetServerList(var lpSiteList: CDDBSITELIST): DWord; cdecl; External akriplib name 'CDDBGetServerList';

implementation

end.