00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _GEDDEI_XLCONNECTION_H
00012 #define _GEDDEI_XLCONNECTION_H
00013
00014 #ifdef __GEDDEI_BUILD
00015 #include "connection.h"
00016 #include "bufferdata.h"
00017 #include "bufferreader.h"
00018 #include "signaltyperef.h"
00019 #else
00020 #include <geddei/connection.h>
00021 #include <geddei/bufferdata.h>
00022 #include <geddei/bufferreader.h>
00023 #include <geddei/signaltyperef.h>
00024 #endif
00025 using namespace Geddei;
00026
00027 namespace Geddei
00028 {
00029
00030 class Sink;
00031
00048 class xLConnection: virtual public Connection
00049 {
00050 friend class Processor;
00051 friend class DomProcessor;
00052
00053 protected:
00054 Sink *theSink;
00055 uint theSinkIndex;
00056
00064 virtual void reset() = 0;
00065
00075 virtual void sinkStopping() = 0;
00076
00086 virtual void sinkStopped() = 0;
00087
00103 virtual const bool plungeSync(const uint samples) const = 0;
00104
00115 virtual const uint elementsReady() const = 0;
00116
00123 virtual void waitForElements(const uint elements) const = 0;
00124
00144 virtual const BufferData readElements(const uint elements) = 0;
00145
00164 virtual const BufferData peekElements(const uint elements) = 0;
00165
00174 virtual void killReader() = 0;
00175
00184 virtual void resurectReader() = 0;
00185
00192 virtual BufferReader *newReader() = 0;
00193
00197 xLConnection(Sink *newSink, const uint newSinkIndex);
00198
00199 public:
00205 virtual const SignalTypeRef type() { return SignalTypeRef(theType); }
00206
00218 void waitForSamples(const uint samples = 1) const { waitForElements(theType->elementsFromSamples(samples)); }
00219
00234 const uint samplesReady() const { return theType->samples(elementsReady()); }
00235
00248 const BufferData readSample() { return readElements(theType->elementsFromSamples(1)); }
00249
00277 const BufferData readSamples(const uint samples = 0, const bool allowZero = false) { if(!allowZero && !samples) while(!samplesReady()) plungeSync(1); return readElements(theType->elementsFromSamples(samples ? samples : samplesReady())); }
00278
00291 const BufferData readSecond() { return readElements(theType->elementsFromSeconds(1.)); }
00292
00306 const BufferData readSeconds(const float seconds) { return readElements(theType->elementsFromSeconds(seconds)); }
00307
00316 const BufferData peekSample() { return peekElements(theType->elementsFromSamples(1)); }
00317
00340 const BufferData peekSamples(const uint samples = 0, const bool allowZero = false) { if(!allowZero && !samples) while(samplesReady() < 1) plungeSync(1); return peekElements(theType->elementsFromSamples(samples ? samples : samplesReady())); }
00341
00350 const BufferData peekSecond() { return peekElements(theType->elementsFromSeconds(1.)); }
00351
00361 const BufferData peekSeconds(const float seconds) { return peekElements(theType->elementsFromSeconds(seconds)); }
00362
00369 virtual const uint capacity() const = 0;
00370
00377 virtual const float filled() const { return 0.; }
00378
00382 virtual ~xLConnection();
00383
00384 };
00385
00386 }
00387
00388 #endif