Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/audio audio(4): Restore(implement) AUDIO_GETIOFFS io...



details:   https://anonhg.NetBSD.org/src/rev/9be759540864
branches:  trunk
changeset: 365749:9be759540864
user:      isaki <isaki%NetBSD.org@localhost>
date:      Sat Apr 23 07:43:16 2022 +0000

description:
audio(4): Restore(implement) AUDIO_GETIOFFS ioctl.

diffstat:

 sys/dev/audio/audio.c |  37 +++++++++++++++++++++++++++----------
 1 files changed, 27 insertions(+), 10 deletions(-)

diffs (73 lines):

diff -r 6570eb03e911 -r 9be759540864 sys/dev/audio/audio.c
--- a/sys/dev/audio/audio.c     Sat Apr 23 06:43:22 2022 +0000
+++ b/sys/dev/audio/audio.c     Sat Apr 23 07:43:16 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audio.c,v 1.129 2022/04/23 06:17:59 isaki Exp $        */
+/*     $NetBSD: audio.c,v 1.130 2022/04/23 07:43:16 isaki Exp $        */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -181,7 +181,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.129 2022/04/23 06:17:59 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.130 2022/04/23 07:43:16 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -3086,12 +3086,31 @@
                break;
 
        case AUDIO_GETIOFFS:
-               /* XXX TODO */
-               TRACEF(2, file, "%s", pre);
                ao = (struct audio_offset *)addr;
-               ao->samples = 0;
-               ao->deltablks = 0;
-               ao->offset = 0;
+               track = file->rtrack;
+               if (track == NULL) {
+                       ao->samples = 0;
+                       ao->deltablks = 0;
+                       ao->offset = 0;
+                       TRACEF(2, file, "%s no rtrack", pre);
+                       break;
+               }
+               mutex_enter(sc->sc_lock);
+               mutex_enter(sc->sc_intr_lock);
+               /* figure out where next transfer will start */
+               stamp = track->stamp;
+               offset = auring_tail(track->input);
+               mutex_exit(sc->sc_intr_lock);
+               mutex_exit(sc->sc_lock);
+
+               /* samples will overflow soon but is as per spec. */
+               ao->samples = stamp * track->usrbuf_blksize;
+               ao->deltablks = stamp - track->last_stamp;
+               ao->offset = audio_track_inputblk_as_usrbyte(track, offset);
+               TRACET(2, track, "%s samples=%u deltablks=%u offset=%u",
+                   pre, ao->samples, ao->deltablks, ao->offset);
+
+               track->last_stamp = stamp;
                break;
 
        case AUDIO_GETOOFFS:
@@ -5152,8 +5171,6 @@
                auring_take(outbuf, bytes2 / framesize);
        }
 
-       /* XXX TODO: any counters here? */
-
 #if defined(AUDIO_DEBUG)
        if (audiodebug >= 3) {
                struct audio_track_debugbuf m;
@@ -6098,7 +6115,7 @@
                    bytes);
                auring_push(input, count);
 
-               /* XXX sequence counter? */
+               track->stamp++;
 
                audio_track_lock_exit(track);
        }



Home | Main Index | Thread Index | Old Index