Re: uaudio_drain() not needed?
On Mon, Apr 24, 2017 at 08:29:17AM +0200, Alexandre Ratchov wrote: > On Mon, Apr 24, 2017 at 01:04:12AM +0800, Michael W. Bombardieri wrote: > > 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. > > > > AFAICS this is correct. uaudio_drain() used to be the "drain" > method, but the audio(4) layer doesn't use it anymore. IMO, it > shouldn't be called by uaudio_detach(), the device is gone and > there are no outstanding requests. FWIW I have now tested this diff on i386. Everything worked ok. One test I neglected earlier was to physically disconnect usb audio device while playing or recording with aucat--that also worked.
Re: uaudio_drain() not needed?
On Mon, Apr 24, 2017 at 01:04:12AM +0800, Michael W. Bombardieri wrote: > 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. > AFAICS this is correct. uaudio_drain() used to be the "drain" method, but the audio(4) layer doesn't use it anymore. IMO, it shouldn't be called by uaudio_detach(), the device is gone and there are no outstanding requests.
uaudio_drain() not needed?
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.c8 Apr 2017 02:57:25 - 1.126 +++ uaudio.c23 Apr 2017 15:34:53 - @@ -371,7 +371,6 @@ voiduaudio_chan_rintr intuaudio_open(void *, int); void uaudio_close(void *); -intuaudio_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