From: Philip Balister <phi...@opensdr.com> On machines where sizeof(long) = sizeof(int) the code for calculating scale factors produced an overflow warning. This change simplifies the code by eliminating the shift. The compiler should calculate the constant at compile time anyway.
Signed-off-by: Philip Balister <phi...@opensdr.com> --- gr-audio/lib/alsa/audio_alsa_sink.cc | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gr-audio/lib/alsa/audio_alsa_sink.cc b/gr-audio/lib/alsa/audio_alsa_sink.cc index 5fd197e..2aa6fc0 100644 --- a/gr-audio/lib/alsa/audio_alsa_sink.cc +++ b/gr-audio/lib/alsa/audio_alsa_sink.cc @@ -343,7 +343,7 @@ audio_alsa_sink::work_s16 (int noutput_items, bi = 0; for (unsigned int i = 0; i < d_period_size; i++){ for (unsigned int chan = 0; chan < nchan; chan++){ - buf[bi++] = (sample_t) (in[chan][i] * (float) ((1L << (NBITS-1)) - 1)); + buf[bi++] = (sample_t) (in[chan][i] * ((2^(NBITS-1)) - 1)); } } @@ -385,7 +385,7 @@ audio_alsa_sink::work_s32 (int noutput_items, bi = 0; for (unsigned int i = 0; i < d_period_size; i++){ for (unsigned int chan = 0; chan < nchan; chan++){ - buf[bi++] = (sample_t) (in[chan][i] * (float) ((1L << (NBITS-1)) - 1)); + buf[bi++] = (sample_t) (in[chan][i] * ((2^(NBITS-1)) - 1)); } } @@ -427,7 +427,7 @@ audio_alsa_sink::work_s16_1x2 (int noutput_items, // process one period of data bi = 0; for (unsigned int i = 0; i < d_period_size; i++){ - sample_t t = (sample_t) (in[0][i] * (float) ((1L << (NBITS-1)) - 1)); + sample_t t = (sample_t) (in[0][i] * ((2^(NBITS-1)) - 1)); buf[bi++] = t; buf[bi++] = t; } @@ -469,7 +469,7 @@ audio_alsa_sink::work_s32_1x2 (int noutput_items, // process one period of data bi = 0; for (unsigned int i = 0; i < d_period_size; i++){ - sample_t t = (sample_t) (in[0][i] * (float) ((1L << (NBITS-1)) - 1)); + sample_t t = (sample_t) (in[0][i] * ((2^(NBITS-1)) - 1)); buf[bi++] = t; buf[bi++] = t; } -- 1.7.6.4 _______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio