The following reply was made to PR bin/55546; it has been noted by GNATS. From: Alexander Best <arun...@freebsd.org> To: bug-follo...@freebsd.org Cc: Subject: Re: bin/55546: cdcontrol(1) play tr m:s.f interface is partially broken Date: Sun, 20 Mar 2011 20:39:06 +0000
--82I3+IH0IqGh5yIs Content-Type: text/plain; charset=us-ascii Content-Disposition: inline this issue is still present in 9.0 (r219727). i've attached the patch again, because the initial patch didn't apply cleanly, due to several changes made to cdcontrol since 2003 (year the initial patch was submitted). it would be nice somebody can take a look at this patch after all these years. cheers. alex -- a13x --82I3+IH0IqGh5yIs Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="cdcontrol.patch" diff --git a/usr.sbin/cdcontrol/cdcontrol.c b/usr.sbin/cdcontrol/cdcontrol.c index 526f599..e001c74 100644 --- a/usr.sbin/cdcontrol/cdcontrol.c +++ b/usr.sbin/cdcontrol/cdcontrol.c @@ -29,6 +29,11 @@ * the uchar storing the volume (256 -> 0, -20 -> 236, ...). * Version 2.0.2 * + * 03-Feb-2011 Tatsuki Makino <tatsuki_mak...@hotmail.com> + * Fixed an ability to specify addresses relative to the + * beginning of a track. + * Version 2.0.3 + * */ #include <sys/cdefs.h> @@ -52,7 +57,7 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> #include <vis.h> -#define VERSION "2.0.2" +#define VERSION "2.0.3" #define ASTS_INVALID 0x00 /* Audio status byte not valid */ #define ASTS_PLAYING 0x11 /* Audio play operation in progress */ @@ -523,6 +528,7 @@ int play (char *arg) unsigned tr1, tr2; unsigned m1, m2, s1, s2, f1, f2; unsigned char tm, ts, tf; + unsigned int lba1, lba2, tlba; tr2 = m2 = s2 = f2 = f1 = 0; if (8 == sscanf (arg, "%d %d:%d.%d %d %d:%d.%d", @@ -589,118 +595,108 @@ int play (char *arg) goto Try_Absolute_Timed_Addresses; Play_Relative_Addresses: - if (! tr1) + if (!tr1) { tr1 = 1; - else if (tr1 > n) + } else if (tr1 > n) { tr1 = n; + } + --tr1; - tr1--; - + /* + * XXX: need check tr1 == toc_buffer[tr1].track ? + */ if (msf) { tm = toc_buffer[tr1].addr.msf.minute; ts = toc_buffer[tr1].addr.msf.second; tf = toc_buffer[tr1].addr.msf.frame; - } else - lba2msf(ntohl(toc_buffer[tr1].addr.lba), - &tm, &ts, &tf); - if ((m1 > tm) - || ((m1 == tm) - && ((s1 > ts) - || ((s1 == ts) - && (f1 > tf))))) { - printf ("Track %d is not that long.\n", tr1); - return (0); + tlba = msf2lba(tm, ts, tf); + } else { + tlba = ntohl(toc_buffer[tr1].addr.lba); } - f1 += tf; - if (f1 >= 75) { - s1 += f1 / 75; - f1 %= 75; - } + lba1 = msf2lba((u_char)m1, (u_char)s1, (u_char)f1) + 150 + tlba; - s1 += ts; - if (s1 >= 60) { - m1 += s1 / 60; - s1 %= 60; + if (lba1 < tlba) { + printf("Track %d is not that long.\n", tr1 + 1); + return 0; } - m1 += tm; - - if (! tr2) { - if (m2 || s2 || f2) { - tr2 = tr1; - f2 += f1; - if (f2 >= 75) { - s2 += f2 / 75; - f2 %= 75; - } - - s2 += s1; - if (s2 > 60) { - m2 += s2 / 60; - s2 %= 60; - } + if (msf) { + tm = toc_buffer[tr1 + 1].addr.msf.minute; + ts = toc_buffer[tr1 + 1].addr.msf.second; + tf = toc_buffer[tr1 + 1].addr.msf.frame; + tlba = msf2lba(tm, ts, tf); + } else { + tlba = ntohl(toc_buffer[tr1 + 1].addr.lba); + } - m2 += m1; + if (lba1 > tlba) { + if ((tr1 + 1) == n) { + printf("The playing time of the disc is not that long.\n"); } else { - tr2 = n; - if (msf) { - m2 = toc_buffer[n].addr.msf.minute; - s2 = toc_buffer[n].addr.msf.second; - f2 = toc_buffer[n].addr.msf.frame; - } else { - lba2msf(ntohl(toc_buffer[n].addr.lba), - &tm, &ts, &tf); - m2 = tm; - s2 = ts; - f2 = tf; - } + printf("Track %d is not that long.\n", tr1 + 1); } + return 0; + } + + if (!tr2) { + tr2 = tr1 + 1; } else if (tr2 > n) { tr2 = n; - m2 = s2 = f2 = 0; + } + --tr2; + + if (msf) { + tm = toc_buffer[tr2].addr.msf.minute; + ts = toc_buffer[tr2].addr.msf.second; + tf = toc_buffer[tr2].addr.msf.frame; + tlba = msf2lba(tm, ts, tf); } else { - if (m2 || s2 || f2) - tr2--; - if (msf) { - tm = toc_buffer[tr2].addr.msf.minute; - ts = toc_buffer[tr2].addr.msf.second; - tf = toc_buffer[tr2].addr.msf.frame; - } else - lba2msf(ntohl(toc_buffer[tr2].addr.lba), - &tm, &ts, &tf); - f2 += tf; - if (f2 >= 75) { - s2 += f2 / 75; - f2 %= 75; - } + tlba = ntohl(toc_buffer[tr2].addr.lba); + } - s2 += ts; - if (s2 > 60) { - m2 += s2 / 60; - s2 %= 60; - } + if (m2 || s2 || f2) { + lba2 = msf2lba((u_char)m2, (u_char)s2, (u_char)f2) + 150 + tlba; + } else if (msf) { + tm = toc_buffer[tr2 + 1].addr.msf.minute; + ts = toc_buffer[tr2 + 1].addr.msf.second; + tf = toc_buffer[tr2 + 1].addr.msf.frame; + lba2 = msf2lba(tm, ts, tf); + } else { + lba2 = ntohl(toc_buffer[tr2 + 1].addr.lba); + } - m2 += tm; + if (lba2 < tlba) { + printf("Track %d is not that long.\n", tr2 + 1); + return 0; } if (msf) { - tm = toc_buffer[n].addr.msf.minute; - ts = toc_buffer[n].addr.msf.second; - tf = toc_buffer[n].addr.msf.frame; - } else - lba2msf(ntohl(toc_buffer[n].addr.lba), - &tm, &ts, &tf); - if ((tr2 < n) - && ((m2 > tm) - || ((m2 == tm) - && ((s2 > ts) - || ((s2 == ts) - && (f2 > tf)))))) { - printf ("The playing time of the disc is not that long.\n"); - return (0); + tm = toc_buffer[tr2 + 1].addr.msf.minute; + ts = toc_buffer[tr2 + 1].addr.msf.second; + tf = toc_buffer[tr2 + 1].addr.msf.frame; + tlba = msf2lba(tm, ts, tf); + } else { + tlba = ntohl(toc_buffer[tr2 + 1].addr.lba); } - return (play_msf (m1, s1, f1, m2, s2, f2)); + + if (lba2 > tlba) { + if ((tr2 + 1) == n) { + printf("The playing time of the disc is not that long.\n"); + } else { + printf("Track %d is not that long.\n", tr2 + 1); + } + return 0; + } + + if (lba1 > lba2) { + /* swap */ + lba1 ^= lba2; + lba2 ^= lba1; + lba1 ^= lba2; + } + + return play_blocks(lba1, lba2 - lba1); Try_Absolute_Timed_Addresses: if (6 != sscanf (arg, "%d:%d.%d%d:%d.%d", --82I3+IH0IqGh5yIs-- _______________________________________________ freebsd-bugs@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-bugs To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"