Page MenuHomeFreeBSD

D46680.diff
No OneTemporary

D46680.diff

diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c
--- a/sys/dev/sound/pcm/channel.c
+++ b/sys/dev/sound/pcm/channel.c
@@ -1157,6 +1157,24 @@
return r;
}
+static struct unrhdr *
+chn_getunr(struct snddev_info *d, int type)
+{
+ switch (type) {
+ case SND_DEV_DSPHW_PLAY:
+ return (d->p_unr);
+ case SND_DEV_DSPHW_VPLAY:
+ return (d->vp_unr);
+ case SND_DEV_DSPHW_REC:
+ return (d->r_unr);
+ case SND_DEV_DSPHW_VREC:
+ return (d->vr_unr);
+ default:
+ __assert_unreachable();
+ }
+
+}
+
struct pcm_channel *
chn_init(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls,
int dir, void *devinfo)
@@ -1165,7 +1183,7 @@
struct feeder_class *fc;
struct snd_dbuf *b, *bs;
char *dirs, buf[CHN_NAMELEN];
- int i, direction, type, unit;
+ int i, direction, type;
PCM_BUSYASSERT(d);
PCM_LOCKASSERT(d);
@@ -1198,13 +1216,6 @@
return (NULL);
}
- unit = 0;
- CHN_FOREACH(c, d, channels.pcm) {
- if (c->type != type)
- continue;
- unit++;
- }
-
PCM_UNLOCK(d);
b = NULL;
bs = NULL;
@@ -1216,7 +1227,7 @@
CHN_INIT(c, children.busy);
c->direction = direction;
c->type = type;
- c->unit = unit;
+ c->unit = alloc_unr(chn_getunr(d, c->type));
c->format = SND_FORMAT(AFMT_U8, 1, 0);
c->speed = DSP_DEFAULT_SPEED;
c->pid = -1;
@@ -1304,6 +1315,7 @@
return (c);
fail:
+ free_unr(chn_getunr(d, c->type), c->unit);
feeder_remove(c);
if (c->devinfo && CHANNEL_FREE(c->methods, c->devinfo))
sndbuf_free(b);
@@ -1335,6 +1347,7 @@
chn_trigger(c, PCMTRIG_ABORT);
CHN_UNLOCK(c);
}
+ free_unr(chn_getunr(c->parentsnddev, c->type), c->unit);
feeder_remove(c);
if (CHANNEL_FREE(c->methods, c->devinfo))
sndbuf_free(b);
diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h
--- a/sys/dev/sound/pcm/sound.h
+++ b/sys/dev/sound/pcm/sound.h
@@ -325,6 +325,10 @@
struct sysctl_ctx_list play_sysctl_ctx, rec_sysctl_ctx;
struct sysctl_oid *play_sysctl_tree, *rec_sysctl_tree;
struct cv cv;
+ struct unrhdr *p_unr;
+ struct unrhdr *vp_unr;
+ struct unrhdr *r_unr;
+ struct unrhdr *vr_unr;
};
void sound_oss_sysinfo(oss_sysinfo *);
diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c
--- a/sys/dev/sound/pcm/sound.c
+++ b/sys/dev/sound/pcm/sound.c
@@ -568,6 +568,10 @@
d->pvchanformat = 0;
d->rvchanrate = 0;
d->rvchanformat = 0;
+ d->p_unr = new_unrhdr(0, INT_MAX, NULL);
+ d->vp_unr = new_unrhdr(0, INT_MAX, NULL);
+ d->r_unr = new_unrhdr(0, INT_MAX, NULL);
+ d->vr_unr = new_unrhdr(0, INT_MAX, NULL);
CHN_INIT(d, channels.pcm);
CHN_INIT(d, channels.pcm.busy);
@@ -653,6 +657,14 @@
cv_destroy(&d->cv);
PCM_UNLOCK(d);
snd_mtxfree(d->lock);
+ if (d->p_unr != NULL)
+ delete_unrhdr(d->p_unr);
+ if (d->vp_unr != NULL)
+ delete_unrhdr(d->vp_unr);
+ if (d->r_unr != NULL)
+ delete_unrhdr(d->r_unr);
+ if (d->vr_unr != NULL)
+ delete_unrhdr(d->vr_unr);
if (snd_unit == device_get_unit(dev)) {
snd_unit = pcm_best_unit(-1);

File Metadata

Mime Type
text/plain
Expires
Thu, Mar 13, 12:20 AM (7 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17127863
Default Alt Text
D46680.diff (2 KB)

Event Timeline