New PCM model with fragment concept removal and two interrupt sources

Renamed size_t/ssize_t to snd_pcm_sframes_t/snd_pcm_uframes_t
This commit is contained in:
Abramo Bagnara 2001-01-15 11:06:53 +00:00
parent 7b06e6f762
commit cc90e32557
29 changed files with 2433 additions and 1906 deletions

View file

@ -58,6 +58,8 @@ static inline unsigned int div_up(unsigned int a, unsigned int b)
static inline unsigned int mul(unsigned int a, unsigned int b)
{
if (a == 0)
return 0;
if (div_down(UINT_MAX, a) < b)
return UINT_MAX;
return a * b;
@ -89,10 +91,9 @@ static inline unsigned int muldiv32(unsigned int a, unsigned int b,
return n;
}
int interval_refine_min(interval_t *i, unsigned int min)
int interval_refine_min(interval_t *i, unsigned int min, int openmin)
{
int changed = 0;
int openmin = 0;
assert(!interval_empty(i));
if (i->min < min) {
i->min = min;
@ -102,24 +103,22 @@ int interval_refine_min(interval_t *i, unsigned int min)
i->openmin = 1;
changed = 1;
}
if (!i->real) {
if (i->integer) {
if (i->openmin) {
i->min++;
i->openmin = 0;
}
}
if (interval_checkempty(i)) {
i->empty = 1;
interval_none(i);
return -EINVAL;
}
return changed;
}
int interval_refine_max(interval_t *i, unsigned int max)
int interval_refine_max(interval_t *i, unsigned int max, int openmax)
{
int changed = 0;
int openmax = 1;
max = add(max, 1);
assert(!interval_empty(i));
if (i->max > max) {
i->max = max;
@ -129,14 +128,14 @@ int interval_refine_max(interval_t *i, unsigned int max)
i->openmax = 1;
changed = 1;
}
if (!i->real) {
if (i->integer) {
if (i->openmax) {
i->max--;
i->openmax = 0;
}
}
if (interval_checkempty(i)) {
i->empty = 1;
interval_none(i);
return -EINVAL;
}
return changed;
@ -163,7 +162,11 @@ int interval_refine(interval_t *i, const interval_t *v)
i->openmax = 1;
changed = 1;
}
if (!i->real) {
if (!i->integer && v->integer) {
i->integer = 1;
changed = 1;
}
if (i->integer) {
if (i->openmin) {
i->min++;
i->openmin = 0;
@ -172,9 +175,10 @@ int interval_refine(interval_t *i, const interval_t *v)
i->max--;
i->openmax = 0;
}
}
} else if (!i->openmin && !i->openmax && i->min == i->max)
i->integer = 1;
if (interval_checkempty(i)) {
i->empty = 1;
interval_none(i);
return -EINVAL;
}
return changed;
@ -183,8 +187,7 @@ int interval_refine(interval_t *i, const interval_t *v)
int interval_refine_first(interval_t *i)
{
assert(!interval_empty(i));
if (i->min == i->max ||
(i->min + 1 == i->max && i->openmin && i->openmax))
if (interval_single(i))
return 0;
i->max = i->min;
i->openmax = i->openmin;
@ -196,8 +199,7 @@ int interval_refine_first(interval_t *i)
int interval_refine_last(interval_t *i)
{
assert(!interval_empty(i));
if (i->min == i->max ||
(i->min + 1 == i->max && i->openmin && i->openmax))
if (interval_single(i))
return 0;
i->min = i->max;
i->openmin = i->openmax;
@ -209,107 +211,154 @@ int interval_refine_last(interval_t *i)
int interval_refine_set(interval_t *i, unsigned int val)
{
interval_t t;
t.min = val;
t.openmin = 0;
t.max = add(val, 1);
t.openmax = 1;
t.empty = 0;
t.min = t.max = val;
t.openmin = t.openmax = 0;
t.integer = 1;
return interval_refine(i, &t);
}
/* a <- b + c */
int interval_add(interval_t *a, const interval_t *b, const interval_t *c)
void interval_add(const interval_t *a, const interval_t *b, interval_t *c)
{
interval_t t;
assert(!a->empty && !b->empty && !c->empty);
t.min = add(b->min, c->min);
t.openmin = (b->openmin || c->openmin);
t.max = add(b->max, c->max);
t.openmax = (b->openmax || c->openmax);
return interval_refine(a, &t);
if (a->empty || b->empty) {
interval_none(c);
return;
}
c->empty = 0;
c->min = add(a->min, b->min);
c->openmin = (a->openmin || b->openmin);
c->max = add(a->max, b->max);
c->openmax = (a->openmax || b->openmax);
c->integer = (a->integer && b->integer);
}
/* a <- b - c */
int interval_sub(interval_t *a, const interval_t *b, const interval_t *c)
void interval_sub(const interval_t *a, const interval_t *b, interval_t *c)
{
interval_t t;
assert(!a->empty && !b->empty && !c->empty);
t.min = sub(b->min, c->max);
t.openmin = (b->openmin || c->openmax);
t.max = add(b->max, c->min);
t.openmax = (b->openmax || c->openmin);
return interval_refine(a, &t);
if (a->empty || b->empty) {
interval_none(c);
return;
}
c->empty = 0;
c->min = sub(a->min, b->max);
c->openmin = (a->openmin || b->openmax);
c->max = add(a->max, b->min);
c->openmax = (a->openmax || b->openmin);
c->integer = (a->integer && b->integer);
}
/* a <- b * c */
int interval_mul(interval_t *a, const interval_t *b, const interval_t *c)
void interval_mul(const interval_t *a, const interval_t *b, interval_t *c)
{
interval_t t;
assert(!a->empty && !b->empty && !c->empty);
t.min = mul(b->min, c->min);
t.openmin = (b->openmin || c->openmin);
t.max = mul(b->max, c->max);
t.openmax = (b->openmax || c->openmax);
return interval_refine(a, &t);
if (a->empty || b->empty) {
interval_none(c);
return;
}
c->empty = 0;
c->min = mul(a->min, b->min);
c->openmin = (a->openmin || b->openmin);
c->max = mul(a->max, b->max);
c->openmax = (a->openmax || b->openmax);
c->integer = (a->integer && b->integer);
}
/* a <- b / c */
int interval_div(interval_t *a, const interval_t *b, const interval_t *c)
void interval_div(const interval_t *a, const interval_t *b, interval_t *c)
{
interval_t t;
unsigned int r;
assert(!a->empty && !b->empty && !c->empty);
t.min = div32(b->min, c->max, &r);
t.openmin = (r || b->openmin || c->openmax);
t.max = div32(b->max, c->min, &r);
if (r) {
t.max++;
t.openmax = 1;
} else
t.openmax = (b->openmax || c->openmin);
return interval_refine(a, &t);
if (a->empty || b->empty) {
interval_none(c);
return;
}
c->empty = 0;
c->min = div32(a->min, b->max, &r);
c->openmin = (r || a->openmin || b->openmax);
if (b->min > 0) {
c->max = div32(a->max, b->min, &r);
if (r) {
c->max++;
c->openmax = 1;
} else
c->openmax = (a->openmax || b->openmin);
} else {
c->max = UINT_MAX;
c->openmax = 0;
}
c->integer = 0;
}
/* a <- b * c / k */
int interval_muldivk(interval_t *a, unsigned int k,
const interval_t *b, const interval_t *c)
/* a * b / c */
void interval_muldiv(const interval_t *a, const interval_t *b,
const interval_t *c, interval_t *d)
{
interval_t t;
unsigned int r;
assert(!a->empty && !b->empty && !c->empty);
t.min = muldiv32(b->min, c->min, k, &r);
t.openmin = (r || b->openmin || c->openmin);
t.max = muldiv32(b->max, c->max, k, &r);
if (a->empty || b->empty || c->empty) {
interval_none(d);
return;
}
d->empty = 0;
d->min = muldiv32(a->min, b->min, c->max, &r);
d->openmin = (r || a->openmin || b->openmin || c->openmax);
d->max = muldiv32(a->max, b->max, c->min, &r);
if (r) {
t.max++;
t.openmax = 1;
d->max++;
d->openmax = 1;
} else
t.openmax = (b->openmax || c->openmax);
return interval_refine(a, &t);
d->openmax = (a->openmax || b->openmax || c->openmin);
d->integer = 0;
}
/* a <- b * k / c */
int interval_mulkdiv(interval_t *a, unsigned int k,
const interval_t *b, const interval_t *c)
/* a * b / k */
void interval_muldivk(const interval_t *a, const interval_t *b,
unsigned int k, interval_t *c)
{
interval_t t;
unsigned int r;
assert(!a->empty && !b->empty && !c->empty);
t.min = muldiv32(b->min, k, c->max, &r);
t.openmin = (r || b->openmin || c->openmax);
t.max = muldiv32(b->max, k, c->min, &r);
if (a->empty || b->empty) {
interval_none(c);
return;
}
c->empty = 0;
c->min = muldiv32(a->min, b->min, k, &r);
c->openmin = (r || a->openmin || b->openmin);
c->max = muldiv32(a->max, b->max, k, &r);
if (r) {
t.max++;
t.openmax = 1;
c->max++;
c->openmax = 1;
} else
t.openmax = (b->openmax || c->openmin);
return interval_refine(a, &t);
c->openmax = (a->openmax || b->openmax);
c->integer = 0;
}
/* a * k / b */
void interval_mulkdiv(const interval_t *a, unsigned int k,
const interval_t *b, interval_t *c)
{
unsigned int r;
if (a->empty || b->empty) {
interval_none(c);
return;
}
c->empty = 0;
c->min = muldiv32(a->min, k, b->max, &r);
c->openmin = (r || a->openmin || b->openmax);
if (b->min > 0) {
c->max = muldiv32(a->max, k, b->min, &r);
if (r) {
c->max++;
c->openmax = 1;
} else
c->openmax = (a->openmax || b->openmin);
} else {
c->max = UINT_MAX;
c->openmax = 0;
}
c->integer = 0;
}
void interval_print(const interval_t *i, FILE *fp)
{
if (interval_empty(i))
fprintf(fp, "NONE");
else if (i->min == 0 && i->openmin == 0 &&
i->max == UINT_MAX && i->openmax == 0)
fprintf(fp, "ALL");
else if (interval_single(i))
fprintf(fp, "%u", interval_value(i));
else