Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/sys/dev/audio Pull up following revision(s) (requested by...
details: https://anonhg.NetBSD.org/src/rev/6bc931ab5eed
branches: netbsd-9
changeset: 466783:6bc931ab5eed
user: martin <martin%NetBSD.org@localhost>
date: Thu Jan 02 09:18:15 2020 +0000
description:
Pull up following revision(s) (requested by isaki in ticket #593):
sys/dev/audio/audio.c: revision 1.34
sys/dev/audio/audio.c: revision 1.35
Use M_WAITOK instead of M_NOWAIT.
These allocations don't require NOWAIT constraints.
Will fix PR kern/54796.
-
Improve and simplify around audio_realloc().
diffstat:
sys/dev/audio/audio.c | 90 +++++++++-----------------------------------------
1 files changed, 16 insertions(+), 74 deletions(-)
diffs (237 lines):
diff -r 02108f40617f -r 6bc931ab5eed sys/dev/audio/audio.c
--- a/sys/dev/audio/audio.c Thu Jan 02 09:09:01 2020 +0000
+++ b/sys/dev/audio/audio.c Thu Jan 02 09:18:15 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.28.2.4 2019/11/19 12:58:29 martin Exp $ */
+/* $NetBSD: audio.c,v 1.28.2.5 2020/01/02 09:18:15 martin Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.4 2019/11/19 12:58:29 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.5 2020/01/02 09:18:15 martin Exp $");
#ifdef _KERNEL_OPT
#include "audio.h"
@@ -3061,30 +3061,6 @@
}
/*
- * Reallocate 'memblock' with specified 'bytes' if 'bytes' > 0.
- * Or free 'memblock' and return NULL if 'byte' is zero.
- */
-static void *
-audio_realloc(void *memblock, size_t bytes)
-{
-
- if (memblock != NULL) {
- if (bytes != 0) {
- return kern_realloc(memblock, bytes, M_NOWAIT);
- } else {
- kern_free(memblock);
- return NULL;
- }
- } else {
- if (bytes != 0) {
- return kern_malloc(bytes, M_NOWAIT);
- } else {
- return NULL;
- }
- }
-}
-
-/*
* Free 'mem' if available, and initialize the pointer.
* For this reason, this is implemented as macro.
*/
@@ -3096,6 +3072,20 @@
} while (0)
/*
+ * (Re)allocate 'memblock' with specified 'bytes'.
+ * bytes must not be 0.
+ * This function never returns NULL.
+ */
+static void *
+audio_realloc(void *memblock, size_t bytes)
+{
+
+ KASSERT(bytes != 0);
+ audio_free(memblock);
+ return kern_malloc(bytes, M_WAITOK);
+}
+
+/*
* (Re)allocate usrbuf with 'newbufsize' bytes.
* Use this function for usrbuf because only usrbuf can be mmapped.
* If successful, it updates track->usrbuf.mem, track->usrbuf.capacity and
@@ -3660,7 +3650,6 @@
static int
audio_track_init_codec(audio_track_t *track, audio_ring_t **last_dstp)
{
- struct audio_softc *sc;
audio_ring_t *last_dst;
audio_ring_t *srcbuf;
audio_format2_t *srcfmt;
@@ -3671,7 +3660,6 @@
KASSERT(track);
- sc = track->mixer->sc;
last_dst = *last_dstp;
dstfmt = &last_dst->fmt;
srcfmt = &track->inputfmt;
@@ -3700,12 +3688,6 @@
srcbuf->capacity = frame_per_block(track->mixer, &srcbuf->fmt);
len = auring_bytelen(srcbuf);
srcbuf->mem = audio_realloc(srcbuf->mem, len);
- if (srcbuf->mem == NULL) {
- device_printf(sc->sc_dev, "%s: malloc(%d) failed\n",
- __func__, len);
- error = ENOMEM;
- goto abort;
- }
arg = &track->codec.arg;
arg->srcfmt = &srcbuf->fmt;
@@ -3731,7 +3713,6 @@
static int
audio_track_init_chvol(audio_track_t *track, audio_ring_t **last_dstp)
{
- struct audio_softc *sc;
audio_ring_t *last_dst;
audio_ring_t *srcbuf;
audio_format2_t *srcfmt;
@@ -3742,7 +3723,6 @@
KASSERT(track);
- sc = track->mixer->sc;
last_dst = *last_dstp;
dstfmt = &last_dst->fmt;
srcfmt = &track->inputfmt;
@@ -3770,12 +3750,6 @@
srcbuf->capacity = frame_per_block(track->mixer, &srcbuf->fmt);
len = auring_bytelen(srcbuf);
srcbuf->mem = audio_realloc(srcbuf->mem, len);
- if (srcbuf->mem == NULL) {
- device_printf(sc->sc_dev, "%s: malloc(%d) failed\n",
- __func__, len);
- error = ENOMEM;
- goto abort;
- }
arg = &track->chvol.arg;
arg->srcfmt = &srcbuf->fmt;
@@ -3786,7 +3760,6 @@
return 0;
}
-abort:
track->chvol.filter = NULL;
audio_free(srcbuf->mem);
return error;
@@ -3801,7 +3774,6 @@
static int
audio_track_init_chmix(audio_track_t *track, audio_ring_t **last_dstp)
{
- struct audio_softc *sc;
audio_ring_t *last_dst;
audio_ring_t *srcbuf;
audio_format2_t *srcfmt;
@@ -3814,7 +3786,6 @@
KASSERT(track);
- sc = track->mixer->sc;
last_dst = *last_dstp;
dstfmt = &last_dst->fmt;
srcfmt = &track->inputfmt;
@@ -3845,12 +3816,6 @@
srcbuf->capacity = frame_per_block(track->mixer, &srcbuf->fmt);
len = auring_bytelen(srcbuf);
srcbuf->mem = audio_realloc(srcbuf->mem, len);
- if (srcbuf->mem == NULL) {
- device_printf(sc->sc_dev, "%s: malloc(%d) failed\n",
- __func__, len);
- error = ENOMEM;
- goto abort;
- }
arg = &track->chmix.arg;
arg->srcfmt = &srcbuf->fmt;
@@ -3861,7 +3826,6 @@
return 0;
}
-abort:
track->chmix.filter = NULL;
audio_free(srcbuf->mem);
return error;
@@ -3876,7 +3840,6 @@
static int
audio_track_init_freq(audio_track_t *track, audio_ring_t **last_dstp)
{
- struct audio_softc *sc;
audio_ring_t *last_dst;
audio_ring_t *srcbuf;
audio_format2_t *srcfmt;
@@ -3891,7 +3854,6 @@
KASSERT(track);
- sc = track->mixer->sc;
last_dst = *last_dstp;
dstfmt = &last_dst->fmt;
srcfmt = &track->inputfmt;
@@ -3930,12 +3892,6 @@
srcbuf->capacity = frame_per_block(track->mixer, &srcbuf->fmt);
len = auring_bytelen(srcbuf);
srcbuf->mem = audio_realloc(srcbuf->mem, len);
- if (srcbuf->mem == NULL) {
- device_printf(sc->sc_dev, "%s: malloc(%d) failed\n",
- __func__, len);
- error = ENOMEM;
- goto abort;
- }
arg = &track->freq.arg;
arg->srcfmt = &srcbuf->fmt;
@@ -3946,7 +3902,6 @@
return 0;
}
-abort:
track->freq.filter = NULL;
audio_free(srcbuf->mem);
return error;
@@ -4128,12 +4083,6 @@
frame_per_block(track->mixer, &track->input->fmt);
len = auring_bytelen(track->input);
track->input->mem = audio_realloc(track->input->mem, len);
- if (track->input->mem == NULL) {
- device_printf(sc->sc_dev, "malloc input(%d) failed\n",
- len);
- error = ENOMEM;
- goto error;
- }
}
/*
@@ -4728,13 +4677,6 @@
len = mixer->frames_per_block * mixer->mixfmt.channels *
mixer->mixfmt.stride / NBBY;
mixer->mixsample = audio_realloc(mixer->mixsample, len);
- if (mixer->mixsample == NULL) {
- device_printf(sc->sc_dev,
- "%s: malloc mixsample(%d) failed\n",
- __func__, len);
- error = ENOMEM;
- goto abort;
- }
} else {
/* No mixing buffer for recording */
}
Home |
Main Index |
Thread Index |
Old Index