Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/cdplay -make digital mode work in non-interactive mo...



details:   https://anonhg.NetBSD.org/src/rev/10ef50bbc97c
branches:  trunk
changeset: 772469:10ef50bbc97c
user:      drochner <drochner%NetBSD.org@localhost>
date:      Wed Jan 04 17:26:21 2012 +0000

description:
-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:

 usr.bin/cdplay/cdplay.1 |  10 ++++++++--
 usr.bin/cdplay/cdplay.c |  29 ++++++++++++++++++++---------
 2 files changed, 28 insertions(+), 11 deletions(-)

diffs (120 lines):

diff -r 19513077e03a -r 10ef50bbc97c usr.bin/cdplay/cdplay.1
--- a/usr.bin/cdplay/cdplay.1   Wed Jan 04 17:07:20 2012 +0000
+++ b/usr.bin/cdplay/cdplay.1   Wed Jan 04 17:26:21 2012 +0000
@@ -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 @@
 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 -r 19513077e03a -r 10ef50bbc97c usr.bin/cdplay/cdplay.c
--- a/usr.bin/cdplay/cdplay.c   Wed Jan 04 17:07:20 2012 +0000
+++ b/usr.bin/cdplay/cdplay.c   Wed Jan 04 17:26:21 2012 +0000
@@ -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 @@
        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 @@
        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 @@
        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 @@
        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 @@
 
        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 @@
        da.lba_start = start;
        da.lba_end = --end;
        da.changed = da.playing = 1;
+       if (!interactive)
+               while (da.playing)
+                       sleep(1);
        return (0);
 }
 



Home | Main Index | Thread Index | Old Index