[paranoia-dev] Large hack needed to get correct CDDB IDs
Rik Hemsley
rik at kde.org
Thu Jul 26 11:55:52 PDT 2001
Hi,
We currently have this function in our code, in order to work around
a problem with libcdda_interface. The details are explained in the
large comment. Any chance of fixing this for the next release please ?
int start_of_first_data_as_in_toc;
int hack_track;
/* Mega hack. This function comes from libcdda_interface, and is called
* by it. We need to override it, so we implement it ourself in the
* hope, that shared lib semantics make the calls in libcdda_interface
* to FixupTOC end up here, instead of it's own copy. This usually
* works. You don't want to know the reason for this.
*/
int FixupTOC(cdrom_drive *d, int tracks)
{
int j;
for (j = 0; j < tracks; j++)
{
if (d->disc_toc[j].dwStartSector < 0)
d->disc_toc[j].dwStartSector = 0;
if (j < tracks-1
&& d->disc_toc[j].dwStartSector > d->disc_toc[j+1].dwStartSector)
d->disc_toc[j].dwStartSector = 0;
}
long last = d->disc_toc[0].dwStartSector;
for (j = 1; j < tracks; j++)
{
if (d->disc_toc[j].dwStartSector < last)
d->disc_toc[j].dwStartSector = last;
}
start_of_first_data_as_in_toc = -1;
hack_track = -1;
if (d->ioctl_fd != -1)
{
struct cdrom_multisession ms_str;
ms_str.addr_format = CDROM_LBA;
if (ioctl(d->ioctl_fd, CDROMMULTISESSION, &ms_str) == -1)
return -1;
if (ms_str.addr.lba > 100)
{
for (j = tracks-1; j >= 0; j--)
{
if (j > 0 && !IS_AUDIO(d,j) && IS_AUDIO(d,j-1))
{
if (d->disc_toc[j].dwStartSector > ms_str.addr.lba - 11400)
{
/* The next two code lines are the purpose of duplicating
* this function, all others are an exact copy of paranoias
* FixupTOC(). The gory details: CD-Extra consist of N
* audio-tracks in the first session and one data-track in
* the next session. This means, the first sector of the
* data track is not right behind the last sector of the
* last audio track, so all length calculation for that last
* audio track would be wrong. For this the start sector of
* the data track is adjusted (we don't need the real start
* sector, as we don't rip that track anyway), so that the
* last audio track end in the first session. All well and
* good so far. BUT: The CDDB disc-id is based on the real
* TOC entries so this adjustment would result in a wrong
* Disc-ID. We can only solve this conflict, when we save
* the old (toc-based) start sector of the data track. Of
* course the correct solution would be, to only adjust the
* _length_ of the last audio track, not the start of the
* next track, but the internal structures of cdparanoia are
* as they are, so the length is only implicitely given.
* Bloody sh*. */
start_of_first_data_as_in_toc = d->disc_toc[j].dwStartSector;
hack_track = j + 1;
d->disc_toc[j].dwStartSector = ms_str.addr.lba - 11400;
}
break;
}
}
return 1;
}
}
return 0;
}
--- >8 ----
List archives: http://www.xiph.org/archives/
Paranoia homepage: http://www.xiph.org/paranoia/
To unsubscribe from this list, send mail to 'paranoia-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the Paranoia-dev
mailing list