| Summary: | Add ``next'' and ``previous'' commands to cdcontrol(1). | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | mux <mux> | ||||||
| Component: | bin | Assignee: | freebsd-bugs (Nobody) <bugs> | ||||||
| Status: | Closed FIXED | ||||||||
| Severity: | Affects Only Me | ||||||||
| Priority: | Normal | ||||||||
| Version: | 5.0-CURRENT | ||||||||
| Hardware: | Any | ||||||||
| OS: | Any | ||||||||
| Attachments: |
|
||||||||
|
Description
mux
2001-04-29 21:20:00 UTC
On Sun, Apr 29, 2001 at 10:11:21PM +0200, Maxime Henrion wrote: > *************** > *** 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 whitespace. > *************** > *** 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, "" }, whitespace. > *************** > *** 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)); whitespace. -- Bill Fumerola - security yahoo / Yahoo! inc. - fumerola@yahoo-inc.com / billf@FreeBSD.org Whitespace problems fixed in this patch. Actually I used tabs as I
think it should have been done, but the original source code was using
spaces :/
*** 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);
}
State Changed From-To: open->closed A version of this patch has been committed, thanks! |