Module Name: src
Committed By: nat
Date: Wed Nov 15 01:55:46 UTC 2017
Modified Files:
src/sys/dev: audio.c
Log Message:
Improved draining function for when the mixer is and is not enabled.
One block of silence is also played in audio drivers using start_output
when draining the hardware, this helps playback of short (less than
blocksize) samples.
To generate a diff of this commit:
cvs rdiff -u -r1.433 -r1.434 src/sys/dev/audio.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/audio.c
diff -u src/sys/dev/audio.c:1.433 src/sys/dev/audio.c:1.434
--- src/sys/dev/audio.c:1.433 Wed Nov 15 01:49:59 2017
+++ src/sys/dev/audio.c Wed Nov 15 01:55:45 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.433 2017/11/15 01:49:59 nat Exp $ */
+/* $NetBSD: audio.c,v 1.434 2017/11/15 01:55:45 nat Exp $ */
/*-
* Copyright (c) 2016 Nathanial Sloss <[email protected]>
@@ -148,7 +148,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.433 2017/11/15 01:49:59 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.434 2017/11/15 01:55:45 nat Exp $");
#ifdef _KERNEL_OPT
#include "audio.h"
@@ -2402,13 +2402,13 @@ audio_drain(struct audio_softc *sc, stru
return 0;
used = audio_stream_get_used(&cb->s);
- if (vc == sc->sc_hwvc) {
+ if (vc == sc->sc_hwvc && sc->sc_usemixer) {
hw = true;
used += audio_stream_get_used(&sc->sc_mixring.sc_mpr.s);
}
for (i = 0; i < vc->sc_npfilters; i++)
used += audio_stream_get_used(&vc->sc_pstreams[i]);
- if (used <= 0 || (hw == true && sc->hw_if->trigger_output == NULL))
+ if (used <= 0)
return 0;
if (hw == false && !vc->sc_pbus) {
@@ -2457,9 +2457,14 @@ audio_drain(struct audio_softc *sc, stru
#endif
vc->sc_draining = true;
- drops = cb->drops + (cb->blksize * PREFILL_BLOCKS);
+ drops = cb->drops;
+ if (vc == sc->sc_hwvc)
+ drops += cb->blksize;
+ else if (sc->sc_usemixer)
+ drops += sc->sc_mixring.sc_mpr.blksize * PREFILL_BLOCKS;
+
error = 0;
- while (cb->drops < drops && !error) {
+ while (cb->drops <= drops && !error) {
DPRINTF(("audio_drain: vc=%p used=%d, drops=%ld\n",
vc,
audio_stream_get_used(&vc->sc_mpr.s),