Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/isaki-audio2]: src/sys/dev/audio Accept if bufsize returned from round_b...
details: https://anonhg.NetBSD.org/src/rev/0062570c4e1c
branches: isaki-audio2
changeset: 450744:0062570c4e1c
user: isaki <isaki%NetBSD.org@localhost>
date: Wed Apr 24 12:14:56 2019 +0000
description:
Accept if bufsize returned from round_buffersize() is a multiple of
blksize.
diffstat:
sys/dev/audio/audio.c | 34 +++++++++++++++++++++++++---------
sys/dev/audio/audiodef.h | 3 +--
2 files changed, 26 insertions(+), 11 deletions(-)
diffs (103 lines):
diff -r df48ce7daa7e -r 0062570c4e1c sys/dev/audio/audio.c
--- a/sys/dev/audio/audio.c Wed Apr 24 12:01:50 2019 +0000
+++ b/sys/dev/audio/audio.c Wed Apr 24 12:14:56 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.1.2.1 2019/04/21 04:28:59 isaki Exp $ */
+/* $NetBSD: audio.c,v 1.1.2.2 2019/04/24 12:14:56 isaki Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -154,7 +154,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.1.2.1 2019/04/21 04:28:59 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.1.2.2 2019/04/24 12:14:56 isaki Exp $");
#ifdef _KERNEL_OPT
#include "audio.h"
@@ -4759,6 +4759,7 @@
int blksize;
int capacity;
size_t bufsize;
+ int hwblks;
int blkms;
int error;
@@ -4779,8 +4780,8 @@
mixer->volume = 256;
mixer->blktime_d = 1000;
mixer->blktime_n = audio_mixer_calc_blktime(sc, mixer);
- mixer->hwblks = NBLKHW;
sc->sc_blk_ms = mixer->blktime_n;
+ hwblks = NBLKHW;
mixer->frames_per_block = frame_per_block(mixer, &mixer->hwbuf.fmt);
blksize = frametobyte(&mixer->hwbuf.fmt, mixer->frames_per_block);
@@ -4799,7 +4800,8 @@
return EINVAL;
}
/* Recalculation */
- mixer->frames_per_block = rounded * NBBY /
+ blksize = rounded;
+ mixer->frames_per_block = blksize * NBBY /
(mixer->hwbuf.fmt.stride *
mixer->hwbuf.fmt.channels);
}
@@ -4807,20 +4809,34 @@
mixer->blktime_n = mixer->frames_per_block;
mixer->blktime_d = mixer->hwbuf.fmt.sample_rate;
- capacity = mixer->frames_per_block * mixer->hwblks;
+ capacity = mixer->frames_per_block * hwblks;
bufsize = frametobyte(&mixer->hwbuf.fmt, capacity);
if (sc->hw_if->round_buffersize) {
size_t rounded;
rounded = sc->hw_if->round_buffersize(sc->hw_hdl, mode,
bufsize);
TRACE(2, "round_buffersize %zd -> %zd", bufsize, rounded);
- if (rounded != bufsize) {
- /* XXX what should I do? */
+ if (rounded < bufsize) {
+ /* buffersize needs NBLKHW blocks at least. */
+ device_printf(sc->sc_dev,
+ "buffersize too small: buffersize=%zd blksize=%d\n",
+ rounded, blksize);
+ return EINVAL;
+ }
+ if (rounded % blksize != 0) {
+ /* buffersize/blksize constraint mismatch? */
device_printf(sc->sc_dev,
- "buffer size not configured %zu -> %zu\n",
- bufsize, rounded);
+ "buffersize must be multiple of blksize: "
+ "buffersize=%zu blksize=%d\n",
+ rounded, blksize);
return EINVAL;
}
+ if (rounded != bufsize) {
+ /* Recalcuration */
+ bufsize = rounded;
+ hwblks = bufsize / blksize;
+ capacity = mixer->frames_per_block * hwblks;
+ }
}
TRACE(2, "buffersize for %s = %zu",
(mode == AUMODE_PLAY) ? "playback" : "recording",
diff -r df48ce7daa7e -r 0062570c4e1c sys/dev/audio/audiodef.h
--- a/sys/dev/audio/audiodef.h Wed Apr 24 12:01:50 2019 +0000
+++ b/sys/dev/audio/audiodef.h Wed Apr 24 12:14:56 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodef.h,v 1.1.2.1 2019/04/21 04:28:59 isaki Exp $ */
+/* $NetBSD: audiodef.h,v 1.1.2.2 2019/04/24 12:14:56 isaki Exp $ */
/*
* Copyright (C) 2017 Tetsuya Isaki. All rights reserved.
@@ -220,7 +220,6 @@
audio_ring_t codecbuf; /* also used for wide->int conversion */
audio_ring_t hwbuf; /* HW I/O buf */
- int hwblks; /* number of blocks in hwbuf */
void *sih; /* softint cookie */
Home |
Main Index |
Thread Index |
Old Index