Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

VrBuffer.h

Go to the documentation of this file.
00001 /* -*- Mode: c++ -*- */ 00002 /* 00003 * Copyright 2001 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00020 * Boston, MA 02111-1307, USA. 00021 */ 00022 /* 00023 * Copyright 1997 Massachusetts Institute of Technology 00024 * 00025 * Permission to use, copy, modify, distribute, and sell this software and its 00026 * documentation for any purpose is hereby granted without fee, provided that 00027 * the above copyright notice appear in all copies and that both that 00028 * copyright notice and this permission notice appear in supporting 00029 * documentation, and that the name of M.I.T. not be used in advertising or 00030 * publicity pertaining to distribution of the software without specific, 00031 * written prior permission. M.I.T. makes no representations about the 00032 * suitability of this software for any purpose. It is provided "as is" 00033 * without express or implied warranty. 00034 * 00035 */ 00036 00037 #ifndef _VRBUFFER_H_ 00038 #define _VRBUFFER_H_ 00039 #include "VrTypes.h" 00040 00041 extern int BufferSizeMultiplier; 00042 class VrConnect; 00043 class VrSigProc; 00044 00045 class VrBuffer { 00046 protected: 00047 //duplicate start = end of unique + 1 = start + bufferSize 00048 char* bufferDupStart; 00049 unsigned int bufferSize; // size in items. = bufferDupStart - buffer start 00050 unsigned int type_size; // size of 1 unit of data 00051 VrSampleIndex WPdupstart; // VrSampleIndex at bufferDupStart 00052 MUTEX_DECLARE(dupstartlock); 00053 VrSampleIndex minRP; // hint; <= min_i(connectors[i]->minRP) -- updated rarely 00054 VrSigProc* upstream; // who writes to this buffer 00055 VrConnect ** connectors; // who reads from this buffer 00056 unsigned int numberConnectors; // how many of above 00057 unsigned int setupCalled; // count of how many setup requests we've received 00058 virtual void allocateBuffer(unsigned int arg_type_size); 00059 00060 public: 00061 unsigned int buffersize() { return bufferSize; }; 00062 unsigned int getNumberConnectors() { return numberConnectors; } 00063 // Add c as a reader of this buffer 00064 void connect_buffer(VrConnect *c); 00065 double buffer_getSamplingFrequency(); 00066 VrSigProc* getUpstreamModule() {return upstream;} 00067 //Called once from upstream module 00068 void setup(unsigned int arg_type_size); 00069 //recompute the hint minRP 00070 VrSampleIndex updateMinRP(); 00071 00072 //returns how much space will be left if the write pointer is updated to WP 00073 // if >0, write can proceed 00074 int writespace(VrSampleIndex WP) { 00075 int s = bufferSize - (WP - minRP); 00076 if(s <= 0) 00077 updateMinRP(); 00078 s = bufferSize - (WP - minRP); 00079 return s; 00080 } 00081 00082 //called from the upstream VrSigProc (in prepareRead) 00083 char *getWritePointer(VrSampleRange r); 00084 //called from a downstream VrSigProc, via VrConnect 00085 virtual char *getReadPointer(VrSampleRange r); 00086 VrBuffer(VrSigProc *m); 00087 virtual ~VrBuffer() { }; 00088 }; 00089 #define PAGE_SIZE getpagesize() 00090 #endif

Generated on Wed Aug 4 02:22:05 2004 for GNU Radio by doxygen 1.3.8