diff --git a/sys/dev/sound/pcm/vchan.c b/sys/dev/sound/pcm/vchan.c --- a/sys/dev/sound/pcm/vchan.c +++ b/sys/dev/sound/pcm/vchan.c @@ -497,9 +497,7 @@ KASSERT(direction == c->direction, ("%s(): invalid direction %d/%d", __func__, direction, c->direction)); - CHN_LOCK(c); - newspd = c->speed; - CHN_UNLOCK(c); + newspd = *vchanrate; ret = sysctl_handle_int(oidp, &newspd, 0, req); if (ret != 0 || req->newptr == NULL) { @@ -530,7 +528,6 @@ ret = chn_reset(c, c->format, newspd); if (ret == 0) { - *vchanrate = c->speed; if (restart != 0) { CHN_FOREACH(ch, c, children.busy) { CHN_LOCK(ch); @@ -543,6 +540,7 @@ } } } + *vchanrate = c->speed; CHN_UNLOCK(c); @@ -605,15 +603,11 @@ KASSERT(direction == c->direction, ("%s(): invalid direction %d/%d", __func__, direction, c->direction)); - CHN_LOCK(c); - bzero(fmtstr, sizeof(fmtstr)); - if (snd_afmt2str(c->format, fmtstr, sizeof(fmtstr)) != c->format) + if (snd_afmt2str(*vchanformat, fmtstr, sizeof(fmtstr)) != *vchanformat) strlcpy(fmtstr, "", sizeof(fmtstr)); - CHN_UNLOCK(c); - ret = sysctl_handle_string(oidp, fmtstr, sizeof(fmtstr), req); if (ret != 0 || req->newptr == NULL) { PCM_RELEASE_QUICK(d); @@ -637,7 +631,6 @@ ret = chn_reset(c, newfmt, c->speed); if (ret == 0) { - *vchanformat = c->format; if (restart != 0) { CHN_FOREACH(ch, c, children.busy) { CHN_LOCK(ch); @@ -650,6 +643,7 @@ } } } + *vchanformat = c->format; CHN_UNLOCK(c);