Subject: audio filter pipeline: is the device softc really needed?
To: None <tech-kern@netbsd.org>
From: Matthias Drochner <M.Drochner@fz-juelich.de>
List: tech-kern
Date: 06/28/2006 18:10:53
This is a multipart MIME message.

--==_Exmh_8523917051510
Content-Type: text/plain; charset=us-ascii


Hi -
some weeks ago when we had a locking problem in the audio
filter code I found that the device softc is passed around
for no good reason. The locking stuff would indeed be much easier
if a filter pipeline was just a thing of its own, not referring
to pointers which might be volatile.
I've done the change in my tree (patch appended), and havn't
seen any problems for more than 2 months.
Is this OK to commit?

best regards
Matthias



--==_Exmh_8523917051510
Content-Type: text/plain ; name="auif.txt"; charset=us-ascii
Content-Description: auif.txt
Content-Disposition: attachment; filename="auif.txt"

Index: dev/auconv.c
===================================================================
RCS file: /cvsroot/src/sys/dev/auconv.c,v
retrieving revision 1.17
diff -u -r1.17 auconv.c
--- dev/auconv.c	18 Mar 2006 14:31:26 -0000	1.17
+++ dev/auconv.c	28 Jun 2006 15:55:43 -0000
@@ -250,7 +250,7 @@
 static int \
 name##_fetch_to(stream_fetcher_t *, audio_stream_t *, int); \
 stream_filter_t * \
-name(struct audio_softc *sc, const audio_params_t *from, \
+name(const audio_params_t *from, \
      const audio_params_t *to) \
 { \
 	return auconv_nocontext_filter_factory(name##_fetch_to); \
Index: dev/audio.c
===================================================================
RCS file: /cvsroot/src/sys/dev/audio.c,v
retrieving revision 1.208
diff -u -r1.208 audio.c
--- dev/audio.c	27 Jun 2006 02:07:08 -0000	1.208
+++ dev/audio.c	28 Jun 2006 15:55:43 -0000
@@ -685,7 +685,7 @@
 		n = pfilters->req_size - i - 1;
 		to_param = &pfilters->filters[n].param;
 		audio_check_params(to_param);
-		pf[i] = pfilters->filters[n].factory(sc, from_param, to_param);
+		pf[i] = pfilters->filters[n].factory(from_param, to_param);
 		if (pf[i] == NULL)
 			break;
 		if (audio_stream_ctor(&ps[i], from_param, AU_RING_SIZE))
@@ -753,7 +753,7 @@
 		audio_check_params(from_param);
 		to_param = i + 1 < rfilters->req_size
 			? &rfilters->filters[i + 1].param : rp;
-		rf[i] = rfilters->filters[i].factory(sc, from_param, to_param);
+		rf[i] = rfilters->filters[i].factory(from_param, to_param);
 		if (rf[i] == NULL)
 			break;
 		if (audio_stream_ctor(&rs[i], to_param, AU_RING_SIZE))
Index: dev/audio_if.h
===================================================================
RCS file: /cvsroot/src/sys/dev/audio_if.h,v
retrieving revision 1.61
diff -u -r1.61 audio_if.h
--- dev/audio_if.h	19 Apr 2006 14:10:58 -0000	1.61
+++ dev/audio_if.h	28 Jun 2006 15:55:43 -0000
@@ -140,7 +140,7 @@
 /**
  * factory method for stream_filter_t
  */
-typedef stream_filter_t *stream_filter_factory_t(struct audio_softc *,
+typedef stream_filter_t *stream_filter_factory_t(
 	const audio_params_t *, const audio_params_t *);
 
 /**
Index: dev/aurateconv.c
===================================================================
RCS file: /cvsroot/src/sys/dev/aurateconv.c,v
retrieving revision 1.15
diff -u -r1.15 aurateconv.c
--- dev/aurateconv.c	11 Dec 2005 12:20:53 -0000	1.15
+++ dev/aurateconv.c	28 Jun 2006 15:55:43 -0000
@@ -100,7 +100,7 @@
 };
 
 stream_filter_t *
-aurateconv(struct audio_softc *sc, const audio_params_t *from,
+aurateconv(const audio_params_t *from,
 	   const audio_params_t *to)
 {
 	aurateconv_t *this;
Index: dev/mulaw.c
===================================================================
RCS file: /cvsroot/src/sys/dev/mulaw.c,v
retrieving revision 1.24
diff -u -r1.24 mulaw.c
--- dev/mulaw.c	11 Dec 2005 12:20:53 -0000	1.24
+++ dev/mulaw.c	28 Jun 2006 15:55:43 -0000
@@ -262,7 +262,7 @@
 static int \
 name##_fetch_to(stream_fetcher_t *, audio_stream_t *, int); \
 stream_filter_t * \
-name(struct audio_softc *sc, const audio_params_t *from, \
+name(const audio_params_t *from, \
      const audio_params_t *to) \
 { \
 	DPRINTF(("Construct '%s' filter.\n", __func__)); \

--==_Exmh_8523917051510--