implement basics of the diagnostic OutputSlot
...specific diagnostic facilities still lacking
This commit is contained in:
parent
07002ab3af
commit
aef3d50ffd
9 changed files with 97 additions and 28 deletions
|
|
@ -21,7 +21,7 @@
|
|||
*/
|
||||
|
||||
/** @file multifact.hpp
|
||||
** Building blocks of a configurable factory, generating families of related objects.
|
||||
** Building blocks to create a configurable factory, generating families of related objects.
|
||||
** Serving the "classical" factory situation: obtaining objects of various kinds, which
|
||||
** are related somehow (usually through an common interface). The creation of these
|
||||
** objects is non-trivial while number and exact parametrisation aren't known beforehand
|
||||
|
|
@ -70,7 +70,7 @@
|
|||
namespace lib {
|
||||
namespace factory {
|
||||
|
||||
//////TODO: couldn't these wrappers be extracted into a separate header?
|
||||
/////////////////////////////////TICKET #470 : couldn't these wrappers be extracted into a separate header?
|
||||
|
||||
/**
|
||||
* Dummy "wrapper",
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
** This extension is mostly helpful for writing unit-tests, and beyond that for the
|
||||
** rather unusual case where we need to place an full-blown object into the buffer,
|
||||
** instead of just plain data. A possible use case for this mechanism is to allow for
|
||||
** state pre calculation stream, feeding this local state to the individual render node
|
||||
** state per calculation stream, feeding this local state to the individual render node
|
||||
** embedded into a "state frame". Some effect processors indeed need to maintain state
|
||||
** beyond the single frame (e.g. averaging, integrating, sound compression), which usually
|
||||
** is handled by applying an "instance" of that processor to the frames to be calculated
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
*/
|
||||
|
||||
/** @file diagnostic-buffer-provider.hpp
|
||||
** An facility for writing unit-tests targeting the BufferProvider interface.
|
||||
** A facility for writing unit-tests targeting the BufferProvider interface.
|
||||
**
|
||||
** @see buffer-provider-protocol-test.cpp
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ namespace engine {
|
|||
TrackingHeapBlockProvider::locateBlock (HashVal typeID, void* storage)
|
||||
{
|
||||
diagn::BlockPool& pool = getBlockPoolFor (typeID);
|
||||
diagn::Block* block4buffer = pool.find (storage);
|
||||
diagn::Block* block4buffer = pool.find (storage); ////////////////////////////////TICKET #856
|
||||
return block4buffer? block4buffer
|
||||
: searchInOutSeqeuence (storage);
|
||||
}
|
||||
|
|
@ -317,7 +317,7 @@ namespace engine {
|
|||
diagn::Block*
|
||||
TrackingHeapBlockProvider::searchInOutSeqeuence (void* blockLocation)
|
||||
{
|
||||
return pick_Block_by_storage (outSeq_, blockLocation);
|
||||
return pick_Block_by_storage (outSeq_, blockLocation); ////////////////////////////////TICKET #856
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ namespace engine {
|
|||
|
||||
|
||||
/**
|
||||
* Helper for a diagnostic BufferProvider:
|
||||
* Helper for implementing a diagnostic BufferProvider:
|
||||
* A block of heap allocated storage, with the capability
|
||||
* to store some additional tracking information.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
//#include <string>
|
||||
//#include <vector>
|
||||
#include <vector>
|
||||
//#include <tr1/memory>
|
||||
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ namespace play {
|
|||
using lib::transform;
|
||||
using lib::iter_stl::eachElm;
|
||||
|
||||
//using std::vector;
|
||||
using std::vector;
|
||||
//using std::tr1::shared_ptr;
|
||||
using boost::scoped_ptr;
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ namespace play {
|
|||
: public OutputSlot::ConnectionState
|
||||
, public vector<CON>
|
||||
{
|
||||
|
||||
typedef vector<CON> Connections;
|
||||
typedef OutputSlot::OpenedSinks OpenedSinks;
|
||||
|
||||
|
||||
|
|
@ -161,7 +161,7 @@ namespace play {
|
|||
bool
|
||||
isActive()
|
||||
{
|
||||
return 0 < vector<CON>::size();
|
||||
return 0 < Connections::size();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ namespace play {
|
|||
|
||||
protected:
|
||||
|
||||
/** Table to maintain connection state */
|
||||
/** active connections through this OutputSlot */
|
||||
class ConnectionState;
|
||||
|
||||
scoped_ptr<ConnectionState> state_;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@
|
|||
#include "proc/play/output-slot-connection.hpp"
|
||||
#include "proc/engine/buffhandle.hpp"
|
||||
#include "proc/engine/tracking-heap-block-provider.hpp"
|
||||
#include "lib/iter-source.hpp" ////////////TODO really going down that path...?
|
||||
#include "lib/scoped-ptrvect.hpp"
|
||||
#include "lib/iter-source.hpp"
|
||||
#include "proc/engine/testframe.hpp"
|
||||
//#include "lib/sync.hpp"
|
||||
|
||||
|
|
@ -55,6 +56,7 @@ namespace play {
|
|||
using proc::engine::BufferDescriptor;
|
||||
using proc::engine::test::TestFrame;
|
||||
using proc::engine::TrackingHeapBlockProvider;
|
||||
namespace diagn = proc::engine::diagn;
|
||||
|
||||
//using std::vector;
|
||||
using std::tr1::shared_ptr;
|
||||
|
|
@ -127,12 +129,34 @@ namespace play {
|
|||
{
|
||||
INFO (engine_dbg, "releasing diagnostic output sequence");
|
||||
}
|
||||
|
||||
|
||||
/* === Diagnostic API === */
|
||||
|
||||
TestFrame*
|
||||
accessEmittedFrame (uint frameNo) const
|
||||
{
|
||||
REQUIRE (buffProvider_);
|
||||
if (frameNo <= buffProvider_->emittedCnt())
|
||||
return &buffProvider_->accessAs<TestFrame> (frameNo);
|
||||
else
|
||||
return 0; ////////////////////////////////TICKET #856
|
||||
}
|
||||
|
||||
diagn::Block*
|
||||
accessEmittedBuffer (uint bufferNo) const
|
||||
{
|
||||
REQUIRE (buffProvider_);
|
||||
if (bufferNo <= buffProvider_->emittedCnt())
|
||||
return buffProvider_->access_emitted (bufferNo);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class SimulatedOutputSequences
|
||||
: public ConnectionStateManager<TrackingInMemoryBlockSequence>
|
||||
, boost::noncopyable
|
||||
{
|
||||
TrackingInMemoryBlockSequence
|
||||
buildConnection()
|
||||
|
|
@ -162,13 +186,28 @@ namespace play {
|
|||
|
||||
static const uint MAX_CHANNELS = 5;
|
||||
|
||||
/* === hook into the OutputSlot frontend === */
|
||||
/** hook into the OutputSlot frontend */
|
||||
ConnectionState*
|
||||
buildState()
|
||||
{
|
||||
return new SimulatedOutputSequences(MAX_CHANNELS);
|
||||
}
|
||||
|
||||
/** @internal is self-managed and non-copyable.
|
||||
* Clients use #build() to get an instance */
|
||||
DiagnosticOutputSlot() { }
|
||||
|
||||
/** @internal access the implementation object
|
||||
* representing a single stream connection
|
||||
*/
|
||||
TrackingInMemoryBlockSequence const&
|
||||
accessSequence (uint channel)
|
||||
{
|
||||
REQUIRE (!isFree(), "diagnostic OutputSlot not (yet) connected");
|
||||
REQUIRE (channel <= MAX_CHANNELS);
|
||||
return static_cast<SimulatedOutputSequences&> (*state_).at(channel);
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
/** build a new Diagnostic Output Slot instance,
|
||||
|
|
@ -177,50 +216,81 @@ namespace play {
|
|||
static OutputSlot&
|
||||
build()
|
||||
{
|
||||
UNIMPLEMENTED ("Diagnostic Output Slot instance");
|
||||
static lib::ScopedPtrVect<OutputSlot> diagnosticSlots;
|
||||
return diagnosticSlots.manage(new DiagnosticOutputSlot);
|
||||
}
|
||||
|
||||
static DiagnosticOutputSlot&
|
||||
access (OutputSlot& to_investigate)
|
||||
{
|
||||
UNIMPLEMENTED ("access the diagnostics data for the given OutputSlot instance");
|
||||
return dynamic_cast<DiagnosticOutputSlot&> (to_investigate);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* === diagnostics API === */
|
||||
|
||||
/**
|
||||
* diagnostic facility to verify
|
||||
* test data frames written to this
|
||||
* Test/Dummy "output"
|
||||
* diagnostic facility to verify test data frames
|
||||
* written to this Test/Dummy "output". It exposes
|
||||
* the emitted Data as a sequence of TestFrame objects.
|
||||
*/
|
||||
struct OutputStreamProtocol
|
||||
: lib::IterSource<TestFrame>
|
||||
class OutputFramesLog
|
||||
: public lib::IterSource<TestFrame>
|
||||
, boost::noncopyable
|
||||
{
|
||||
/////////////TODO: implement the extension points required to drive an IterSource
|
||||
TrackingInMemoryBlockSequence const& outSeq_;
|
||||
uint currentFrame_;
|
||||
|
||||
|
||||
virtual Pos
|
||||
firstResult ()
|
||||
{
|
||||
REQUIRE (0 == currentFrame_);
|
||||
return outSeq_.accessEmittedFrame (currentFrame_);
|
||||
}
|
||||
|
||||
virtual void
|
||||
nextResult (Pos& pos)
|
||||
{
|
||||
++currentFrame_;
|
||||
pos = outSeq_.accessEmittedFrame(currentFrame_);
|
||||
}
|
||||
|
||||
public:
|
||||
OutputFramesLog (TrackingInMemoryBlockSequence const& bs)
|
||||
: outSeq_(bs)
|
||||
, currentFrame_(0)
|
||||
{ }
|
||||
};
|
||||
|
||||
typedef OutputStreamProtocol::iterator OutFrames;
|
||||
typedef OutputFramesLog::iterator OutFrames;
|
||||
|
||||
|
||||
OutFrames
|
||||
getChannel (uint channel)
|
||||
{
|
||||
UNIMPLEMENTED ("access output stream tracing entry");
|
||||
REQUIRE (channel < MAX_CHANNELS);
|
||||
return OutputFramesLog::build(
|
||||
new OutputFramesLog (
|
||||
accessSequence(channel)));
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
buffer_was_used (uint channel, FrameID frame)
|
||||
{
|
||||
UNIMPLEMENTED ("determine if the denoted buffer was indeed used");
|
||||
diagn::Block* block = accessSequence(channel)
|
||||
.accessEmittedBuffer(frame);
|
||||
return block
|
||||
&& block->was_used();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
buffer_unused (uint channel, FrameID frame)
|
||||
{
|
||||
UNIMPLEMENTED ("determine if the specified buffer was never touched/locked for use");
|
||||
return !buffer_was_used(channel, frame);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,6 @@ namespace test {
|
|||
virtual void
|
||||
run (Arg)
|
||||
{
|
||||
UNIMPLEMENTED ("build a mock output slot and perform a full lifecycle");
|
||||
verifyStandardCase();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue