Page MenuHomeFreeBSD

D47918.diff
No OneTemporary

D47918.diff

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
@@ -248,46 +248,26 @@
};
CHANNEL_DECLARE(vchan);
-static void
-vchan_getparentchannel(struct snddev_info *d,
- struct pcm_channel **wrch, struct pcm_channel **rdch)
+static struct pcm_channel *
+vchan_getparentchannel(struct snddev_info *d, int direction)
{
- struct pcm_channel **ch, *wch, *rch, *c;
+ struct pcm_channel *c = NULL;
KASSERT(d != NULL, ("%s(): NULL snddev_info", __func__));
PCM_BUSYASSERT(d);
PCM_UNLOCKASSERT(d);
- wch = NULL;
- rch = NULL;
-
- CHN_FOREACH(c, d, channels.pcm) {
+ CHN_FOREACH(c, d, channels.pcm.primary) {
CHN_LOCK(c);
- ch = (c->direction == PCMDIR_PLAY) ? &wch : &rch;
- if (c->flags & CHN_F_VIRTUAL) {
- /* Sanity check */
- if (*ch != NULL && *ch != c->parentchannel) {
- CHN_UNLOCK(c);
- *ch = NULL;
- break;
- }
- } else {
- /* No way!! */
- if (*ch != NULL) {
- CHN_UNLOCK(c);
- *ch = NULL;
- break;
- }
- *ch = c;
+ if (c->direction == direction) {
+ CHN_UNLOCK(c);
+ break;
}
CHN_UNLOCK(c);
}
- if (wrch != NULL)
- *wrch = wch;
- if (rdch != NULL)
- *rdch = rch;
+ return (c);
}
static int
@@ -384,19 +364,11 @@
PCM_ACQUIRE(d);
PCM_UNLOCK(d);
- if (direction == PCMDIR_PLAY)
- vchan_getparentchannel(d, &c, NULL);
- else
- vchan_getparentchannel(d, NULL, &c);
-
- if (c == NULL) {
+ if ((c = vchan_getparentchannel(d, direction)) == NULL) {
PCM_RELEASE_QUICK(d);
return (EINVAL);
}
- KASSERT(direction == c->direction, ("%s(): invalid direction %d/%d",
- __func__, direction, c->direction));
-
CHN_LOCK(c);
if (c->flags & CHN_F_VCHAN_PASSTHROUGH)
strlcpy(dtype, "passthrough", sizeof(dtype));
@@ -486,19 +458,11 @@
PCM_ACQUIRE(d);
PCM_UNLOCK(d);
- if (direction == PCMDIR_PLAY)
- vchan_getparentchannel(d, &c, NULL);
- else
- vchan_getparentchannel(d, NULL, &c);
-
- if (c == NULL) {
+ if ((c = vchan_getparentchannel(d, direction)) == NULL) {
PCM_RELEASE_QUICK(d);
return (EINVAL);
}
- KASSERT(direction == c->direction, ("%s(): invalid direction %d/%d",
- __func__, direction, c->direction));
-
newspd = *vchanrate;
ret = sysctl_handle_int(oidp, &newspd, 0, req);
@@ -592,19 +556,11 @@
PCM_ACQUIRE(d);
PCM_UNLOCK(d);
- if (direction == PCMDIR_PLAY)
- vchan_getparentchannel(d, &c, NULL);
- else
- vchan_getparentchannel(d, NULL, &c);
-
- if (c == NULL) {
+ if ((c = vchan_getparentchannel(d, direction)) == NULL) {
PCM_RELEASE_QUICK(d);
return (EINVAL);
}
- KASSERT(direction == c->direction, ("%s(): invalid direction %d/%d",
- __func__, direction, c->direction));
-
bzero(fmtstr, sizeof(fmtstr));
if (snd_afmt2str(*vchanformat, fmtstr, sizeof(fmtstr)) != *vchanformat)

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 9, 3:28 AM (7 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15061710
Default Alt Text
D47918.diff (2 KB)

Event Timeline