/* -*- c++ -*- */ /* * Copyright 2003,2005 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 2, 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, * Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include static const int MAX_BLOCK_SIZE = fusb_sysconfig::max_block_size(); static const int DEFAULT_BLOCK_SIZE = MAX_BLOCK_SIZE; static const int DEFAULT_BUFFER_SIZE = 16 * (1L << 20); // 16 MB / endpoint static const int USB_TIMEOUT = 1000; // in milliseconds fusb_devhandle_win32::fusb_devhandle_win32 (usb_dev_handle *udh) : fusb_devhandle (udh) { // that's it } fusb_devhandle_win32::~fusb_devhandle_win32 () { // nop } fusb_ephandle * fusb_devhandle_win32::make_ephandle (int endpoint, bool input_p, int block_size, int nblocks) { return new fusb_ephandle_win32 (this, endpoint, input_p, block_size, nblocks); } // ---------------------------------------------------------------- fusb_ephandle_win32::fusb_ephandle_win32 (fusb_devhandle_win32 *dh, int endpoint, bool input_p, int block_size, int nblocks) : fusb_ephandle (endpoint, input_p, block_size, nblocks), d_devhandle (dh), d_input_leftover(0),d_output_short(0) { if (d_block_size < 0 || d_block_size > MAX_BLOCK_SIZE) throw std::out_of_range ("fusb_ephandle_win32: block_size"); if (d_nblocks < 0) throw std::out_of_range ("fusb_ephandle_win32: nblocks"); if (d_block_size == 0) d_block_size = DEFAULT_BLOCK_SIZE; if (d_nblocks == 0) d_nblocks = std::max (1, DEFAULT_BUFFER_SIZE / d_block_size); d_buffer = new char [d_block_size*d_nblocks]; d_context = new void * [d_nblocks]; // allocate contexts usb_dev_handle *dev = dh->get_usb_dev_handle (); int i; if (d_input_p) endpoint |= USB_ENDPOINT_IN; for (i=0; i