mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 12:35:42 +00:00
Use the verified Gamescope component and preserve the safe copy fallback. Direct game frames remains experimental and off by default.
37 lines
1.2 KiB
C++
37 lines
1.2 KiB
C++
#include "droiddeck_producer_fence.hpp"
|
|
#include <cassert>
|
|
#include <cerrno>
|
|
#include <utility>
|
|
|
|
int main()
|
|
{
|
|
using namespace droiddeck;
|
|
assert(!ProducerAcquireEnabled()); // normal startup, no opt-in
|
|
assert(ProducerFenceStatus(-1) < 0);
|
|
|
|
int ends[2];
|
|
assert(pipe(ends) == 0);
|
|
const int readEnd = ends[0];
|
|
auto fd = std::make_shared<ProducerFence>(readEnd);
|
|
assert(fd->SyncStatus() < 0); // ordinary pipe must never become a ready writer fence
|
|
assert(fd->SignaledFd() < 0);
|
|
int a, b;
|
|
PendingProducerFence old{fd, 21, &a};
|
|
assert(!old.Consume(true, 22, &a));
|
|
assert(!old.fence);
|
|
PendingProducerFence different{fd, 21, &a};
|
|
assert(!different.Consume(true, 21, &b));
|
|
PendingProducerFence empty{fd, 21, &a};
|
|
assert(!empty.Consume(false, 21, &a));
|
|
PendingProducerFence matching{std::move(fd), 21, &a};
|
|
auto consumed = matching.Consume(true, 21, &a);
|
|
assert(consumed && !matching.Consume(true, 21, &a)); // never clonable across commits
|
|
int dup = consumed->Dup();
|
|
assert(dup >= 0 && fcntl(dup, F_GETFD) == FD_CLOEXEC);
|
|
consumed.reset();
|
|
assert(fcntl(readEnd, F_GETFD) == -1 && errno == EBADF);
|
|
assert(fcntl(dup, F_GETFD) == FD_CLOEXEC);
|
|
close(dup);
|
|
close(ends[1]);
|
|
}
|