2011-07-09 02:44:24 +02:00
|
|
|
/*
|
|
|
|
|
DIAGNOSTIC-OUTPUT-SLOT.hpp - helper for testing against the OutputSlot interface
|
|
|
|
|
|
|
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2011, Hermann Vosseler <Ichthyostega@web.de>
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2 of
|
|
|
|
|
the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** @file diagnostic-output-slot.hpp
|
|
|
|
|
** An facility for writing unit-tests against the OutputSlot interface.
|
|
|
|
|
**
|
|
|
|
|
** @see output-slot-protocol-test.cpp
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef PROC_PLAY_DIAGNOSTIC_OUTPUT_SLOT_H
|
|
|
|
|
#define PROC_PLAY_DIAGNOSTIC_OUTPUT_SLOT_H
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "lib/error.hpp"
|
2011-11-07 01:57:33 +01:00
|
|
|
#include "include/logging.h"
|
2011-07-09 02:44:24 +02:00
|
|
|
#include "proc/play/output-slot.hpp"
|
2011-11-07 01:57:33 +01:00
|
|
|
#include "proc/play/output-slot-connection.hpp"
|
|
|
|
|
#include "proc/engine/buffhandle.hpp"
|
|
|
|
|
#include "proc/engine/tracking-heap-block-provider.hpp"
|
2011-10-19 02:47:11 +02:00
|
|
|
#include "lib/iter-source.hpp" ////////////TODO really going down that path...?
|
|
|
|
|
#include "proc/engine/testframe.hpp"
|
2011-07-09 02:44:24 +02:00
|
|
|
//#include "lib/sync.hpp"
|
|
|
|
|
|
2011-11-07 01:57:33 +01:00
|
|
|
#include <boost/noncopyable.hpp>
|
2011-07-09 02:44:24 +02:00
|
|
|
//#include <string>
|
|
|
|
|
//#include <vector>
|
2011-11-07 01:57:33 +01:00
|
|
|
#include <tr1/memory>
|
2011-07-09 02:44:24 +02:00
|
|
|
//#include <boost/scoped_ptr.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace proc {
|
|
|
|
|
namespace play {
|
|
|
|
|
|
|
|
|
|
//using std::string;
|
2011-11-07 01:57:33 +01:00
|
|
|
using ::engine::BufferDescriptor;
|
2011-10-19 02:47:11 +02:00
|
|
|
using ::engine::test::TestFrame;
|
2011-11-07 01:57:33 +01:00
|
|
|
using ::engine::TrackingHeapBlockProvider;
|
2011-07-09 02:44:24 +02:00
|
|
|
|
|
|
|
|
//using std::vector;
|
2011-11-07 01:57:33 +01:00
|
|
|
using std::tr1::shared_ptr;
|
2011-07-09 02:44:24 +02:00
|
|
|
//using boost::scoped_ptr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-11-07 01:57:33 +01:00
|
|
|
class TrackingInMemoryBlockSequence
|
|
|
|
|
: public OutputSlot::Connection
|
|
|
|
|
{
|
|
|
|
|
|
2011-11-11 23:33:59 +01:00
|
|
|
shared_ptr<TrackingHeapBlockProvider> buffProvider_;
|
2011-11-07 01:57:33 +01:00
|
|
|
BufferDescriptor bufferType_;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* === Connection API === */
|
|
|
|
|
|
2011-11-08 02:59:56 +01:00
|
|
|
BuffHandle
|
|
|
|
|
claimBufferFor(FrameID frameNr)
|
2011-11-07 01:57:33 +01:00
|
|
|
{
|
|
|
|
|
buffProvider_->lockBufferFor (bufferType_);
|
2011-11-08 02:59:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
isTimely (FrameID frameNr, TimeValue currentTime)
|
|
|
|
|
{
|
|
|
|
|
if (Time::MAX == currentTime)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
UNIMPLEMENTED ("find out about timings");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
transfer (BuffHandle const& filledBuffer)
|
|
|
|
|
{
|
|
|
|
|
pushout (filledBuffer);
|
2011-11-07 01:57:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2011-11-08 02:59:56 +01:00
|
|
|
pushout (BuffHandle const& data4output)
|
2011-11-07 01:57:33 +01:00
|
|
|
{
|
2011-11-08 02:59:56 +01:00
|
|
|
buffProvider_->mark_emitted (data4output);
|
|
|
|
|
buffProvider_->releaseBuffer (data4output);
|
2011-11-07 01:57:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2011-11-08 02:59:56 +01:00
|
|
|
discard (BuffHandle const& superseededData)
|
2011-11-07 01:57:33 +01:00
|
|
|
{
|
2011-11-08 02:59:56 +01:00
|
|
|
buffProvider_->releaseBuffer (superseededData);
|
2011-11-07 01:57:33 +01:00
|
|
|
}
|
|
|
|
|
|
2011-11-08 02:59:56 +01:00
|
|
|
void
|
|
|
|
|
shutDown ()
|
|
|
|
|
{
|
|
|
|
|
buffProvider_.reset();
|
|
|
|
|
}
|
2011-11-07 01:57:33 +01:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TrackingInMemoryBlockSequence()
|
|
|
|
|
: buffProvider_(new TrackingHeapBlockProvider())
|
|
|
|
|
, bufferType_(buffProvider_->getDescriptor<TestFrame>())
|
|
|
|
|
{
|
|
|
|
|
INFO (engine_dbg, "building in-memory diagnostic output sequence");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual
|
|
|
|
|
~TrackingInMemoryBlockSequence()
|
|
|
|
|
{
|
|
|
|
|
INFO (engine_dbg, "releasing diagnostic output sequence");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SimulatedOutputSequences
|
|
|
|
|
: public ConnectionStateManager<TrackingInMemoryBlockSequence>
|
|
|
|
|
, boost::noncopyable
|
|
|
|
|
{
|
|
|
|
|
TrackingInMemoryBlockSequence
|
|
|
|
|
buildConnection()
|
|
|
|
|
{
|
|
|
|
|
return TrackingInMemoryBlockSequence();
|
|
|
|
|
}
|
2011-11-08 02:59:56 +01:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
SimulatedOutputSequences (uint numChannels)
|
|
|
|
|
{
|
|
|
|
|
init (numChannels);
|
|
|
|
|
}
|
2011-11-07 01:57:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-07-09 02:44:24 +02:00
|
|
|
/********************************************************************
|
|
|
|
|
* Helper for unit tests: Mock output sink.
|
|
|
|
|
*
|
|
|
|
|
* @todo write type comment
|
|
|
|
|
*/
|
|
|
|
|
class DiagnosticOutputSlot
|
|
|
|
|
: public OutputSlot
|
|
|
|
|
{
|
2011-11-08 02:59:56 +01:00
|
|
|
|
|
|
|
|
static const uint MAX_CHANNELS = 5;
|
|
|
|
|
|
2011-11-07 01:57:33 +01:00
|
|
|
/* === hook into the OutputSlot frontend === */
|
|
|
|
|
ConnectionState*
|
|
|
|
|
buildState()
|
|
|
|
|
{
|
2011-11-08 02:59:56 +01:00
|
|
|
return new SimulatedOutputSequences(MAX_CHANNELS);
|
2011-11-07 01:57:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-07-09 02:44:24 +02:00
|
|
|
public:
|
2011-08-18 12:31:26 +02:00
|
|
|
/** build a new Diagnostic Output Slot instance,
|
|
|
|
|
* discard the existing one. Use the static query API
|
|
|
|
|
* for investigating collected data. */
|
|
|
|
|
static OutputSlot&
|
|
|
|
|
build()
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("Diagnostic Output Slot instance");
|
|
|
|
|
}
|
2011-07-09 02:44:24 +02:00
|
|
|
|
2011-10-19 02:47:11 +02:00
|
|
|
static DiagnosticOutputSlot&
|
|
|
|
|
access (OutputSlot& to_investigate)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("access the diagnostics data for the given OutputSlot instance");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* === diagnostics API === */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* diagnostic facility to verify
|
|
|
|
|
* test data frames written to this
|
|
|
|
|
* Test/Dummy "output"
|
|
|
|
|
*/
|
|
|
|
|
struct OutputStreamProtocol
|
|
|
|
|
: lib::IterSource<TestFrame>
|
|
|
|
|
{
|
|
|
|
|
/////////////TODO: implement the extension points required to drive an IterSource
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef OutputStreamProtocol::iterator OutFrames;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OutFrames
|
|
|
|
|
getChannel (uint channel)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("access output stream tracing entry");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2011-11-06 02:37:22 +01:00
|
|
|
buffer_was_used (uint channel, FrameID frame)
|
2011-10-19 02:47:11 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("determine if the denoted buffer was indeed used");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2011-11-06 02:37:22 +01:00
|
|
|
buffer_unused (uint channel, FrameID frame)
|
2011-10-19 02:47:11 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("determine if the specified buffer was never touched/locked for use");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2011-11-06 02:37:22 +01:00
|
|
|
buffer_was_closed (uint channel, FrameID frame)
|
2011-10-19 02:47:11 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("determine if the specified buffer was indeed closed properly");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2011-11-06 02:37:22 +01:00
|
|
|
emitted (uint channel, FrameID frame)
|
2011-10-19 02:47:11 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("determine if the specivied buffer was indeed handed over for emitting output");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-07-09 02:44:24 +02:00
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}} // namespace proc::play
|
|
|
|
|
#endif
|