mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-05 13:30:00 -05:00
a bit reordered code to fix bug #838
This commit is contained in:
parent
02b6b9f616
commit
ff9fd33190
1 changed files with 10 additions and 8 deletions
|
|
@ -221,20 +221,22 @@ static int get_compare_weight(const char *name, unsigned int idx)
|
|||
|
||||
static long to_user(selem_t *s, int dir, selem_ctl_t *c, long value)
|
||||
{
|
||||
int64_t n;
|
||||
if (c->max == c->min)
|
||||
if (c->max == c->min) {
|
||||
return s->str[dir].min;
|
||||
n = (int64_t) (value - c->min) * (s->str[dir].max - s->str[dir].min);
|
||||
return s->str[dir].min + (n + (c->max - c->min) / 2) / (c->max - c->min);
|
||||
} else {
|
||||
int64_t n = (int64_t) (value - c->min) * (s->str[dir].max - s->str[dir].min);
|
||||
return s->str[dir].min + (n + (c->max - c->min) / 2) / (c->max - c->min);
|
||||
}
|
||||
}
|
||||
|
||||
static long from_user(selem_t *s, int dir, selem_ctl_t *c, long value)
|
||||
{
|
||||
int64_t n;
|
||||
if (s->str[dir].max == s->str[dir].min)
|
||||
if (s->str[dir].max == s->str[dir].min) {
|
||||
return c->min;
|
||||
n = (int64_t) (value - s->str[dir].min) * (c->max - c->min);
|
||||
return c->min + (n + (s->str[dir].max - s->str[dir].min) / 2) / (s->str[dir].max - s->str[dir].min);
|
||||
} else {
|
||||
int64_t n = (int64_t) (value - s->str[dir].min) * (c->max - c->min);
|
||||
return c->min + (n + (s->str[dir].max - s->str[dir].min) / 2) / (s->str[dir].max - s->str[dir].min);
|
||||
}
|
||||
}
|
||||
|
||||
static int elem_read_volume(selem_t *s, int dir, selem_ctl_type_t type)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue