Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107002748
D48336.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D48336.diff
View Options
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
@@ -253,48 +253,6 @@
};
CHANNEL_DECLARE(vchan);
-static void
-vchan_getparentchannel(struct snddev_info *d,
- struct pcm_channel **wrch, struct pcm_channel **rdch)
-{
- struct pcm_channel **ch, *wch, *rch, *c;
-
- 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_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;
- }
- CHN_UNLOCK(c);
- }
-
- if (wrch != NULL)
- *wrch = wch;
- if (rdch != NULL)
- *rdch = rch;
-}
-
static int
sysctl_dev_pcm_vchans(SYSCTL_HANDLER_ARGS)
{
@@ -391,19 +349,6 @@
PCM_ACQUIRE(d);
PCM_UNLOCK(d);
- if (direction == PCMDIR_PLAY)
- vchan_getparentchannel(d, &c, NULL);
- else
- vchan_getparentchannel(d, NULL, &c);
-
- if (c == NULL) {
- PCM_RELEASE_QUICK(d);
- return (EINVAL);
- }
-
- KASSERT(direction == c->direction, ("%s(): invalid direction %d/%d",
- __func__, direction, c->direction));
-
if (*vchanmode & CHN_F_VCHAN_PASSTHROUGH)
strlcpy(dtype, "passthrough", sizeof(dtype));
else if (*vchanmode & CHN_F_VCHAN_ADAPTIVE)
@@ -412,26 +357,29 @@
strlcpy(dtype, "fixed", sizeof(dtype));
ret = sysctl_handle_string(oidp, dtype, sizeof(dtype), req);
- if (ret == 0 && req->newptr != NULL) {
- if (strcasecmp(dtype, "passthrough") == 0 ||
- strcmp(dtype, "1") == 0)
- dflags = CHN_F_VCHAN_PASSTHROUGH;
- else if (strcasecmp(dtype, "adaptive") == 0 ||
- strcmp(dtype, "2") == 0)
- dflags = CHN_F_VCHAN_ADAPTIVE;
- else if (strcasecmp(dtype, "fixed") == 0 ||
- strcmp(dtype, "0") == 0)
- dflags = 0;
- else {
- PCM_RELEASE_QUICK(d);
- return (EINVAL);
- }
+ if (ret != 0 || req->newptr == NULL) {
+ PCM_RELEASE_QUICK(d);
+ return (ret);
+ }
+
+ if (strcasecmp(dtype, "passthrough") == 0 || strcmp(dtype, "1") == 0)
+ dflags = CHN_F_VCHAN_PASSTHROUGH;
+ else if (strcasecmp(dtype, "adaptive") == 0 || strcmp(dtype, "2") == 0)
+ dflags = CHN_F_VCHAN_ADAPTIVE;
+ else if (strcasecmp(dtype, "fixed") == 0 || strcmp(dtype, "0") == 0)
+ dflags = 0;
+ else {
+ PCM_RELEASE_QUICK(d);
+ return (EINVAL);
+ }
+
+ CHN_FOREACH(c, d, channels.pcm.primary) {
CHN_LOCK(c);
- if (dflags == (c->flags & CHN_F_VCHAN_DYNAMIC) ||
+ if (c->direction != direction ||
+ dflags == (c->flags & CHN_F_VCHAN_DYNAMIC) ||
(c->flags & CHN_F_PASSTHROUGH)) {
CHN_UNLOCK(c);
- PCM_RELEASE_QUICK(d);
- return (0);
+ continue;
}
c->flags &= ~CHN_F_VCHAN_DYNAMIC;
c->flags |= dflags;
@@ -492,19 +440,6 @@
PCM_ACQUIRE(d);
PCM_UNLOCK(d);
- if (direction == PCMDIR_PLAY)
- vchan_getparentchannel(d, &c, NULL);
- else
- vchan_getparentchannel(d, NULL, &c);
-
- if (c == 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);
@@ -518,40 +453,44 @@
return (EINVAL);
}
- CHN_LOCK(c);
-
- if (newspd != c->speed && VCHAN_ACCESSIBLE(c)) {
- if (CHN_STARTED(c)) {
- chn_abort(c);
- restart = 1;
- } else
- restart = 0;
-
- if (feeder_rate_round) {
- caps = chn_getcaps(c);
- RANGE(newspd, caps->minspeed, caps->maxspeed);
- newspd = CHANNEL_SETSPEED(c->methods,
- c->devinfo, newspd);
+ CHN_FOREACH(c, d, channels.pcm.primary) {
+ CHN_LOCK(c);
+ if (c->direction != direction) {
+ CHN_UNLOCK(c);
+ continue;
}
+ if (newspd != c->speed && VCHAN_ACCESSIBLE(c)) {
+ if (CHN_STARTED(c)) {
+ chn_abort(c);
+ restart = 1;
+ } else
+ restart = 0;
+
+ if (feeder_rate_round) {
+ caps = chn_getcaps(c);
+ RANGE(newspd, caps->minspeed, caps->maxspeed);
+ newspd = CHANNEL_SETSPEED(c->methods,
+ c->devinfo, newspd);
+ }
- 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);
- if (VCHAN_SYNC_REQUIRED(ch))
- vchan_sync(ch);
- CHN_UNLOCK(ch);
+ 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);
+ if (VCHAN_SYNC_REQUIRED(ch))
+ vchan_sync(ch);
+ CHN_UNLOCK(ch);
+ }
+ c->flags |= CHN_F_DIRTY;
+ ret = chn_start(c, 1);
}
- c->flags |= CHN_F_DIRTY;
- ret = chn_start(c, 1);
}
}
+ CHN_UNLOCK(c);
}
- CHN_UNLOCK(c);
-
PCM_RELEASE_QUICK(d);
return (ret);
@@ -598,19 +537,6 @@
PCM_ACQUIRE(d);
PCM_UNLOCK(d);
- if (direction == PCMDIR_PLAY)
- vchan_getparentchannel(d, &c, NULL);
- else
- vchan_getparentchannel(d, NULL, &c);
-
- if (c == 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)
@@ -628,33 +554,37 @@
return (EINVAL);
}
- CHN_LOCK(c);
-
- if (newfmt != c->format && VCHAN_ACCESSIBLE(c)) {
- if (CHN_STARTED(c)) {
- chn_abort(c);
- restart = 1;
- } else
- restart = 0;
-
- 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);
- if (VCHAN_SYNC_REQUIRED(ch))
- vchan_sync(ch);
- CHN_UNLOCK(ch);
+ CHN_FOREACH(c, d, channels.pcm.primary) {
+ CHN_LOCK(c);
+ if (c->direction != direction) {
+ CHN_UNLOCK(c);
+ continue;
+ }
+ if (newfmt != c->format && VCHAN_ACCESSIBLE(c)) {
+ if (CHN_STARTED(c)) {
+ chn_abort(c);
+ restart = 1;
+ } else
+ restart = 0;
+
+ 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);
+ if (VCHAN_SYNC_REQUIRED(ch))
+ vchan_sync(ch);
+ CHN_UNLOCK(ch);
+ }
+ c->flags |= CHN_F_DIRTY;
+ ret = chn_start(c, 1);
}
- c->flags |= CHN_F_DIRTY;
- ret = chn_start(c, 1);
}
}
+ CHN_UNLOCK(c);
}
- CHN_UNLOCK(c);
-
PCM_RELEASE_QUICK(d);
return (ret);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 9, 7:45 PM (9 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15723662
Default Alt Text
D48336.diff (6 KB)
Attached To
Mode
D48336: sound: Handle multiple primary channel cases in vchan sysctls
Attached
Detach File
Event Timeline
Log In to Comment