Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/cdplay Add repeat mode to cdplay(1) per PR bin/13970
details: https://anonhg.NetBSD.org/src/rev/21e0f7ce3054
branches: trunk
changeset: 586796:21e0f7ce3054
user: garbled <garbled%NetBSD.org@localhost>
date: Mon Jan 02 21:29:53 2006 +0000
description:
Add repeat mode to cdplay(1) per PR bin/13970
Applied the second patch in the PR, with minor tweaking, and adjusted
manpage for change.
diffstat:
usr.bin/cdplay/cdplay.1 | 9 ++++++++-
usr.bin/cdplay/cdplay.c | 33 ++++++++++++++++++++++++++-------
2 files changed, 34 insertions(+), 8 deletions(-)
diffs (119 lines):
diff -r 805d80b406d6 -r 21e0f7ce3054 usr.bin/cdplay/cdplay.1
--- a/usr.bin/cdplay/cdplay.1 Mon Jan 02 20:55:42 2006 +0000
+++ b/usr.bin/cdplay/cdplay.1 Mon Jan 02 21:29:53 2006 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: cdplay.1,v 1.16 2004/03/18 21:14:54 wiz Exp $
+.\" $NetBSD: cdplay.1,v 1.17 2006/01/02 21:29:53 garbled Exp $
.\"
.\" Copyright (c) 1999, 2000 Andrew Doran.
.\" All rights reserved.
@@ -120,6 +120,13 @@
.It Cm shuffle
Select shuffle play.
Only valid in interactive mode.
+.It Cm single Op Ar track
+Pick a single track and play it repeatedly. If a
+.Ar track
+argument is not given the
+.Cm single
+command will shut shuffle mode off and play the disc normally.
+Only valid in interactive mode.
.It Cm skip
Skip to another track.
Only valid when shuffle play is selected.
diff -r 805d80b406d6 -r 21e0f7ce3054 usr.bin/cdplay/cdplay.c
--- a/usr.bin/cdplay/cdplay.c Mon Jan 02 20:55:42 2006 +0000
+++ b/usr.bin/cdplay/cdplay.c Mon Jan 02 21:29:53 2006 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cdplay.c,v 1.30 2005/06/02 01:40:10 lukem Exp $ */
+/* $NetBSD: cdplay.c,v 1.31 2006/01/02 21:29:53 garbled Exp $ */
/*
* Copyright (c) 1999, 2000, 2001 Andrew Doran.
@@ -40,7 +40,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: cdplay.c,v 1.30 2005/06/02 01:40:10 lukem Exp $");
+__RCSID("$NetBSD: cdplay.c,v 1.31 2006/01/02 21:29:53 garbled Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -78,6 +78,7 @@
CMD_RESUME,
CMD_SET,
CMD_SHUFFLE,
+ CMD_SINGLE,
CMD_SKIP,
CMD_STATUS,
CMD_STOP,
@@ -107,6 +108,7 @@
{ CMD_RESUME, "resume", 4, NULL },
{ CMD_SET, "set", 2, "msf | lba" },
{ CMD_SHUFFLE, "shuffle", 2, NULL },
+ { CMD_SINGLE, "single", 2, "[<track>]" },
{ CMD_SKIP, "skip", 2, NULL },
{ CMD_STATUS, "status", 3, NULL },
{ CMD_STOP, "stop", 3, NULL },
@@ -378,6 +380,11 @@
rv = skip(1, 1);
break;
+ case CMD_SINGLE:
+ if (interactive == 0)
+ errx(EXIT_FAILURE,
+ "'single' valid only in interactive mode");
+ /*FALLTHROUGH*/
case CMD_SHUFFLE:
if (interactive == 0)
errx(EXIT_FAILURE,
@@ -388,7 +395,13 @@
itv_timer.it_value.tv_sec = 1;
itv_timer.it_value.tv_usec = 0;
if (setitimer(ITIMER_REAL, &itv_timer, NULL) == 0) {
- shuffle = 1;
+ if (cmd == CMD_SHUFFLE) {
+ shuffle = 1;
+ } else {
+ while (isspace((unsigned char)*arg))
+ arg++;
+ shuffle = -atoi(arg);
+ }
skip(0, 1);
}
} else {
@@ -399,7 +412,10 @@
if (setitimer(ITIMER_REAL, &itv_timer, NULL) == 0)
shuffle = 0;
}
- printf("shuffle play:\t%s\n", shuffle ? "on" : "off");
+ if (shuffle < 0)
+ printf("single track:\t%d\n", -shuffle);
+ else
+ printf("shuffle play:\t%s\n", (shuffle != 0) ? "on" : "off");
rv = 0;
break;
@@ -711,8 +727,8 @@
if (dir == 0) {
if (fromuser || (rv != CD_AS_PLAY_IN_PROGRESS &&
rv != CD_AS_PLAY_PAUSED))
- trk = h.starting_track +
- arc4random() % (h.ending_track - h.starting_track + 1);
+ trk = shuffle < 0 ? (-shuffle) : (h.starting_track +
+ arc4random() % (h.ending_track - h.starting_track + 1));
else
return (0);
} else {
@@ -779,7 +795,10 @@
} else
printf("audio status:\tno info available\n");
- printf("shuffle play:\t%s\n", shuffle ? "on" : "off");
+ if (shuffle < 0)
+ printf("single track:\t%d\n", -shuffle);
+ else
+ printf("shuffle play:\t%s\n", (shuffle != 0) ? "on" : "off");
bzero(&ss, sizeof(ss));
ss.data = &data;
Home |
Main Index |
Thread Index |
Old Index