Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Rework of play/rec threads to ensure effective use o...
details: https://anonhg.NetBSD.org/src/rev/195a333ac62b
branches: trunk
changeset: 358582:195a333ac62b
user: nat <nat%NetBSD.org@localhost>
date: Tue Jan 09 04:10:27 2018 +0000
description:
Rework of play/rec threads to ensure effective use of locks.
Addresses part of PR kern/52889 where the mixing thread would not exit on
audio detach.
diffstat:
sys/dev/audio.c | 46 ++++++++++++++++++++++++++--------------------
1 files changed, 26 insertions(+), 20 deletions(-)
diffs (83 lines):
diff -r bd01d89b445b -r 195a333ac62b sys/dev/audio.c
--- a/sys/dev/audio.c Tue Jan 09 03:31:12 2018 +0000
+++ b/sys/dev/audio.c Tue Jan 09 04:10:27 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.447 2018/01/06 23:15:36 nat Exp $ */
+/* $NetBSD: audio.c,v 1.448 2018/01/09 04:10:27 nat Exp $ */
/*-
* Copyright (c) 2016 Nathanial Sloss <nathanialsloss%yahoo.com.au@localhost>
@@ -148,7 +148,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.447 2018/01/06 23:15:36 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.448 2018/01/09 04:10:27 nat Exp $");
#ifdef _KERNEL_OPT
#include "audio.h"
@@ -5858,22 +5858,24 @@
sc = (struct audio_softc *)v;
for (;;) {
- mutex_enter(sc->sc_intr_lock);
- cv_wait_sig(&sc->sc_condvar, sc->sc_intr_lock);
+ mutex_enter(sc->sc_lock);
if (sc->sc_dying) {
- mutex_exit(sc->sc_intr_lock);
+ mutex_exit(sc->sc_lock);
kthread_exit(0);
}
-
- while (sc->sc_usemixer &&
+ if (!sc->sc_trigger_started)
+ goto play_wait;
+
+ while (!sc->sc_dying && sc->sc_usemixer &&
audio_stream_get_used(&sc->sc_mixring.sc_mpr.s) <
- sc->sc_mixring.sc_mpr.blksize) {
- mutex_exit(sc->sc_intr_lock);
- mutex_enter(sc->sc_lock);
+ sc->sc_mixring.sc_mpr.blksize)
audio_mix(sc);
- mutex_exit(sc->sc_lock);
- mutex_enter(sc->sc_intr_lock);
- }
+
+play_wait:
+ mutex_exit(sc->sc_lock);
+
+ mutex_enter(sc->sc_intr_lock);
+ cv_wait_sig(&sc->sc_condvar, sc->sc_intr_lock);
mutex_exit(sc->sc_intr_lock);
}
}
@@ -5886,17 +5888,21 @@
sc = (struct audio_softc *)v;
for (;;) {
- mutex_enter(sc->sc_intr_lock);
- cv_wait_sig(&sc->sc_rcondvar, sc->sc_intr_lock);
+ mutex_enter(sc->sc_lock);
if (sc->sc_dying) {
- mutex_exit(sc->sc_intr_lock);
+ mutex_exit(sc->sc_lock);
kthread_exit(0);
}
+ if (!sc->sc_rec_started)
+ goto rec_wait;
+
+ audio_upmix(sc);
+rec_wait:
+ mutex_exit(sc->sc_lock);
+
+ mutex_enter(sc->sc_intr_lock);
+ cv_wait_sig(&sc->sc_rcondvar, sc->sc_intr_lock);
mutex_exit(sc->sc_intr_lock);
-
- mutex_enter(sc->sc_lock);
- audio_upmix(sc);
- mutex_exit(sc->sc_lock);
}
}
Home |
Main Index |
Thread Index |
Old Index