libcdio-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Libcdio-devel] CD_MSF_FORMAT vs LBA on NetBSD


From: Edd Barrett
Subject: Re: [Libcdio-devel] CD_MSF_FORMAT vs LBA on NetBSD
Date: Sun, 9 Dec 2018 17:42:23 +0000
User-agent: Mutt/1.11.1 (2018-12-01)

On Sun, Dec 09, 2018 at 05:57:20PM +0100, Thomas Schmitt wrote:
> So was the shown cd-info result from the intermediate state before
>   
> https://github.com/vext01/libcdio/commit/539c52488506c5bacdfebbcafc5406034a0738fd

Correct.

> But why then didn't this yield an error message ?
>
> So get_track_msf_netbsd() must not return CDIO_INVALID_TRACK but rather
> false in case of error.

Agreed! And applied:
https://github.com/vext01/libcdio/commit/cc9f216badadf097f5c33976fb082808a9ea01a4

> Pity, i had it in mind as reason for the cdparanoia complaint

I've just finished a bug-finding session on cd-paranoia. It looks to me
like it's exactly the same problem as we've been facing with libcdio. It
assumes tracks start at 1.

I've very quickly hacked it to the point where I can at least extract
CDs with non-one start tracks. I'm not suggesting these are the correct
fixes, but hopefully it will be enough to get us going. I'm aware that
we are working on forked code, and we probably want to minimize
code-difference where possible.

FWIW: upstream cdparanoia works fine on CDs with start track >1 on
OpenBSD.

You should be able to repro these bugs on other platforms I think. I
don't think this is OpenBSD specific.

Thoughts?

diff --git a/lib/cdda_interface/cddap_interface.c 
b/lib/cdda_interface/cddap_interface.c
index 9e92545..53e23a6 100644
--- a/lib/cdda_interface/cddap_interface.c
+++ b/lib/cdda_interface/cddap_interface.c
@@ -55,7 +55,7 @@ cddap_readtoc (cdrom_drive_t *d)
                                                    CDIO_CDROM_LEADOUT_TRACK);
 
   d->cd_extra=FixupTOC(d, d->tracks+1); /* fixup includes lead-out */
-  return --i_track;  /* number of tracks returned does not include lead-out */
+  return d->tracks;  /* number of tracks returned does not include lead-out */
 }
 
 
@@ -263,6 +263,7 @@ verify_read_command(cdrom_drive_t *d)
   int16_t *buff=malloc(CDIO_CD_FRAMESIZE_RAW);
   int audioflag=0;
   int i_test_flags = d->i_test_flags;
+  int first_track = cdio_get_first_track_num(d->p_cdio);
 
   d->i_test_flags = 0;
 
@@ -270,7 +271,7 @@ verify_read_command(cdrom_drive_t *d)
 
   d->enable_cdda(d,1);
 
-  for(i=1;i<=d->tracks;i++){
+  for(i=first_track; i<first_track+d->tracks; i++){
     if(cdda_track_audiop(d,i)==1){
       long firstsector=cdda_track_firstsector(d,i);
       long lastsector=cdda_track_lastsector(d,i);
diff --git a/lib/cdda_interface/toc.c b/lib/cdda_interface/toc.c
index 930cf9a..693960f 100644
--- a/lib/cdda_interface/toc.c
+++ b/lib/cdda_interface/toc.c
@@ -65,15 +65,17 @@ lsn_t
 cdda_disc_firstsector(cdrom_drive_t *d)
 {
   int i;
+  int first_track = cdio_get_first_track_num(d->p_cdio);
+
   if(!d->opened){
     cderror(d,"400: Device not open\n");
     return(-400);
   }
 
   /* look for an audio track */
-  for ( i=0; i<d->tracks; i++ )
+  for ( i=first_track;i<first_track + d->tracks;i++ )
     if( cdda_track_audiop(d, i+1)==1 ) {
-      if (i == 0) /* disc starts at lba 0 if first track is an audio track */
+      if (i == first_track) /* disc starts at lba 0 if first track is an audio 
track */
        return 0;
       else
        return cdda_track_firstsector(d, i+1);
diff --git a/lib/paranoia/p_block.c b/lib/paranoia/p_block.c
index 1f68d30..4370ec2 100644
--- a/lib/paranoia/p_block.c
+++ b/lib/paranoia/p_block.c
@@ -382,6 +382,8 @@ i_paranoia_firstlast(cdrom_paranoia_t *p)
   p->current_lastsector = p->current_firstsector = -1;
 
   i = cdda_sector_gettrack(d, p->cursor);
+  if( i==0 )
+    i = cdio_get_first_track_num(d->p_cdio);
 
   if ( CDIO_INVALID_TRACK != i ) {
     if ( 0 == i ) i++;
diff --git a/src/cd-paranoia.c b/src/cd-paranoia.c
index 9443b62..1099079 100644
--- a/src/cd-paranoia.c
+++ b/src/cd-paranoia.c
@@ -1189,6 +1189,9 @@ main(int argc,char *argv[])
 
     {
       int track1 = cdda_sector_gettrack(d, i_first_lsn);
+      if( track1==0 )
+        track1 = cdio_get_first_track_num(d->p_cdio);
+
       int track2 = cdda_sector_gettrack(d, i_last_lsn);
       long off1  = i_first_lsn - cdda_track_firstsector(d, track1);
       long off2  = i_last_lsn  - cdda_track_firstsector(d, track2);


-- 
Best Regards
Edd Barrett

http://www.theunixzoo.co.uk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]