summaryrefslogtreecommitdiff
path: root/gr-audio
diff options
context:
space:
mode:
authorTom Rondeau2011-10-25 14:03:49 -0400
committerTom Rondeau2011-10-25 14:03:49 -0400
commit26a1eb1854896ec0181a417a13dea6b24949ad01 (patch)
tree827caf2c32b64594cd293fe5b3a1b99651aac48a /gr-audio
parent64afdec6d5db9f85c5db0a923d6fc3f54441e74f (diff)
parent334f45e5599fd816d614a4b2a3092b0ac2d2904e (diff)
downloadgnuradio-26a1eb1854896ec0181a417a13dea6b24949ad01.tar.gz
gnuradio-26a1eb1854896ec0181a417a13dea6b24949ad01.tar.bz2
gnuradio-26a1eb1854896ec0181a417a13dea6b24949ad01.zip
Merge branch 'upstream/alsa-source-warning-fix' into maint
Diffstat (limited to 'gr-audio')
-rw-r--r--gr-audio/lib/alsa/audio_alsa_source.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/gr-audio/lib/alsa/audio_alsa_source.cc b/gr-audio/lib/alsa/audio_alsa_source.cc
index 2f4506f71..08d4996a8 100644
--- a/gr-audio/lib/alsa/audio_alsa_source.cc
+++ b/gr-audio/lib/alsa/audio_alsa_source.cc
@@ -308,7 +308,7 @@ audio_alsa_source::work_s16 (int noutput_items,
gr_vector_void_star &output_items)
{
typedef gr_int16 sample_t; // the type of samples we're creating
- static const int NBITS = 16; // # of bits in a sample
+ static const float scale_factor = 1.0 / std::pow(2.0f, 16-1);
unsigned int nchan = output_items.size ();
float **out = (float **) &output_items[0];
@@ -329,7 +329,7 @@ audio_alsa_source::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++){
- out[chan][i] = (float) buf[bi++] * (1.0 / (float) ((1L << (NBITS-1)) - 1));
+ out[chan][i] = (float) buf[bi++] * scale_factor;
}
}
@@ -346,7 +346,7 @@ audio_alsa_source::work_s16_2x1 (int noutput_items,
gr_vector_void_star &output_items)
{
typedef gr_int16 sample_t; // the type of samples we're creating
- static const int NBITS = 16; // # of bits in a sample
+ static const float scale_factor = 1.0 / std::pow(2.0f, 16-1);
unsigned int nchan = output_items.size ();
float **out = (float **) &output_items[0];
@@ -370,7 +370,7 @@ audio_alsa_source::work_s16_2x1 (int noutput_items,
for (unsigned int i = 0; i < d_period_size; i++){
int t = (buf[bi] + buf[bi+1]) / 2;
bi += 2;
- out[0][i] = (float) t * (1.0 / (float) ((1L << (NBITS-1)) - 1));
+ out[0][i] = (float) t * scale_factor;
}
return d_period_size;
@@ -385,7 +385,7 @@ audio_alsa_source::work_s32 (int noutput_items,
gr_vector_void_star &output_items)
{
typedef gr_int32 sample_t; // the type of samples we're creating
- static const int NBITS = 32; // # of bits in a sample
+ static const float scale_factor = 1.0 / std::pow(2.0f, 32-1);
unsigned int nchan = output_items.size ();
float **out = (float **) &output_items[0];
@@ -406,7 +406,7 @@ audio_alsa_source::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++){
- out[chan][i] = (float) buf[bi++] * (1.0 / (float) ((1L << (NBITS-1)) - 1));
+ out[chan][i] = (float) buf[bi++] * scale_factor;
}
}
@@ -423,7 +423,7 @@ audio_alsa_source::work_s32_2x1 (int noutput_items,
gr_vector_void_star &output_items)
{
typedef gr_int32 sample_t; // the type of samples we're creating
- static const int NBITS = 32; // # of bits in a sample
+ static const float scale_factor = 1.0 / std::pow(2.0f, 32-1);
unsigned int nchan = output_items.size ();
float **out = (float **) &output_items[0];
@@ -447,7 +447,7 @@ audio_alsa_source::work_s32_2x1 (int noutput_items,
for (unsigned int i = 0; i < d_period_size; i++){
int t = (buf[bi] + buf[bi+1]) / 2;
bi += 2;
- out[0][i] = (float) t * (1.0 / (float) ((1L << (NBITS-1)) - 1));
+ out[0][i] = (float) t * scale_factor;
}
return d_period_size;