2011-07-09 02:44:24 +02:00
|
|
|
|
/*
|
|
|
|
|
|
OutputSlotProtocol(Test) - covering the basic usage cycle of an output slot
|
|
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
Copyright (C)
|
|
|
|
|
|
2011, Hermann Vosseler <Ichthyostega@web.de>
|
2011-07-09 02:44:24 +02:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
**Lumiera** 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. See the file COPYING for further details.
|
2011-07-09 02:44:24 +02:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
* *****************************************************************/
|
2011-07-09 02:44:24 +02:00
|
|
|
|
|
2017-02-22 01:54:20 +01:00
|
|
|
|
/** @file output-slot-protocol-test.cpp
|
2017-02-22 03:17:18 +01:00
|
|
|
|
** unit test \ref OutputSlotProtocol_test
|
2016-11-03 18:20:10 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
2011-07-09 02:44:24 +02:00
|
|
|
|
|
2026-03-06 21:34:20 +01:00
|
|
|
|
#include "test/run.hpp"
|
2012-01-08 03:06:32 +01:00
|
|
|
|
|
2026-03-10 23:12:30 +01:00
|
|
|
|
#include "vault/out/diagnostic-output-slot.hpp"
|
2026-03-08 00:53:41 +01:00
|
|
|
|
#include "vault/mem/buffhandle.hpp"
|
2026-04-10 23:15:32 +02:00
|
|
|
|
#include "vault/real-clock.hpp"
|
2026-03-07 22:31:08 +01:00
|
|
|
|
#include "test/test-frame.hpp"
|
2011-07-09 02:44:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
2026-03-07 22:31:08 +01:00
|
|
|
|
using test::TestFrame;
|
|
|
|
|
|
using test::testData;
|
2026-04-10 23:15:32 +02:00
|
|
|
|
using vault::RealClock;
|
2026-03-08 00:53:41 +01:00
|
|
|
|
using vault::mem::BuffHandle;
|
2026-04-10 23:15:32 +02:00
|
|
|
|
using lib::time::FSecs;
|
2011-07-09 02:44:24 +02:00
|
|
|
|
|
2026-03-10 23:12:30 +01:00
|
|
|
|
namespace vault{
|
|
|
|
|
|
namespace out {
|
2011-12-02 17:50:44 +01:00
|
|
|
|
namespace test {
|
2011-07-09 02:44:24 +02:00
|
|
|
|
|
2026-06-01 23:33:25 +02:00
|
|
|
|
using DataSink = vault::out::OutputSlot::DataSink;
|
|
|
|
|
|
|
2011-07-09 02:44:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
2013-10-24 23:06:36 +02:00
|
|
|
|
/***************************************************************//**
|
2011-07-10 18:18:20 +02:00
|
|
|
|
* @test verify the OutputSlot interface and base implementation
|
|
|
|
|
|
* by performing full data exchange cycle. This is a
|
|
|
|
|
|
* kind of "dry run" for documentation purposes,
|
|
|
|
|
|
* both the actual OutputSlot implementation
|
|
|
|
|
|
* as the client using this slot are Mocks.
|
2011-07-09 02:44:24 +02:00
|
|
|
|
*/
|
|
|
|
|
|
class OutputSlotProtocol_test : public Test
|
|
|
|
|
|
{
|
|
|
|
|
|
virtual void
|
2025-06-07 23:59:57 +02:00
|
|
|
|
run (Arg)
|
2011-07-09 02:44:24 +02:00
|
|
|
|
{
|
2011-07-10 18:18:20 +02:00
|
|
|
|
verifyStandardCase();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
verifyStandardCase()
|
|
|
|
|
|
{
|
|
|
|
|
|
// Create Test fixture.
|
|
|
|
|
|
// In real usage, the OutputSlot will be preconfigured
|
|
|
|
|
|
// (Media format, number of channels, physical connections)
|
|
|
|
|
|
// and then registered with / retrieved from an OutputManager
|
2026-03-10 19:57:41 +01:00
|
|
|
|
DiagnosticOutputSlot oSlot;
|
2011-07-10 18:18:20 +02:00
|
|
|
|
|
2026-03-20 23:39:10 +01:00
|
|
|
|
// Note: an OutputSlot is automatically activated / allocated
|
|
|
|
|
|
// for exclusive use by this client.
|
2011-07-10 18:18:20 +02:00
|
|
|
|
|
|
|
|
|
|
// Now the client is able to prepare
|
|
|
|
|
|
// "calculation streams" for the individual
|
|
|
|
|
|
// Channels to be output through this slot.
|
2026-03-20 23:39:10 +01:00
|
|
|
|
OutputSlot::OpenedSinks sinks = oSlot.getOpenedSinks();
|
2026-03-10 19:57:41 +01:00
|
|
|
|
DataSink sink0 = *sinks;
|
|
|
|
|
|
DataSink sink1 = *++sinks;
|
2011-07-10 18:18:20 +02:00
|
|
|
|
|
2026-04-10 23:15:32 +02:00
|
|
|
|
// some test markers....
|
|
|
|
|
|
const FrameCnt START = 123;
|
|
|
|
|
|
TimeVar testTime = Time::ZERO;
|
|
|
|
|
|
oSlot.fixCurrentTime(testTime);
|
|
|
|
|
|
auto markTime = [&]{ return Time( testTime += FSecs(1) ); };
|
|
|
|
|
|
|
2011-07-10 18:18:20 +02:00
|
|
|
|
// within the frame-calculation "loop"
|
2012-01-21 03:13:33 +01:00
|
|
|
|
// we perform a data exchange cycle
|
2026-04-10 23:15:32 +02:00
|
|
|
|
auto MARK_0 = markTime();
|
2026-06-01 23:33:25 +02:00
|
|
|
|
BuffHandle buff00 = sink0.lockFrame (START);
|
|
|
|
|
|
BuffHandle buff10 = sink1.lockFrame (START);
|
2011-07-10 18:18:20 +02:00
|
|
|
|
|
|
|
|
|
|
// rendering process calculates content....
|
2026-03-24 23:27:43 +01:00
|
|
|
|
buff00.emplace<TestFrame> (testData(0,0));
|
2011-07-10 18:18:20 +02:00
|
|
|
|
|
|
|
|
|
|
// while further frames might be processed in parallel
|
2026-04-10 23:15:32 +02:00
|
|
|
|
auto MARK_1 = markTime();
|
2026-06-01 23:33:25 +02:00
|
|
|
|
BuffHandle buff11 = sink1.lockFrame (START+1);
|
2026-03-24 23:27:43 +01:00
|
|
|
|
buff11.emplace<TestFrame> (testData(1,1));
|
|
|
|
|
|
buff10.emplace<TestFrame> (testData(1,0));
|
2011-07-10 18:18:20 +02:00
|
|
|
|
|
|
|
|
|
|
// Now it's time to emit the output
|
2026-04-10 23:15:32 +02:00
|
|
|
|
auto MARK_2 = markTime();
|
2026-03-10 19:57:41 +01:00
|
|
|
|
buff11.emit();
|
|
|
|
|
|
buff00.emit();
|
|
|
|
|
|
|
|
|
|
|
|
// Buffers must be marked as released when done
|
2026-04-10 23:15:32 +02:00
|
|
|
|
auto MARK_3 = markTime();
|
2026-03-10 19:57:41 +01:00
|
|
|
|
buff00.release();
|
|
|
|
|
|
buff10.release();
|
|
|
|
|
|
buff11.release();
|
2011-07-10 18:18:20 +02:00
|
|
|
|
// that's all for the client
|
|
|
|
|
|
|
|
|
|
|
|
// Verify sane operation....
|
2026-03-10 19:57:41 +01:00
|
|
|
|
CHECK (watch(oSlot).cntLocked() == 3);
|
|
|
|
|
|
CHECK (watch(oSlot).cntEmitted() == 2);
|
|
|
|
|
|
CHECK (watch(oSlot).cntReleased() == 3);
|
|
|
|
|
|
|
2026-04-10 23:15:32 +02:00
|
|
|
|
CHECK ( watch(oSlot).feed(0).frame(START ).wasLocked());
|
|
|
|
|
|
CHECK (not watch(oSlot).feed(0).frame(START+1).wasLocked());
|
|
|
|
|
|
CHECK ( watch(oSlot).feed(1).frame(START ).wasLocked());
|
|
|
|
|
|
CHECK ( watch(oSlot).feed(1).frame(START+1).wasLocked());
|
2011-07-10 18:18:20 +02:00
|
|
|
|
|
2026-04-10 23:15:32 +02:00
|
|
|
|
CHECK ( watch(oSlot).feed(0).frame(START ).wasEmitted());
|
|
|
|
|
|
CHECK (not watch(oSlot).feed(0).frame(START+1).wasEmitted());
|
|
|
|
|
|
CHECK (not watch(oSlot).feed(1).frame(START ).wasEmitted());
|
|
|
|
|
|
CHECK ( watch(oSlot).feed(1).frame(START+1).wasEmitted());
|
2011-07-10 18:18:20 +02:00
|
|
|
|
|
2026-04-10 23:15:32 +02:00
|
|
|
|
CHECK ( watch(oSlot).feed(0).frame(START ).wasReleased());
|
|
|
|
|
|
CHECK (not watch(oSlot).feed(0).frame(START+1).wasReleased());
|
|
|
|
|
|
CHECK ( watch(oSlot).feed(1).frame(START ).wasReleased());
|
|
|
|
|
|
CHECK ( watch(oSlot).feed(1).frame(START+1).wasReleased());
|
2011-07-10 18:18:20 +02:00
|
|
|
|
|
2026-04-10 23:15:32 +02:00
|
|
|
|
auto stream0 = watch(oSlot).getFeed(0, START);
|
|
|
|
|
|
auto stream1 = watch(oSlot).getFeed(1, START);
|
2011-07-10 18:18:20 +02:00
|
|
|
|
|
|
|
|
|
|
CHECK ( stream0);
|
2012-01-08 01:14:36 +01:00
|
|
|
|
CHECK (*stream0 == testData(0,0)); ++stream0;
|
2026-04-10 23:15:32 +02:00
|
|
|
|
CHECK (not stream0->wasLocked());
|
2011-07-10 18:18:20 +02:00
|
|
|
|
|
|
|
|
|
|
CHECK ( stream1);
|
2012-01-08 01:14:36 +01:00
|
|
|
|
CHECK (*stream1 == testData(1,0)); ++stream1;
|
|
|
|
|
|
CHECK (*stream1 == testData(1,1)); ++stream1;
|
2026-04-10 23:15:32 +02:00
|
|
|
|
CHECK (not stream1->wasLocked());
|
|
|
|
|
|
|
|
|
|
|
|
// Verify that recorded times match the »step stones« defined above...
|
|
|
|
|
|
auto recordedTime_0 = watch(oSlot).feed(0).frame(START).locked; // Frame 0.0
|
|
|
|
|
|
auto recordedTime_1 = watch(oSlot).feed(1).frame(START+1).locked; // Frame 1.1
|
|
|
|
|
|
auto recordedTime_2 = watch(oSlot).feed(0).frame(START ).emitted; // Frame 0.0
|
|
|
|
|
|
auto recordedTime_3 = watch(oSlot).feed(0).frame(START ).released; // Frame 0.0
|
|
|
|
|
|
// ..while Frame#1 on Sink#0 was actually never requested...
|
|
|
|
|
|
auto recordedTime_N = watch(oSlot).feed(0).frame(START+1).locked; // Frame 0.1
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (recordedTime_0 < recordedTime_1);
|
|
|
|
|
|
CHECK (recordedTime_1 < recordedTime_2);
|
|
|
|
|
|
CHECK (recordedTime_2 < recordedTime_3);
|
|
|
|
|
|
CHECK (recordedTime_0 == MARK_0);
|
|
|
|
|
|
CHECK (recordedTime_1 == MARK_1);
|
|
|
|
|
|
CHECK (recordedTime_2 == MARK_2);
|
|
|
|
|
|
CHECK (recordedTime_3 == MARK_3);
|
|
|
|
|
|
CHECK (Time::NEVER == recordedTime_N);
|
2011-07-10 18:18:20 +02:00
|
|
|
|
}
|
2011-07-09 02:44:24 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Register this test class... */
|
2023-06-07 04:03:00 +02:00
|
|
|
|
LAUNCHER (OutputSlotProtocol_test, "unit play");
|
2011-07-09 02:44:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-03-10 23:12:30 +01:00
|
|
|
|
}}} // namespace vault::out::test
|