Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/audio Put the lowered mixing volume back when all pl...
details: https://anonhg.NetBSD.org/src/rev/886a087669a6
branches: trunk
changeset: 999937:886a087669a6
user: isaki <isaki%NetBSD.org@localhost>
date: Tue Jun 25 13:07:48 2019 +0000
description:
Put the lowered mixing volume back when all playback tracks are closed.
TODO: about long life descriptor.
diffstat:
sys/dev/audio/audio.c | 55 +++++++++--------------------------------------
sys/dev/audio/audiodef.h | 8 +++++-
2 files changed, 17 insertions(+), 46 deletions(-)
diffs (126 lines):
diff -r 097ac224ede8 -r 886a087669a6 sys/dev/audio/audio.c
--- a/sys/dev/audio/audio.c Tue Jun 25 12:30:50 2019 +0000
+++ b/sys/dev/audio/audio.c Tue Jun 25 13:07:48 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.19 2019/06/23 01:46:56 isaki Exp $ */
+/* $NetBSD: audio.c,v 1.20 2019/06/25 13:07:48 isaki Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.19 2019/06/23 01:46:56 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.20 2019/06/25 13:07:48 isaki Exp $");
#ifdef _KERNEL_OPT
#include "audio.h"
@@ -587,7 +587,6 @@
static int audio_mixers_set_format(struct audio_softc *,
const struct audio_info *);
static void audio_mixers_get_format(struct audio_softc *, struct audio_info *);
-static int audio_sysctl_volume(SYSCTLFN_PROTO);
static int audio_sysctl_blk_ms(SYSCTLFN_PROTO);
static int audio_sysctl_multiuser(SYSCTLFN_PROTO);
#if defined(AUDIO_DEBUG)
@@ -1013,13 +1012,6 @@
if (node != NULL) {
sysctl_createv(&sc->sc_log, 0, NULL, NULL,
CTLFLAG_READWRITE,
- CTLTYPE_INT, "volume",
- SYSCTL_DESCR("software volume test"),
- audio_sysctl_volume, 0, (void *)sc, 0,
- CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL);
-
- sysctl_createv(&sc->sc_log, 0, NULL, NULL,
- CTLFLAG_READWRITE,
CTLTYPE_INT, "blk_ms",
SYSCTL_DESCR("blocksize in msec"),
audio_sysctl_blk_ms, 0, (void *)sc, 0,
@@ -2159,6 +2151,13 @@
KASSERT(sc->sc_popens > 0);
sc->sc_popens--;
+
+ /* Restore mixing volume if all tracks are gone. */
+ if (sc->sc_popens == 0) {
+ mutex_enter(sc->sc_intr_lock);
+ sc->sc_pmixer->volume = 256;
+ mutex_exit(sc->sc_intr_lock);
+ }
}
if (file->rtrack) {
/* Call hw halt_input if this is the last recording track. */
@@ -5016,8 +5015,8 @@
if (mixer->volume > 128) {
mixer->volume =
(mixer->volume * 95) / 100;
- device_printf(sc->sc_dev,
- "auto volume adjust: volume %d\n",
+ TRACE(2,
+ "auto volume adjust: volume %d",
mixer->volume);
}
}
@@ -7266,38 +7265,6 @@
}
/*
- * Get or set software master volume: 0..256
- * XXX It's for debug.
- */
-static int
-audio_sysctl_volume(SYSCTLFN_ARGS)
-{
- struct sysctlnode node;
- struct audio_softc *sc;
- int t, error;
-
- node = *rnode;
- sc = node.sysctl_data;
-
- if (sc->sc_pmixer)
- t = sc->sc_pmixer->volume;
- else
- t = -1;
- node.sysctl_data = &t;
- error = sysctl_lookup(SYSCTLFN_CALL(&node));
- if (error || newp == NULL)
- return error;
-
- if (sc->sc_pmixer == NULL)
- return EINVAL;
- if (t < 0)
- return EINVAL;
-
- sc->sc_pmixer->volume = t;
- return 0;
-}
-
-/*
* Get or set hardware blocksize in msec.
* XXX It's for debug.
*/
diff -r 097ac224ede8 -r 886a087669a6 sys/dev/audio/audiodef.h
--- a/sys/dev/audio/audiodef.h Tue Jun 25 12:30:50 2019 +0000
+++ b/sys/dev/audio/audiodef.h Tue Jun 25 13:07:48 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodef.h,v 1.4 2019/06/10 13:49:39 isaki Exp $ */
+/* $NetBSD: audiodef.h,v 1.5 2019/06/25 13:07:48 isaki Exp $ */
/*
* Copyright (C) 2017 Tetsuya Isaki. All rights reserved.
@@ -187,7 +187,11 @@
int frames_per_block; /* number of frames in a block */
- u_int volume; /* software master volume (0..256) */
+ /*
+ * software master volume (0..256)
+ * Must be protected by sc_intr_lock.
+ */
+ u_int volume;
audio_format2_t mixfmt;
void *mixsample; /* mixing buf in double-sized int */
Home |
Main Index |
Thread Index |
Old Index