-/* $OpenBSD: audio.c,v 1.207 2024/06/07 08:48:10 jsg Exp $ */
+/* $OpenBSD: audio.c,v 1.208 2024/08/20 07:44:36 mvs Exp $ */
/*
* Copyright (c) 2015 Alexandre Ratchov <alex@caoua.org>
*
#include <sys/malloc.h>
#include <sys/device.h>
#include <sys/audioio.h>
+#include <sys/atomic.h>
#include <dev/audio_if.h>
#include <dev/mulaw.h>
#include "audio.h"
#include "wskbd.h"
+/*
+ * Locks used to protect data:
+ * a atomic
+ */
+
#ifdef AUDIO_DEBUG
#define DPRINTF(...) \
do { \
* Global flag to control if audio recording is enabled when the
* mixerctl setting is record.enable=sysctl
*/
-int audio_record_enable = 0;
+int audio_record_enable = 0; /* [a] */
#ifdef AUDIO_DEBUG
/*
sc->rec.pos += sc->rec.blksz;
if ((sc->record_enable == MIXER_RECORD_ENABLE_SYSCTL &&
- !audio_record_enable) ||
+ atomic_load_int(&audio_record_enable) == 0) ||
sc->record_enable == MIXER_RECORD_ENABLE_OFF) {
ptr = audio_buf_wgetblk(&sc->rec, &count);
audio_fill_sil(sc, ptr, sc->rec.blksz);
-/* $OpenBSD: kern_sysctl.c,v 1.439 2024/08/14 17:52:47 mvs Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.440 2024/08/20 07:44:36 mvs Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
return witness_sysctl(name, namelen, oldp, oldlenp,
newp, newlen);
#endif
-#if NAUDIO > 0
- case KERN_AUDIO:
- return (sysctl_audio(name, namelen, oldp, oldlenp,
- newp, newlen));
-#endif
#if NVIDEO > 0
case KERN_VIDEO:
return (sysctl_video(name, namelen, oldp, oldlenp,
/* dispatch the non-terminal nodes first */
if (namelen != 1) {
+ switch (name[0]) {
+#if NAUDIO > 0
+ case KERN_AUDIO:
+ return (sysctl_audio(name, namelen, oldp, oldlenp,
+ newp, newlen));
+#endif
+ default:
+ break;
+ }
+
savelen = *oldlenp;
if ((error = sysctl_vslock(oldp, savelen)))
return (error);