Date: Sun, 29 Apr 2001 22:11:21 +0200 (CEST) From: Maxime Henrion <mux@qualys.com> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/26962: [PATCH] add ``next'' and ``previous'' commands to cdcontrol(1). Message-ID: <200104292011.f3TKBLY04836@nebula.cybercable.fr>
next in thread | raw e-mail | index | archive | help
>Number: 26962
>Category: bin
>Synopsis: Add ``next'' and ``previous'' commands to cdcontrol(1).
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sun Apr 29 13:20:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Maxime Henrion
>Release: FreeBSD 5.0-CURRENT i386
>Organization:
none
>Environment:
System: FreeBSD nebula.cybercable.fr 5.0-CURRENT FreeBSD 5.0-CURRENT #5: Sun Apr 29 02:10:15 CEST 2001 mux@nebula.cybercable.fr:/usr/src/sys/compile/NEBULA i386
>Description:
This patch adds the ``next'' and ``previous'' commands to cdcontrol(1).
After the last track, ``next'' loops back to the first one, and so
on for ``previous''.
>How-To-Repeat:
>Fix:
Reviewed by jkh on IRC.
*** cdcontrol.c.old Sun Apr 29 21:33:09 2001
--- cdcontrol.c Sun Apr 29 21:32:48 2001
***************
*** 69,74 ****
--- 69,76 ----
#define CMD_SET 13
#define CMD_STATUS 14
#define CMD_CDID 15
+ #define CMD_NEXT 16
+ #define CMD_PREVIOUS 17
#define STATUS_AUDIO 0x1
#define STATUS_MEDIA 0x2
#define STATUS_VOLUME 0x4
***************
*** 85,95 ****
--- 87,99 ----
{ CMD_HELP, "?", 1, 0 },
{ CMD_HELP, "help", 1, "" },
{ CMD_INFO, "info", 1, "" },
+ { CMD_NEXT, "next", 1, "" },
{ CMD_PAUSE, "pause", 2, "" },
{ CMD_PLAY, "play", 1, "min1:sec1[.fram1] [min2:sec2[.fram2]]" },
{ CMD_PLAY, "play", 1, "track1[.index1] [track2[.index2]]" },
{ CMD_PLAY, "play", 1, "tr1 m1:s1[.f1] [[tr2] [m2:s2[.f2]]]" },
{ CMD_PLAY, "play", 1, "[#block [len]]" },
+ { CMD_PREVIOUS, "previous", 2, "" },
{ CMD_QUIT, "quit", 1, "" },
{ CMD_RESET, "reset", 4, "" },
{ CMD_RESUME, "resume", 1, "" },
***************
*** 115,120 ****
--- 119,126 ----
int get_vol __P((int *, int *));
int status __P((int *, int *, int *, int *));
int open_cd __P((void));
+ int next __P((void));
+ int previous __P((void));
int play __P((char *arg));
int info __P((char *arg));
int cdid __P((void));
***************
*** 287,298 ****
--- 293,316 ----
return pstatus (arg);
+ case CMD_NEXT:
+ if (fd < 0 && ! open_cd ())
+ return (0);
+
+ return next ();
+
case CMD_PAUSE:
if (fd < 0 && ! open_cd ())
return (0);
return ioctl (fd, CDIOCPAUSE);
+ case CMD_PREVIOUS:
+ if (fd < 0 && ! open_cd ())
+ return (0);
+
+ return previous ();
+
case CMD_RESUME:
if (fd < 0 && ! open_cd ())
return (0);
***************
*** 1180,1183 ****
--- 1198,1245 ----
err(1, "%s", devbuf);
}
return (1);
+ }
+
+ int
+ next()
+ {
+ int trk;
+ struct ioc_toc_header h;
+ int rc, n;
+
+ rc = ioctl(fd, CDIOREADTOCHEADER, &h);
+
+ if (rc < 0)
+ return (rc);
+
+ n = h.ending_track - h.starting_track + 1;
+
+ if (status(&trk, &rc, &rc, &rc) < 0)
+ return (-1);
+
+ if (++trk > h.ending_track)
+ trk = 1;
+ return play_track(trk, 1, n, 1);
+ }
+
+ int
+ previous()
+ {
+ int trk;
+ struct ioc_toc_header h;
+ int rc, n;
+
+ rc = ioctl(fd, CDIOREADTOCHEADER, &h);
+
+ if (rc < 0)
+ return (rc);
+
+ n = h.ending_track - h.starting_track + 1;
+
+ if (status(&trk, &rc, &rc, &rc) < 0)
+ return (-1);
+
+ if (--trk < 1)
+ trk = h.ending_track;
+ return play_track(trk, 1, n, 1);
}
*** cdcontrol.1.old Thu Feb 1 17:43:36 2001
--- cdcontrol.1 Sun Apr 29 21:18:28 2001
***************
*** 82,87 ****
--- 82,91 ----
using
.Ar length
logical blocks.
+ .It Cm next
+ Play the next track.
+ .It Cm previous
+ Play the previous track.
.It Cm pause
Stop playing.
Do not stop the disc.
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200104292011.f3TKBLY04836>
