Downgrade volume computations to float (from double)

Although we lose precision, this is still enough for computing relative,
absolute and RAOP volume and will make a difference on embedded CPUs.
This commit is contained in:
Julien BLACHE 2010-12-04 16:15:49 +01:00
parent 4ac75a316a
commit 02ea6f4823
2 changed files with 8 additions and 8 deletions

View File

@ -257,12 +257,12 @@ status_update(enum play_status status)
static int static int
rel_to_vol(int relvol) rel_to_vol(int relvol)
{ {
double vol; float vol;
if (relvol == 100) if (relvol == 100)
return master_volume; return master_volume;
vol = ((double)relvol * (double)master_volume) / 100.0; vol = ((float)relvol * (float)master_volume) / 100.0;
return (int)vol; return (int)vol;
} }
@ -270,12 +270,12 @@ rel_to_vol(int relvol)
static int static int
vol_to_rel(int volume) vol_to_rel(int volume)
{ {
double rel; float rel;
if (volume == master_volume) if (volume == master_volume)
return 100; return 100;
rel = ((double)volume / (double)master_volume) * 100.0; rel = ((float)volume / (float)master_volume) * 100.0;
return (int)rel; return (int)rel;
} }

View File

@ -1667,10 +1667,10 @@ raop_session_failure_cb(struct evrtsp_request *req, void *arg)
/* Volume handling */ /* Volume handling */
static double static float
raop_volume_convert(int volume) raop_volume_convert(int volume)
{ {
double raop_volume; float raop_volume;
/* RAOP volume /* RAOP volume
* -144.0 is off * -144.0 is off
@ -1681,7 +1681,7 @@ raop_volume_convert(int volume)
if (volume == 0) if (volume == 0)
raop_volume = 144.0; raop_volume = 144.0;
else else
raop_volume = 30.0 - ((double)volume * 30.0) / 100.0; raop_volume = 30.0 - ((float)volume * 30.0) / 100.0;
return raop_volume; return raop_volume;
} }
@ -1690,7 +1690,7 @@ static int
raop_set_volume_internal(struct raop_session *rs, int volume, evrtsp_req_cb cb) raop_set_volume_internal(struct raop_session *rs, int volume, evrtsp_req_cb cb)
{ {
struct evbuffer *evbuf; struct evbuffer *evbuf;
double raop_volume; float raop_volume;
int ret; int ret;
evbuf = evbuffer_new(); evbuf = evbuffer_new();