diff options
Diffstat (limited to 'gr-audio/lib/alsa/audio_alsa_source.cc')
-rw-r--r-- | gr-audio/lib/alsa/audio_alsa_source.cc | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/gr-audio/lib/alsa/audio_alsa_source.cc b/gr-audio/lib/alsa/audio_alsa_source.cc index a90552ff5..9fdf80b43 100644 --- a/gr-audio/lib/alsa/audio_alsa_source.cc +++ b/gr-audio/lib/alsa/audio_alsa_source.cc @@ -1,19 +1,19 @@ /* -*- c++ -*- */ /* * Copyright 2004-2011 Free Software Foundation, Inc. - * + * * This file is part of GNU Radio - * + * * GNU Radio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. - * + * * GNU Radio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with GNU Radio; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, @@ -50,7 +50,7 @@ static snd_pcm_format_t acceptable_formats[] = { #define NELEMS(x) (sizeof(x)/sizeof(x[0])) -static std::string +static std::string default_device_name () { return gr_prefs::singleton()->get_string("audio_alsa", "default_input_device", "hw:0,0"); @@ -127,10 +127,10 @@ audio_alsa_source::audio_alsa_source (int sampling_rate, min_chan = 1; d_special_case_stereo_to_mono = true; } - + set_output_signature (gr_make_io_signature (min_chan, max_chan, sizeof (float))); - + // fill in portions of the d_hw_params that we know now... // Specify the access methods we implement @@ -155,14 +155,14 @@ audio_alsa_source::audio_alsa_source (int sampling_rate, "audio_alsa_source", CHATTY_DEBUG)) throw std::runtime_error ("audio_alsa_source"); - + // sampling rate unsigned int orig_sampling_rate = d_sampling_rate; if ((error = snd_pcm_hw_params_set_rate_near (d_pcm_handle, d_hw_params, &d_sampling_rate, 0)) < 0) bail ("failed to set rate near", error); - + if (orig_sampling_rate != d_sampling_rate){ fprintf (stderr, "audio_alsa_source[%s]: unable to support sampling rate %d\n", snd_pcm_name (d_pcm_handle), orig_sampling_rate); @@ -204,7 +204,7 @@ audio_alsa_source::audio_alsa_source (int sampling_rate, &d_period_size, &dir); if (error < 0) bail ("get_period_size failed", error); - + set_output_multiple (d_period_size); } @@ -309,7 +309,7 @@ audio_alsa_source::work_s16 (int noutput_items, { typedef gr_int16 sample_t; // the type of samples we're creating 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]; sample_t *buf = (sample_t *) d_buffer; @@ -321,7 +321,7 @@ audio_alsa_source::work_s16 (int noutput_items, // To minimize latency, return at most a single period's worth of samples. // [We could also read the first one in a blocking mode and subsequent // ones in non-blocking mode, but we'll leave that for later (or never).] - + if (!read_buffer (buf, d_period_size, sizeof_frame)) return -1; // No fixing this problem. Say we're done. @@ -347,7 +347,7 @@ audio_alsa_source::work_s16_2x1 (int noutput_items, { typedef gr_int16 sample_t; // the type of samples we're creating static const float scale_factor = 1.0 / std::pow(2.0f, 16-1); - + float **out = (float **) &output_items[0]; sample_t *buf = (sample_t *) d_buffer; int bi; @@ -360,7 +360,7 @@ audio_alsa_source::work_s16_2x1 (int noutput_items, // To minimize latency, return at most a single period's worth of samples. // [We could also read the first one in a blocking mode and subsequent // ones in non-blocking mode, but we'll leave that for later (or never).] - + if (!read_buffer (buf, d_period_size, sizeof_frame)) return -1; // No fixing this problem. Say we're done. @@ -385,7 +385,7 @@ audio_alsa_source::work_s32 (int noutput_items, { typedef gr_int32 sample_t; // the type of samples we're creating 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]; sample_t *buf = (sample_t *) d_buffer; @@ -397,7 +397,7 @@ audio_alsa_source::work_s32 (int noutput_items, // To minimize latency, return at most a single period's worth of samples. // [We could also read the first one in a blocking mode and subsequent // ones in non-blocking mode, but we'll leave that for later (or never).] - + if (!read_buffer (buf, d_period_size, sizeof_frame)) return -1; // No fixing this problem. Say we're done. @@ -423,7 +423,7 @@ audio_alsa_source::work_s32_2x1 (int noutput_items, { typedef gr_int32 sample_t; // the type of samples we're creating static const float scale_factor = 1.0 / std::pow(2.0f, 32-1); - + float **out = (float **) &output_items[0]; sample_t *buf = (sample_t *) d_buffer; int bi; @@ -436,7 +436,7 @@ audio_alsa_source::work_s32_2x1 (int noutput_items, // To minimize latency, return at most a single period's worth of samples. // [We could also read the first one in a blocking mode and subsequent // ones in non-blocking mode, but we'll leave that for later (or never).] - + if (!read_buffer (buf, d_period_size, sizeof_frame)) return -1; // No fixing this problem. Say we're done. |