2011-06-18 03:34:27 +02:00
|
|
|
/*
|
|
|
|
|
OutputSlot - capability to transfer data to a physical output
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
* *****************************************************/
|
|
|
|
|
|
|
|
|
|
|
2011-11-05 16:51:24 +01:00
|
|
|
#include "lib/error.hpp"
|
2011-06-18 03:34:27 +02:00
|
|
|
#include "proc/play/output-slot.hpp"
|
2011-11-06 02:37:22 +01:00
|
|
|
#include "proc/play/output-slot-connection.hpp"
|
2011-06-18 03:34:27 +02:00
|
|
|
|
2011-11-05 16:51:24 +01:00
|
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
|
#include <vector>
|
2011-06-18 03:34:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace proc {
|
|
|
|
|
namespace play {
|
|
|
|
|
|
2011-11-05 16:51:24 +01:00
|
|
|
using std::vector;
|
|
|
|
|
|
|
|
|
|
namespace error = lumiera::error;
|
|
|
|
|
|
2011-06-18 03:34:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OutputSlot::~OutputSlot() { } // emit VTables here....
|
|
|
|
|
|
2011-11-05 16:51:24 +01:00
|
|
|
OutputSlot::Allocation::~Allocation() { }
|
|
|
|
|
|
2011-11-08 02:59:56 +01:00
|
|
|
OutputSlot::Connection::~Connection() { }
|
|
|
|
|
|
2011-11-05 16:51:24 +01:00
|
|
|
|
|
|
|
|
|
2011-06-18 03:34:27 +02:00
|
|
|
|
|
|
|
|
|
2011-06-25 17:44:28 +02:00
|
|
|
/** whether this output slot is occupied
|
|
|
|
|
* @return true if currently unconnected and
|
|
|
|
|
* able to connect and handle output data
|
|
|
|
|
*/
|
|
|
|
|
bool
|
|
|
|
|
OutputSlot::isFree() const
|
|
|
|
|
{
|
2011-11-05 16:51:24 +01:00
|
|
|
return ! this->state_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-12-23 02:22:38 +01:00
|
|
|
/** claim this OutputSlot for active use as output sink(s).
|
|
|
|
|
* At any point, a given slot can only be used for a single
|
|
|
|
|
* ongoing output process (which may serve several channels though).
|
|
|
|
|
* The assumption is for the OutputSlot to be picked through a query
|
|
|
|
|
* to some OutputManater, so the parameters (resolution, sample rate...)
|
|
|
|
|
* should be suited for the intended use. Thus no additional configuration
|
|
|
|
|
* is necessary.
|
|
|
|
|
* @return Allocation representing the "connected state" from the client's POV.
|
|
|
|
|
* The client may retrieve the effectively required Timings from there,
|
|
|
|
|
* as well as the actual output sinks, ready for use.
|
|
|
|
|
* @remarks calls back into #buildState, where the concrete OutputSlot
|
|
|
|
|
* is expected to provide a private Connection implementation,
|
|
|
|
|
* subclassing OutputSlot::Allocation
|
|
|
|
|
*/
|
2011-11-05 16:51:24 +01:00
|
|
|
OutputSlot::Allocation&
|
|
|
|
|
OutputSlot::allocate()
|
|
|
|
|
{
|
|
|
|
|
if (!isFree())
|
|
|
|
|
throw error::Logic ("Attempt to open/allocate an OutputSlot already in use.");
|
|
|
|
|
|
2011-11-06 02:37:22 +01:00
|
|
|
state_.reset (this->buildState());
|
2011-11-05 16:51:24 +01:00
|
|
|
return *state_;
|
2011-06-25 17:44:28 +02:00
|
|
|
}
|
2011-06-18 03:34:27 +02:00
|
|
|
|
|
|
|
|
|
2011-11-06 02:37:22 +01:00
|
|
|
void
|
|
|
|
|
OutputSlot::disconnect()
|
|
|
|
|
{
|
|
|
|
|
if (!isFree())
|
|
|
|
|
state_.reset(0);
|
|
|
|
|
}
|
2011-11-08 02:59:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* === 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);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-06 02:37:22 +01:00
|
|
|
|
|
|
|
|
|
2011-06-18 03:34:27 +02:00
|
|
|
|
|
|
|
|
}} // namespace proc::play
|