Page MenuHomeFreeBSD

D48961.id150896.diff
No OneTemporary

D48961.id150896.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
@@ -1179,7 +1179,7 @@
struct feeder_class *fc;
struct snd_dbuf *b, *bs;
char buf[CHN_NAMELEN];
- int err, i, direction;
+ int err, i, direction, *vchanrate, *vchanformat;
PCM_BUSYASSERT(d);
PCM_LOCKASSERT(d);
@@ -1188,10 +1188,14 @@
case PCMDIR_PLAY:
case PCMDIR_PLAY_VIRTUAL:
direction = PCMDIR_PLAY;
+ vchanrate = &d->pvchanrate;
+ vchanformat = &d->pvchanformat;
break;
case PCMDIR_REC:
case PCMDIR_REC_VIRTUAL:
direction = PCMDIR_REC;
+ vchanrate = &d->rvchanrate;
+ vchanformat = &d->rvchanformat;
break;
default:
device_printf(d->dev,
@@ -1296,8 +1300,12 @@
PCM_LOCK(d);
CHN_INSERT_SORT_ASCEND(d, c, channels.pcm);
- if ((c->flags & CHN_F_VIRTUAL) == 0)
+ if ((c->flags & CHN_F_VIRTUAL) == 0) {
CHN_INSERT_SORT_ASCEND(d, c, channels.pcm.primary);
+ /* Initialize the *vchanrate/vchanformat parameters. */
+ *vchanrate = sndbuf_getspd(c->bufsoft);
+ *vchanformat = sndbuf_getfmt(c->bufsoft);
+ }
switch (c->type) {
case PCMDIR_PLAY:
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
@@ -405,7 +405,6 @@
{
struct snddev_info *d;
struct pcm_channel *c, *ch;
- struct pcmchan_caps *caps;
int *vchanrate, direction, ret, newspd, restart;
d = devclass_get_softc(pcm_devclass, VCHAN_SYSCTL_UNIT(oidp->oid_arg1));
@@ -467,13 +466,6 @@
} 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) {
if (restart != 0) {
@@ -488,7 +480,7 @@
}
}
}
- *vchanrate = c->speed;
+ *vchanrate = sndbuf_getspd(c->bufsoft);
CHN_UNLOCK(c);
}
@@ -583,7 +575,7 @@
}
}
}
- *vchanformat = c->format;
+ *vchanformat = sndbuf_getfmt(c->bufsoft);
CHN_UNLOCK(c);
}
@@ -607,11 +599,9 @@
struct pcm_channel *ch;
struct pcmchan_caps *parent_caps;
uint32_t vchanfmt, vchanspd;
- int ret, direction, r;
- bool save;
+ int ret, direction;
ret = 0;
- save = false;
d = parent->parentsnddev;
PCM_BUSYASSERT(d);
@@ -664,75 +654,9 @@
goto fail;
}
- if (vchanfmt == 0) {
- const char *vfmt;
-
- CHN_UNLOCK(parent);
- r = resource_string_value(device_get_name(parent->dev),
- device_get_unit(parent->dev), VCHAN_FMT_HINT(direction),
- &vfmt);
- CHN_LOCK(parent);
- if (r != 0)
- vfmt = NULL;
- if (vfmt != NULL) {
- vchanfmt = snd_str2afmt(vfmt);
- if (vchanfmt != 0 && !(vchanfmt & AFMT_VCHAN))
- vchanfmt = 0;
- }
- if (vchanfmt == 0)
- vchanfmt = VCHAN_DEFAULT_FORMAT;
- save = true;
- }
-
- if (vchanspd == 0) {
- /*
- * This is very sad. Few soundcards advertised as being
- * able to do (insanely) higher/lower speed, but in
- * reality, they simply can't. At least, we give user chance
- * to set sane value via kernel hints or sysctl.
- */
- CHN_UNLOCK(parent);
- r = resource_int_value(device_get_name(parent->dev),
- device_get_unit(parent->dev), VCHAN_SPD_HINT(direction),
- &vchanspd);
- CHN_LOCK(parent);
- if (r != 0) {
- /* No saved value, no hint, NOTHING. */
- vchanspd = VCHAN_DEFAULT_RATE;
- RANGE(vchanspd, parent_caps->minspeed,
- parent_caps->maxspeed);
- }
- save = true;
- }
-
- /*
- * 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);
- }
-
if ((ret = chn_reset(parent, vchanfmt, vchanspd)) != 0)
goto fail;
- if (save) {
- /*
- * Save new value.
- */
- if (direction == PCMDIR_PLAY_VIRTUAL) {
- d->pvchanformat = parent->format;
- d->pvchanrate = parent->speed;
- } else {
- d->rvchanformat = parent->format;
- d->rvchanrate = parent->speed;
- }
- }
-
/*
* If the parent channel supports digital format,
* enable passthrough mode.

File Metadata

Mime Type
text/plain
Expires
Sat, Feb 22, 7:05 PM (4 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16761266
Default Alt Text
D48961.id150896.diff (4 KB)

Event Timeline