NetBSD-Bugs archive

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

Re: bin/38493: no good audio with cdplay



The following reply was made to PR bin/38493; it has been noted by GNATS.

From: Matthias Drochner <M.Drochner%fz-juelich.de@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: gnats-admin%NetBSD.org@localhost, netbsd-bugs%NetBSD.org@localhost,
        reed%reedmedia.net@localhost
Subject: Re: bin/38493: no good audio with cdplay 
Date: Mon, 14 Jul 2008 14:22:28 +0200

 This is a multipart MIME message.
 
 --==_Exmh_6896404818000
 Content-Type: text/plain; charset=us-ascii
 
 
 svs%ropnet.ru@localhost said:
 >  -   ai.mode = AUMODE_PLAY;
 >  +   ai.mode = AUMODE_PLAY_ALL; 
 
 Thanks - this improves the "resume" for me too.
 Here is an aggregate patch which also fixes some other
 problems:
 -The timeout for the raw SCSI command to read audio data
  is much too small. This caused complete failure for me.
 -"digital 1" does not work, at least with HZ=100.
  (The signal handler can't keep up.)
 -"digital 20" or so leads to poor interactive behaviour
  (because the program blocks most of the time in the
   signal handler)
 With that patch, digital mode is usable for me.
 (This code is a mess and should be rewritten, but
 not before 5.0 imo.)
 
 best regards
 Matthias
 
 
 
 
 
 -------------------------------------------------------------------
 -------------------------------------------------------------------
 Forschungszentrum Juelich GmbH
 52425 Juelich
 
 Sitz der Gesellschaft: Juelich
 Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
 Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
 Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
 Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr. Harald Bolt,
 Dr. Sebastian M. Schmidt
 -------------------------------------------------------------------
 -------------------------------------------------------------------
 
 --==_Exmh_6896404818000
 Content-Type: text/plain ; name="cdplay.txt"; charset=us-ascii
 Content-Description: cdplay.txt
 Content-Disposition: attachment; filename="cdplay.txt"
 
 #
 # old_revision [b0293fd440ffeb0cc85778a3a79fcbb762e17b78]
 #
 # patch "usr.bin/cdplay/cdplay.c"
 #  from [97aad6bcf900d21ed7d4dea09dfce00aa70d314e]
 #    to [d976096f1ed56cbf03af1c70350d0d3484e50413]
 #
 ============================================================
 --- usr.bin/cdplay/cdplay.c    97aad6bcf900d21ed7d4dea09dfce00aa70d314e
 +++ usr.bin/cdplay/cdplay.c    d976096f1ed56cbf03af1c70350d0d3484e50413
 @@ -483,7 +483,7 @@ run(int cmd, const char *arg)
  
        case CMD_DIGITAL:
                if (digital == 0) {
 -                      int fpw;
 +                      int fpw, intv_usecs, hz_usecs;
  
                        fpw = atoi(arg);
                        if (fpw > 0)
 @@ -491,6 +491,23 @@ run(int cmd, const char *arg)
                        else
                                da.fpw = 5;
                        da.read_errors = 0;
 +
 +                      /* real rate: 75 frames per second */
 +                      intv_usecs = 13333 * da.fpw;
 +                      /*
 +                       * interrupt earlier for safety, by a value which
 +                       * doesn't hurt interactice response if we block
 +                       * in the signal handler
 +                       */
 +                      intv_usecs -= 50000;
 +                      hz_usecs = 1000000 / sysconf(_SC_CLK_TCK);
 +                      if (intv_usecs < hz_usecs) {
 +                              /* can't have a shorter interval, increase
 +                                 buffer size to compensate */
 +                              da.fpw += (hz_usecs - intv_usecs) / 13333;
 +                              intv_usecs = hz_usecs;
 +                      }
 +
                        da.aubuf = malloc(da.fpw * CDDA_SIZE);
                        if (da.aubuf == NULL) {
                                warn("Not enough memory for audio buffers");
 @@ -500,9 +517,10 @@ run(int cmd, const char *arg)
                                warn("Cannot open audio device");
                                return (1);
                        }
 -                      itv_timer.it_interval.tv_sec = 
itv_timer.it_value.tv_sec = da.fpw / 75;
 +                      itv_timer.it_interval.tv_sec = 
itv_timer.it_value.tv_sec =
 +                              intv_usecs / 1000000;
                        itv_timer.it_interval.tv_usec = 
itv_timer.it_value.tv_usec =
 -                          (da.fpw * 6666) % 1000000;
 +                              intv_usecs % 1000000;
                        rv = setitimer(ITIMER_REAL, &itv_timer, NULL);
                        if (rv == 0) {
                                digital = 1;
 @@ -932,7 +950,8 @@ print_status(const char *arg)
        else
                printf("shuffle play:\t%s\n", (shuffle != 0) ? "on" : "off");
        if (digital)
 -              printf("digital xfer:\tto %s (%d frames per wakeup, %ld.%03lds 
period)\n",
 +              printf("digital xfer:\tto %s "
 +                     "(%d frames per wakeup, %ld.%06lds period)\n",
                    da.auname, da.fpw, itv_timer.it_interval.tv_sec,
                    itv_timer.it_interval.tv_usec);
        else
 @@ -1346,7 +1365,7 @@ openaudio()
                da.afd = -1;
                return (0);
        }
 -      ai.mode = AUMODE_PLAY;
 +      ai.mode = AUMODE_PLAY_ALL;
        ai.play.sample_rate = 44100;
        ai.play.channels = 2;
        ai.play.precision = 16;
 @@ -1387,7 +1406,7 @@ readaudio(afd, lba, blocks, data)
        sc.datalen = CDDA_SIZE * blocks;
        sc.senselen = sizeof(sc.sense);
        sc.flags = SCCMD_READ;
 -      sc.timeout = da.fpw * 15;
 +      sc.timeout = 10000; /* 10s */
        rc = ioctl(afd, SCIOCCOMMAND, &sc);
        if (rc < 0 || sc.retsts != SCCMD_OK) {
                if (da.read_errors < 10) {
 
 --==_Exmh_6896404818000--
 


Home | Main Index | Thread Index | Old Index