diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2015-03-05 12:31:06 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2015-03-05 14:22:12 +0100 |
commit | 40f4daffd12b84dceb23942a992815e11b5a0839 (patch) | |
tree | 57b65ac9c830f114b127aa8431f9a53a6882dd65 | |
parent | 31a3e6c9f1462a7d76eddbceebac9fb9ceeef44e (diff) |
volume: Explicitly cast integers to doubles and then back to integers after multiplication
gcc 4.9.1 on ARM seems to have a bug that causes it to cast the float to an
integer first, resulting in a 0 scale factor for volume < 1.0.
As a side effect this change here will also improve accuracy of the result a
bit because we go via doubles instead of floats.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65325
https://bugzilla.gnome.org/show_bug.cgi?id=745667
-rw-r--r-- | gst/volume/gstvolume.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/gst/volume/gstvolume.c b/gst/volume/gstvolume.c index 0f5b362dd..94d03a316 100644 --- a/gst/volume/gstvolume.c +++ b/gst/volume/gstvolume.c @@ -250,10 +250,14 @@ volume_update_volume (GstVolume * self, const GstAudioInfo * info, self->current_mute = FALSE; self->current_volume = volume; - self->current_vol_i8 = volume * VOLUME_UNITY_INT8; - self->current_vol_i16 = volume * VOLUME_UNITY_INT16; - self->current_vol_i24 = volume * VOLUME_UNITY_INT24; - self->current_vol_i32 = volume * VOLUME_UNITY_INT32; + self->current_vol_i8 = + (gint) ((gdouble) volume * (gdouble) VOLUME_UNITY_INT8); + self->current_vol_i16 = + (gint) ((gdouble) volume * (gdouble) VOLUME_UNITY_INT16); + self->current_vol_i24 = + (gint) ((gdouble) volume * (gdouble) VOLUME_UNITY_INT24); + self->current_vol_i32 = + (gint) ((gdouble) volume * (gdouble) VOLUME_UNITY_INT32); passthrough = (self->current_vol_i16 == VOLUME_UNITY_INT16); } |