Module Name:    src
Committed By:   isaki
Date:           Sun Mar  1 07:35:33 UTC 2020

Modified Files:
        src/sys/dev/audio: audio.c

Log Message:
Reinitialize the sticky parameters whenever the hardware format is changed.
When the number of the hardware channels becomes less than the number of
channels that sticky parameters remember, subsequent open("/dev/sound") will
fail without this treatment.  This is for rev 1.43.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/dev/audio/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/audio.c
diff -u src/sys/dev/audio/audio.c:1.58 src/sys/dev/audio/audio.c:1.59
--- src/sys/dev/audio/audio.c:1.58	Sat Feb 29 09:38:10 2020
+++ src/sys/dev/audio/audio.c	Sun Mar  1 07:35:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.58 2020/02/29 09:38:10 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.59 2020/03/01 07:35:33 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.58 2020/02/29 09:38:10 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.59 2020/03/01 07:35:33 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -6507,6 +6507,18 @@ audio_mixers_set_format(struct audio_sof
 	if (error)
 		return error;
 
+	/*
+	 * Reinitialize the sticky parameters for /dev/sound.
+	 * If the number of the hardware channels becomes less than the number
+	 * of channels that sticky parameters remember, subsequent /dev/sound
+	 * open will fail.  To prevent this, reinitialize the sticky
+	 * parameters whenever the hardware format is changed.
+	 */
+	sc->sc_sound_pparams = params_to_format2(&audio_default);
+	sc->sc_sound_rparams = params_to_format2(&audio_default);
+	sc->sc_sound_ppause = false;
+	sc->sc_sound_rpause = false;
+
 	return 0;
 }
 

Reply via email to