00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
#ifndef _VRSINK_H_
00038
#define _VRSINK_H_
00039
00040
#include <VrSigProc.h>
00041
00042
template<
class iType>
00043 class VrSink :
public VrSigProc {
00044
private:
00045 unsigned int optimalSize;
00046
00047
public:
00048 virtual const char *
name() {
return "VrSink"; }
00049
00050
00051
00052 void setOptimalSize(
unsigned int s) { optimalSize = s;}
00053
00054
virtual void setup();
00055
void setup_upstream();
00056
00057 virtual int work(
VrSampleRange output,
void *o[],
00058
VrSampleRange inputs[],
void *i[]) {
00059
return work3 (output, inputs, i);
00060 };
00061
00062
virtual int work3(
VrSampleRange output,
00063
VrSampleRange inputs[],
void *i[]) = 0;
00064
00065 VrSink() :
VrSigProc(0, sizeof(
iType), 0),
00066 optimalSize(0x70000000){ }
00067 };
00068
00069
template <
class iType>
void
00070 VrSink<iType>::setup()
00071 {
00072
VrSink<iType>::setup_upstream();
00073 }
00074
00075
template <
class iType>
void
00076 VrSink<iType>::setup_upstream()
00077 {
00078
float m =
memoryTouched();
00079
00080
00081
00082
unsigned int cachedSize = (
int) (
cacheSize * (
getSamplingFrequency() / m));
00083
00084 fprintf(stderr,
"%s cachedSize = %d\n",
name(),cachedSize);
00085
if(cachedSize/
getSamplingFrequency() >
maxLatency) {
00086 fprintf(stderr,
" reducing latency from %f",cachedSize/
getSamplingFrequency());
00087 cachedSize = (
unsigned int) (
getSamplingFrequency() *
maxLatency);
00088 fprintf(stderr,
" to %f seconds\n",cachedSize/
getSamplingFrequency());
00089 }
00090
if(
optimalSize < cachedSize) {
00091 fprintf(stderr,
" manually specified optimalSize of %d (%f sec)\n",
optimalSize,
optimalSize/
getSamplingFrequency());
00092 cachedSize=
optimalSize;
00093 }
00094
00095
if((cachedSize %
getOutputSize()) != 0) {
00096 cachedSize = (cachedSize/
getOutputSize()) *
getOutputSize();
00097 }
00098
if(cachedSize==0) cachedSize=
getOutputSize();
00099 maxDSReadSize=
optimalSize=cachedSize;
00100
00101
VrSigProc::setup_upstream();
00102 }
00103
00104
#endif
00105