make attempts to set unsupported speeds or formats non-sticky. this should

fix problems with apps that probe for a variety of settings.

Submitted by:	Orion Hodson <O.Hodson@cs.ucl.ac.uk>
This commit is contained in:
Cameron Grant 2001-02-13 21:57:34 +00:00
parent cdcb6bc676
commit 7ec3c4620e

View File

@ -1106,8 +1106,8 @@ chn_setvolume(pcm_channel *c, int left, int right)
return 0;
}
int
chn_setspeed(pcm_channel *c, int speed)
static int
chn_tryspeed(pcm_channel *c, int speed)
{
pcm_feeder *f;
snd_dbuf *b = &c->buffer;
@ -1171,7 +1171,20 @@ chn_setspeed(pcm_channel *c, int speed)
}
int
chn_setformat(pcm_channel *c, u_int32_t fmt)
chn_setspeed(pcm_channel *c, int speed)
{
int r, oldspeed = c->speed;
r = chn_tryspeed(c, speed);
if (r) {
DEB(printf("Failed to set speed %d falling back to %d\n", speed, oldspeed));
chn_tryspeed(c, oldspeed);
}
return r;
}
static int
chn_tryformat(pcm_channel *c, u_int32_t fmt)
{
snd_dbuf *b = &c->buffer;
snd_dbuf *bs = &c->buffer2nd;
@ -1200,6 +1213,20 @@ chn_setformat(pcm_channel *c, u_int32_t fmt)
return 0;
}
int
chn_setformat(pcm_channel *c, u_int32_t fmt)
{
u_int32_t oldfmt = c->format;
int r;
r = chn_tryformat(c, fmt);
if (r) {
DEB(printf("Format change %d failed, reverting to %d\n", fmt, oldfmt));
chn_tryformat(c, oldfmt);
}
return r;
}
int
chn_setblocksize(pcm_channel *c, int blkcnt, int blksz)
{