summaryrefslogtreecommitdiff
path: root/usr.bin/cdplay
diff options
context:
space:
mode:
authordrochner <drochner@NetBSD.org>2012-01-04 17:26:21 +0000
committerdrochner <drochner@NetBSD.org>2012-01-04 17:26:21 +0000
commit0d092c42fff137107a24edda104f27932d689e31 (patch)
treeb93829396f13475c5641365b8169727b5d270e25 /usr.bin/cdplay
parent9104cac07cb9f44470e74f06fd003cf462ff18e9 (diff)
-make digital mode work in non-interactive mode (init sighandler
earlier, sleep(3) until playing finished) -also switch to digital mode if an audio device is given on the cmd line, or the (new) "CDPLAY_DIGITAL" env var is set (The latter can be used to make digital mode default per system. As I see it, analog mode is not dead yet - two of three external DVD drives I looked at have a speaker output.)
Diffstat (limited to 'usr.bin/cdplay')
-rw-r--r--usr.bin/cdplay/cdplay.110
-rw-r--r--usr.bin/cdplay/cdplay.c29
2 files changed, 28 insertions, 11 deletions
diff --git a/usr.bin/cdplay/cdplay.1 b/usr.bin/cdplay/cdplay.1
index 1661b2ae084..16f4ab48b68 100644
--- a/usr.bin/cdplay/cdplay.1
+++ b/usr.bin/cdplay/cdplay.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: cdplay.1,v 1.23 2011/11/26 23:20:41 christos Exp $
+.\" $NetBSD: cdplay.1,v 1.24 2012/01/04 17:26:21 drochner Exp $
.\"
.\" Copyright (c) 1999, 2000 Andrew Doran.
.\" All rights reserved.
@@ -26,7 +26,7 @@
.\"
.\" from FreeBSD: cdcontrol.1,v 1.16.2.2 1999/01/31 15:36:01 billf Exp
.\"
-.Dd November 26, 2011
+.Dd January 3, 2012
.Dt CDPLAY 1
.Os
.Sh NAME
@@ -57,6 +57,12 @@ and
will be tried (in this order) to find the device; as a last resort,
.Pa /dev/sound
will be used.
+If the
+.Dq Fl a
+command line option is used, or the
+.Ev CDPLAY_DIGITAL
+environment variable is present,
+digital transfer mode is switched on automatically.
.It Fl f Ar device
Specify the control device to use.
Both absolute paths and paths relative to
diff --git a/usr.bin/cdplay/cdplay.c b/usr.bin/cdplay/cdplay.c
index 847125b8a16..96838a0588b 100644
--- a/usr.bin/cdplay/cdplay.c
+++ b/usr.bin/cdplay/cdplay.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cdplay.c,v 1.45 2012/01/04 17:07:20 drochner Exp $ */
+/* $NetBSD: cdplay.c,v 1.46 2012/01/04 17:26:21 drochner Exp $ */
/*
* Copyright (c) 1999, 2000, 2001 Andrew Doran.
@@ -40,7 +40,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: cdplay.c,v 1.45 2012/01/04 17:07:20 drochner Exp $");
+__RCSID("$NetBSD: cdplay.c,v 1.46 2012/01/04 17:26:21 drochner Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -204,6 +204,7 @@ main(int argc, char **argv)
const char *elline;
int scratch, rv;
struct sigaction sa_timer;
+ const char *use_digital = NULL; /* historical default */
cdname = getenv("MUSIC_CD");
if (cdname == NULL)
@@ -219,10 +220,14 @@ main(int argc, char **argv)
if (!da.auname)
da.auname = "/dev/sound";
+ use_digital = getenv("CDPLAY_DIGITAL");
+
while ((c = getopt(argc, argv, "a:f:h")) != -1)
switch (c) {
case 'a':
da.auname = optarg;
+ if (!use_digital)
+ use_digital = "";
continue;
case 'f':
cdname = optarg;
@@ -247,6 +252,15 @@ main(int argc, char **argv)
opencd();
da.afd = -1;
+ sigemptyset(&sa_timer.sa_mask);
+ sa_timer.sa_handler = sig_timer;
+ sa_timer.sa_flags = SA_RESTART;
+ if ((rv = sigaction(SIGALRM, &sa_timer, NULL)) < 0)
+ err(EXIT_FAILURE, "sigaction()");
+
+ if (use_digital)
+ start_digital(use_digital);
+
if (argc > 0) {
interactive = 0;
for (p = buf; argc-- > 0; argv++) {
@@ -277,12 +291,6 @@ main(int argc, char **argv)
el_set(elptr, EL_SIGNAL, 1);
el_source(elptr, NULL);
- sigemptyset(&sa_timer.sa_mask);
- sa_timer.sa_handler = sig_timer;
- sa_timer.sa_flags = SA_RESTART;
- if ((rv = sigaction(SIGALRM, &sa_timer, NULL)) < 0)
- err(EXIT_FAILURE, "sigaction()");
-
for (;;) {
line = NULL;
arg = NULL;
@@ -1131,7 +1139,7 @@ play_track(int tstart, int istart, int tend, int iend)
if ((rv = ioctl(fd, CDIOCPLAYTRACKS, &t)) < 0) {
int oerrno = errno;
- if (errno == EINVAL && start_digital("5") == 0)
+ if (errno == EINVAL && start_digital("") == 0)
return play_track(tstart, istart, tend, iend);
errno = oerrno;
warn("ioctl(CDIOCPLAYTRACKS)");
@@ -1159,6 +1167,9 @@ play_digital(int start, int end)
da.lba_start = start;
da.lba_end = --end;
da.changed = da.playing = 1;
+ if (!interactive)
+ while (da.playing)
+ sleep(1);
return (0);
}