cdrom.pp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. {
  2. Copyright (c) 1999-2000 by Michael Van Canneyt
  3. Unit to read a CDROM disc TOC and get a list of CD Rom devices
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. {$IFNDEF FPC_DOTTEDUNITS}
  11. unit cdrom;
  12. {$ENDIF}
  13. {$mode objfpc}
  14. {$h+}
  15. interface
  16. Type
  17. // Frames are 1/75th of a second.
  18. // To get the seconds of a track divide the frames by 75.
  19. // TrackLen: Double; ...
  20. // TrackLen := Frames / 75.
  21. TTocEntry = Record
  22. min, sec, frame : Integer;
  23. end;
  24. PTocEntry = ^TTocEntry;
  25. // Returns the High value to use in a loop. Each entry is the position of the end
  26. // of a track. For audio cd's the zero'th entry is not audio data. If an audio cd
  27. // has 10 songs then ReadCDToc will return 10 but there are 11 entries: 0..10.
  28. // You still need to use the zero'th entry to get the first track length:
  29. // Track1Length := TOC[1].frames = TOC[0].frames.
  30. Function ReadCDTOC(Device : AnsiString; Var CDTOC : Array of TTocEntry) : Integer;
  31. // Returns the number of devices placed in 'Devices'
  32. Function GetCDRomDevices(Var Devices : Array of AnsiString) : Integer;
  33. Implementation
  34. {$ifdef linux}
  35. {$i cdromlin.inc}
  36. {$else}
  37. {$i cdromw32.inc}
  38. {$endif}
  39. end.