Hi,

When I remove uaudio_drain() on my laptop the attach/detach still
seems to work as expected.
I did a test with two usb soundcards. Audio files were played &
recorded using aucat.

* boot system (no audio device because I disabled azalia)
* attach device1 (Creative card)
* play wav file1 (reference file)
* detach device1
* attach device2 (Yamaha card)
* play wav file1
* record wav file2
* detach device2
* attach device2
* play wav file2
* detach device2
* attach device1
* play wav file2
* detach device1

So far this has only been tested on amd64. Maybe it produces
issues for your uaudio device though.

- Michael


Index: uaudio.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/uaudio.c,v
retrieving revision 1.126
diff -u -p -u -r1.126 uaudio.c
--- uaudio.c    8 Apr 2017 02:57:25 -0000       1.126
+++ uaudio.c    23 Apr 2017 15:34:53 -0000
@@ -371,7 +371,6 @@ void        uaudio_chan_rintr
 
 int    uaudio_open(void *, int);
 void   uaudio_close(void *);
-int    uaudio_drain(void *);
 void   uaudio_get_minmax_rates
        (int, const struct as_info *, const struct audio_params *,
         int, int, int, u_long *, u_long *);
@@ -563,7 +562,6 @@ int
 uaudio_detach(struct device *self, int flags)
 {
        struct uaudio_softc *sc = (struct uaudio_softc *)self;
-       int rv = 0;
 
        /*
         * sc_alts may be NULL if uaudio_identify_as() failed, in
@@ -571,14 +569,8 @@ uaudio_detach(struct device *self, int f
         * nothing to detach.
         */
        if (sc->sc_alts == NULL)
-               return (rv);
-
-       /* Wait for outstanding requests to complete. */
-       uaudio_drain(sc);
-
-       rv = config_detach_children(self, flags);
-
-       return (rv);
+               return (0);
+       return (config_detach_children(self, flags));
 }
 
 const usb_interface_descriptor_t *
@@ -2107,24 +2099,6 @@ uaudio_close(void *addr)
                uaudio_chan_close(sc, &sc->sc_playchan);
        if (sc->sc_recchan.altidx != -1)
                uaudio_chan_close(sc, &sc->sc_recchan);
-}
-
-int
-uaudio_drain(void *addr)
-{
-       struct uaudio_softc *sc = addr;
-       struct chan *pchan = &sc->sc_playchan;
-       struct chan *rchan = &sc->sc_recchan;
-       int ms = 0;
-
-       /* Wait for outstanding requests to complete. */
-       if (pchan->altidx != -1 && sc->sc_alts[pchan->altidx].sc_busy)
-               ms = max(ms, pchan->reqms);
-       if (rchan->altidx != -1 && sc->sc_alts[rchan->altidx].sc_busy)
-               ms = max(ms, rchan->reqms);
-       usbd_delay_ms(sc->sc_udev, UAUDIO_NCHANBUFS * ms);
-
-       return (0);
 }
 
 int

Reply via email to