3 * Copyright 2008 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
27 #define MSDD_DEBUG2_TRUE
29 #ifdef MSDD_DEBUG2_TRUE
31 #define MSDD_DEBUG2(x) std::cout << x << std::endl;
33 #define MSDD_DEBUG2(x)
36 #include <msdd_source_s.h>
37 #include <gr_io_signature.h>
40 static const int NBASIC_SAMPLES_PER_ITEM = 1;
44 msdd_make_source_s (int which_board,
45 unsigned int decim_rate,
46 unsigned int fft_points,
47 double initial_rx_freq,
50 unsigned short port_src
51 ) throw (std::runtime_error)
53 return msdd_source_s_sptr (new msdd_source_s (which_board,
64 msdd_source_s::msdd_source_s (int which_board,
65 unsigned int decim_rate,
66 unsigned int fft_points,
67 double initial_rx_freq,
70 unsigned short port_src
71 ) throw (std::runtime_error)
72 : msdd_source_base ("msdd_source_s",
73 gr_make_io_signature (1, 1, sizeof (int)),
74 which_board, opp_mode, src, port_src
78 switch (sizeof_basic_sample()) {
80 d_buffer_copy_behavior.reset(
81 new msdd::BufferCopyBehaviorGeneric<short, unsigned char>());
84 d_buffer_copy_behavior.reset(
85 new msdd::BufferCopyBehaviorGeneric<short, float>());
88 d_buffer_copy_behavior.reset(
89 new msdd::BufferCopyBehaviorGeneric<short, int>());
97 msdd_source_s::~msdd_source_s ()
102 msdd_source_s::ninput_bytes_reqd_for_noutput_items (int noutput_items)
104 return noutput_items * NBASIC_SAMPLES_PER_ITEM * sizeof_basic_sample();
108 msdd_source_s::copy_from_msdd_buffer (gr_vector_void_star &output_items,
110 int output_items_available,
111 int &output_items_produced,
112 const void *msdd_buffer,
116 MSDD_DEBUG2("copy_from_msdd_buffer: output_index: " << output_index << " output_items_available: " << output_items_available << " buflen: " << buffer_length)
118 unsigned nmsdd_bytes_per_item
119 (msdd_source_s::ninput_bytes_reqd_for_noutput_items(1));
121 unsigned int nitems = std::min (output_items_available,
122 (int)(buffer_length / nmsdd_bytes_per_item));
124 MSDD_DEBUG2("copy_from_msdd_buffer: nmsdd_bytes_per_item: " << nmsdd_bytes_per_item << " nitems: " << nitems)
126 (*d_buffer_copy_behavior.get())(output_items, msdd_buffer, output_index, nitems);
128 output_items_produced = nitems;
129 bytes_read = nitems * nmsdd_bytes_per_item;