libcdio-devel
[Top][All Lists]
Advanced

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

Re: [Libcdio-devel] Proposal for fix of cd-info on MSWindows driver


From: Pete Batard
Subject: Re: [Libcdio-devel] Proposal for fix of cd-info on MSWindows driver
Date: Wed, 20 May 2020 19:57:37 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0

Hi Thomas,

Your patch looks good. :)

--------------------------------------------------------------------
$ ./src/cd-info.exe --dvd --no-device-info
cd-info.exe version 2.1.0 i686-w64-mingw32
Copyright (c) 2003-2005, 2007-2008, 2011-2015, 2017 R. Bernstein
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
CD location   : \\.\I:
CD driver name: WIN32
   access mode: ioctl

__________________________________

Disc mode is listed as: DVD-ROM
CD-ROM Track List (4 - 5)
  #: MSF       LSN    Type   Green? Copy?
  4: 00:02:00  000000 audio  false  yes   2        no
  5: 00:04:00  000150 audio  false  yes   2        no
170: 00:06:02  000302 leadout (693 KB raw, 604 KB formatted)
__________________________________
CD Analysis Report
No CD-TEXT on Disc.
--------------------------------------------------------------------

There were a few typos which I corrected (i_track -> i_tracks). Here is the exact function that I compiled & validated:

--------------------------------------------------------------------
static bool
_cdio_get_track_msf(void *p_user_data, track_t i_tracks, msf_t *p_msf)
{
  _img_private_t *p_env = p_user_data;

  if (!p_msf) return false;

  if (!p_env->gen.toc_init)
    if (!read_toc_win32 (p_env)) return false;

  if (i_tracks == CDIO_CDROM_LEADOUT_TRACK)
    i_tracks = p_env->gen.i_tracks + p_env->gen.i_first_track;

  if (i_tracks > (p_env->gen.i_tracks + p_env->gen.i_first_track)
      || i_tracks < p_env->gen.i_first_track) {
    return false;
  } else {
    cdio_lsn_to_msf(
p_env->tocent[i_tracks - p_env->gen.i_first_track].start_lsn, p_msf);
    return true;
  }
}
--------------------------------------------------------------------

Since it's your patch, I'll let you push it to master.
Many thanks for fixing this one!

Regards,

/Pete

PS: I also pushed an unrelated small commit for testischar.c, some time ago.


On 2020.05.20 18:08, Thomas Schmitt wrote:
Hi,

Pete Batard wrote in "check_cue.sh failing with cdda_4_5 image on MinGW":
$ ./src/cd-info.exe --dvd
...
cd-info.exe: cdio_track_msf for track 4 failed, I give up.

As expected from source study.

One should bring some brain from get_track_msf_linux() into the win32
variant. Like this totally untested and not even compiled proposal:

static bool
_cdio_get_track_msf(void *p_user_data, track_t i_tracks, msf_t *p_msf)
{
   _img_private_t *p_env = p_user_data;

   if (!p_msf) return false;

   if (!p_env->gen.toc_init)
     if (!read_toc_win32 (p_env)) return false;

   if (i_tracks == CDIO_CDROM_LEADOUT_TRACK)
     i_track = p_env->gen.i_tracks + p_env->gen.i_first_track;

   if (i_track > (p_env->gen.i_tracks + p_env->gen.i_first_track)
       || i_track < p_env->gen.i_first_track) {
     return false;
   } else {
     cdio_lsn_to_msf(
           p_env->tocent[i_tracks - p_env->gen.i_first_track].start_lsn, p_msf);
     return true;
   }
}

-------------------------------------------------------------------------

As diff:

--- lib/driver/MSWindows/win32.c.orig   2018-05-27 09:06:52.403774138 +0200
+++ lib/driver/MSWindows/win32.c        2020-05-20 18:55:12.100941556 +0200
@@ -818,12 +818,15 @@ _cdio_get_track_msf(void *p_user_data, t
    if (!p_env->gen.toc_init)
      if (!read_toc_win32 (p_env)) return false;

-  if (i_tracks == CDIO_CDROM_LEADOUT_TRACK) i_tracks = p_env->gen.i_tracks+1;
+  if (i_tracks == CDIO_CDROM_LEADOUT_TRACK)
+    i_track = p_env->gen.i_tracks + p_env->gen.i_first_track;

-  if (i_tracks > p_env->gen.i_tracks+1 || i_tracks == 0) {
+  if (i_track > (p_env->gen.i_tracks + p_env->gen.i_first_track)
+      || i_track < p_env->gen.i_first_track) {
      return false;
    } else {
-    cdio_lsn_to_msf(p_env->tocent[i_tracks-1].start_lsn, p_msf);
+    cdio_lsn_to_msf(
+          p_env->tocent[i_tracks - p_env->gen.i_first_track].start_lsn, p_msf);
      return true;
    }
  }

-------------------------------------------------------------------------

I looked for other suspicious indexed access to .tocent[] and found none.


Have a nice day :)

Thomas






reply via email to

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