nail down a lot of OutputSlot implementation details

This commit is contained in:
Fischlurch 2011-11-08 02:59:56 +01:00
parent 59dfb7c660
commit f75e55a060
8 changed files with 105 additions and 33 deletions

View file

@ -83,6 +83,7 @@ namespace engine {
virtual uint announce (uint count, BufferDescriptor const&) =0;
virtual BuffHandle lockBufferFor (BufferDescriptor const&) =0;
virtual void mark_emitted (BuffHandle const&) =0;
virtual void releaseBuffer (BuffHandle const&) =0;
template<typename BU>

View file

@ -78,10 +78,17 @@ namespace engine {
}
void
TrackingHeapBlockProvider::mark_emitted (BuffHandle const& handle)
{
UNIMPLEMENTED ("commit a buffer to the protocol section");
}
void
TrackingHeapBlockProvider::releaseBuffer (BuffHandle const& handle)
{
UNIMPLEMENTED ("release a buffer and invalidate the handle");
UNIMPLEMENTED ("mark a buffer as officially discarded");
}

View file

@ -117,6 +117,7 @@ namespace engine {
virtual uint announce (uint count, BufferDescriptor const& type);
virtual BuffHandle lockBufferFor (BufferDescriptor const& descriptor);
virtual void mark_emitted (BuffHandle const& handle);
virtual void releaseBuffer (BuffHandle const& handle);
public:

View file

@ -59,7 +59,7 @@
namespace proc {
namespace play {
//using ::engine::BuffHandle;
using ::engine::BuffHandle;
//using ::engine::BufferProvider;
//using lib::time::Time;
//using std::string;
@ -98,9 +98,12 @@ namespace play {
public:
virtual ~Connection();
virtual void lock (FrameID) =0;
virtual void transfer (FrameID) =0;
virtual void pushout (FrameID) =0;
virtual BuffHandle claimBufferFor(FrameID) =0;
virtual bool isTimely (FrameID, TimeValue) =0;
virtual void transfer (BuffHandle const&) =0;
virtual void pushout (BuffHandle const&) =0;
virtual void discard (BuffHandle const&) =0;
virtual void shutDown () =0;
};
@ -164,19 +167,24 @@ namespace play {
public:
ConnectionStateManager()
{
UNIMPLEMENTED ("immediately build up the necessary number of connections");
}
virtual
~ConnectionStateManager()
{
UNIMPLEMENTED ("shut down all connections");
}
{ }
virtual
CON
buildConnection() =0;
~ConnectionStateManager()
{ }
void
init (uint numChannels)
{
for (uint i=0; i<numChannels; ++i)
push_back(buildConnection());
}
/** factory function to build the actual
* connection handling objects per channel */
virtual CON buildConnection() =0;
private: // Implementation details
@ -190,10 +198,10 @@ namespace play {
}
static void
shutdownConnection (void* toClose)
shutdownConnection (OutputSlot::Connection* toClose)
{
///////////////////////////////////////////////////////////TODO problem: is it possible to pass the concrete type????
UNIMPLEMENTED ("how to mark a connection as closed");
REQUIRE (toClose);
toClose->shutDown();
}
};

View file

@ -51,6 +51,8 @@ namespace play {
OutputSlot::Allocation::~Allocation() { }
OutputSlot::Connection::~Connection() { }
@ -86,6 +88,28 @@ namespace play {
if (!isFree())
state_.reset(0);
}
/* === DataSink frontend === */
BuffHandle
DataSink::lockBufferFor(FrameID frameNr)
{
return impl().claimBufferFor(frameNr);
}
void
DataSink::emit (FrameID frameNr, BuffHandle const& data2emit, TimeValue currentTime)
{
OutputSlot::Connection& connection = impl();
if (connection.isTimely(frameNr,currentTime))
connection.transfer(data2emit);
else
connection.discard(data2emit);
}

View file

@ -38,7 +38,7 @@
#include "lib/error.hpp"
#include "lib/handle.hpp"
//#include "lib/time/timevalue.hpp"
#include "lib/time/timevalue.hpp"
#include "proc/engine/buffer-provider.hpp"
#include "proc/play/timings.hpp"
#include "lib/iter-source.hpp"
@ -56,7 +56,7 @@ namespace play {
using ::engine::BuffHandle;
using ::engine::BufferProvider;
//using lib::time::Time;
using lib::time::TimeValue;
//using std::string;
//using std::vector;
@ -132,7 +132,7 @@ namespace play {
public:
BuffHandle lockBufferFor(FrameID);
void emit(FrameID);
void emit(FrameID, BuffHandle const&, TimeValue currentTime = Time::MAX); ///////////////TICKET #855
};

View file

@ -72,25 +72,47 @@ namespace play {
/* === Connection API === */
void
lock (FrameID)
BuffHandle
claimBufferFor(FrameID frameNr)
{
buffProvider_->lockBufferFor (bufferType_);
/////////////////////////////////////////////////TODO: should return that
}
bool
isTimely (FrameID frameNr, TimeValue currentTime)
{
if (Time::MAX == currentTime)
return true;
UNIMPLEMENTED ("find out about timings");
return false;
}
void
transfer (FrameID frameNr)
transfer (BuffHandle const& filledBuffer)
{
pushout (frameNr);
pushout (filledBuffer);
}
void
pushout (FrameID)
pushout (BuffHandle const& data4output)
{
UNIMPLEMENTED ("simulate output");
buffProvider_->mark_emitted (data4output);
buffProvider_->releaseBuffer (data4output);
}
void
discard (BuffHandle const& superseededData)
{
buffProvider_->releaseBuffer (superseededData);
}
void
shutDown ()
{
buffProvider_.reset();
}
public:
TrackingInMemoryBlockSequence()
@ -117,6 +139,12 @@ namespace play {
{
return TrackingInMemoryBlockSequence();
}
public:
SimulatedOutputSequences (uint numChannels)
{
init (numChannels);
}
};
@ -131,11 +159,14 @@ namespace play {
class DiagnosticOutputSlot
: public OutputSlot
{
static const uint MAX_CHANNELS = 5;
/* === hook into the OutputSlot frontend === */
ConnectionState*
buildState()
{
return new SimulatedOutputSequences();
return new SimulatedOutputSequences(MAX_CHANNELS);
}

View file

@ -106,9 +106,9 @@ namespace test {
buff10.accessAs<TestFrame>() = testData(1,0);
// Now it's time to emit the output
sink2.emit (frameNr-1);
sink2.emit (frameNr );
sink1.emit (frameNr-1);
sink2.emit (frameNr-1, buff10);
sink2.emit (frameNr , buff11);
sink1.emit (frameNr-1, buff00);
// that's all for the client
// Verify sane operation....