How do you detect pre/post-gap to compute exact track length in a CD-ROM?

151 Views Asked by At

Using IOCTL_CDROM_READ_TOC_EX, a naive way to compute the exact length of a CD-ROM track would be to assume that audio tracks have a pre-gap of 2 seconds and a data track followed by a different track type has a post-gap of 2 seconds.

But unfortunately, this is not always the case, e.g. multi-session discs.

So I came up with the following to compute the exact length for each track:

  • read backward the start of a track
  • issue a READ CD command to read Q sub-channel
  • as long as INDEX for current TNO is zero, we're effectively in a pre|post-gap zone

This works as expected and we can spot gaps to compute the exact track length in sectors.

However it's a bit surprising this topic isn't explained in SCSI Multimedia Commands specifications!

Question:

Is this the right approach to compute the exact length of each tracks in a CD-ROM ?

0

There are 0 best solutions below