Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/sound/pcm/vchan.c
Show First 20 Lines • Show All 922 Lines • ▼ Show 20 Lines | vchan_setnew(struct snddev_info *d, int direction, int newcnt) | ||||
if (newcnt > vcnt) { | if (newcnt > vcnt) { | ||||
/* add new vchans - find a parent channel first */ | /* add new vchans - find a parent channel first */ | ||||
ch = NULL; | ch = NULL; | ||||
CHN_FOREACH(c, d, channels.pcm) { | CHN_FOREACH(c, d, channels.pcm) { | ||||
CHN_LOCK(c); | CHN_LOCK(c); | ||||
if (c->direction == direction && | if (c->direction == direction && | ||||
((c->flags & CHN_F_HAS_VCHAN) || (vcnt == 0 && | ((c->flags & CHN_F_HAS_VCHAN) || (vcnt == 0 && | ||||
c->refcount < 1 && | |||||
!(c->flags & (CHN_F_BUSY | CHN_F_VIRTUAL))))) { | !(c->flags & (CHN_F_BUSY | CHN_F_VIRTUAL))))) { | ||||
/* | /* | ||||
* Reuse hw channel with vchans already | * Reuse hw channel with vchans already | ||||
* created. | * created. | ||||
*/ | */ | ||||
if (c->flags & CHN_F_HAS_VCHAN) { | if (c->flags & CHN_F_HAS_VCHAN) { | ||||
ch = c; | ch = c; | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | CHN_FOREACH(c, d, channels.pcm) { | ||||
if (c->direction != direction || | if (c->direction != direction || | ||||
CHN_EMPTY(c, children) || | CHN_EMPTY(c, children) || | ||||
!(c->flags & CHN_F_HAS_VCHAN)) { | !(c->flags & CHN_F_HAS_VCHAN)) { | ||||
CHN_UNLOCK(c); | CHN_UNLOCK(c); | ||||
continue; | continue; | ||||
} | } | ||||
CHN_FOREACH_SAFE(ch, c, nch, children) { | CHN_FOREACH_SAFE(ch, c, nch, children) { | ||||
CHN_LOCK(ch); | CHN_LOCK(ch); | ||||
if (vcnt == 1 && c->refcount > 0) { | if (vcnt == 1 && ch->flags & CHN_F_BUSY) { | ||||
CHN_UNLOCK(ch); | CHN_UNLOCK(ch); | ||||
break; | break; | ||||
} | } | ||||
if (!(ch->flags & CHN_F_BUSY) && | if (!(ch->flags & CHN_F_BUSY)) { | ||||
ch->refcount < 1) { | |||||
err = vchan_destroy(ch); | err = vchan_destroy(ch); | ||||
if (err == 0) | if (err == 0) | ||||
vcnt--; | vcnt--; | ||||
} else | } else | ||||
CHN_UNLOCK(ch); | CHN_UNLOCK(ch); | ||||
if (vcnt == newcnt) | if (vcnt == newcnt) | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 118 Lines • Show Last 20 Lines |