Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F109298616
D46833.id143866.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D46833.id143866.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
@@ -676,6 +676,8 @@
uint32_t vchanfmt, vchanspd;
int ret, direction, r, save;
+ ret = 0;
+ save = 0;
d = parent->parentsnddev;
PCM_BUSYASSERT(d);
@@ -688,8 +690,6 @@
parent->direction == PCMDIR_REC))
return (EINVAL);
- d = parent->parentsnddev;
-
CHN_UNLOCK(parent);
PCM_LOCK(d);
@@ -728,14 +728,13 @@
parent->flags |= CHN_F_HAS_VCHAN;
- ret = 0;
parent_caps = chn_getcaps(parent);
- if (parent_caps == NULL)
+ if (parent_caps == NULL) {
ret = EINVAL;
+ goto fail;
+ }
- save = 0;
-
- if (ret == 0 && vchanfmt == 0) {
+ if (vchanfmt == 0) {
const char *vfmt;
CHN_UNLOCK(parent);
@@ -755,7 +754,7 @@
save = 1;
}
- if (ret == 0 && vchanspd == 0) {
+ if (vchanspd == 0) {
/*
* This is very sad. Few soundcards advertised as being
* able to do (insanely) higher/lower speed, but in
@@ -776,23 +775,22 @@
save = 1;
}
- if (ret == 0) {
- /*
- * Limit the speed between feeder_rate_min <-> feeder_rate_max.
- */
- RANGE(vchanspd, feeder_rate_min, feeder_rate_max);
-
- if (feeder_rate_round) {
- RANGE(vchanspd, parent_caps->minspeed,
- parent_caps->maxspeed);
- vchanspd = CHANNEL_SETSPEED(parent->methods,
- parent->devinfo, vchanspd);
- }
+ /*
+ * Limit the speed between feeder_rate_min <-> feeder_rate_max.
+ */
+ RANGE(vchanspd, feeder_rate_min, feeder_rate_max);
- ret = chn_reset(parent, vchanfmt, vchanspd);
+ if (feeder_rate_round) {
+ RANGE(vchanspd, parent_caps->minspeed,
+ parent_caps->maxspeed);
+ vchanspd = CHANNEL_SETSPEED(parent->methods,
+ parent->devinfo, vchanspd);
}
- if (ret == 0 && save) {
+ if ((ret = chn_reset(parent, vchanfmt, vchanspd)) != 0)
+ goto fail;
+
+ if (save) {
/*
* Save new value.
*/
@@ -809,23 +807,24 @@
* If the parent channel supports digital format,
* enable passthrough mode.
*/
- if (ret == 0 && snd_fmtvalid(AFMT_PASSTHROUGH, parent_caps->fmtlist)) {
+ if (snd_fmtvalid(AFMT_PASSTHROUGH, parent_caps->fmtlist)) {
parent->flags &= ~CHN_F_VCHAN_DYNAMIC;
parent->flags |= CHN_F_VCHAN_PASSTHROUGH;
}
- if (ret != 0) {
- CHN_REMOVE(parent, ch, children);
- parent->flags &= ~CHN_F_HAS_VCHAN;
- CHN_UNLOCK(parent);
- PCM_LOCK(d);
- if (pcm_chn_remove(d, ch) == 0) {
- PCM_UNLOCK(d);
- chn_kill(ch);
- } else
- PCM_UNLOCK(d);
- CHN_LOCK(parent);
- }
+ return (ret);
+
+fail:
+ CHN_REMOVE(parent, ch, children);
+ parent->flags &= ~CHN_F_HAS_VCHAN;
+ CHN_UNLOCK(parent);
+ PCM_LOCK(d);
+ if (pcm_chn_remove(d, ch) == 0) {
+ PCM_UNLOCK(d);
+ chn_kill(ch);
+ } else
+ PCM_UNLOCK(d);
+ CHN_LOCK(parent);
return (ret);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Feb 4, 5:59 AM (21 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16448820
Default Alt Text
D46833.id143866.diff (2 KB)
Attached To
Mode
D46833: sound: Simplify vchan_create() error paths
Attached
Detach File
Event Timeline
Log In to Comment