Commit 2abc98db authored by Jakob Bornecrantz's avatar Jakob Bornecrantz
Browse files

aux/util: Add split sink

parent 798ef433
Pipeline #62003 passed with stages
in 1 minute and 13 seconds
......@@ -45,6 +45,7 @@ set(UTIL_SOURCE_FILES
util/u_sink.h
util/u_sink_converter.c
util/u_sink_queue.c
util/u_sink_split.c
util/u_time.cpp
util/u_time.h
util/u_var.cpp
......
......@@ -32,6 +32,12 @@ u_sink_queue_create(struct xrt_frame_context *xfctx,
struct xrt_frame_sink *downstream,
struct xrt_frame_sink **out_xfs);
void
u_sink_split_create(struct xrt_frame_context *xfctx,
struct xrt_frame_sink *left,
struct xrt_frame_sink *right,
struct xrt_frame_sink **out_xfs);
#ifdef __cplusplus
}
......
// Copyright 2019, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief A @ref xrt_frame_sink splitter.
* @author Jakob Bornecrantz <jakob@collabora.com>
* @ingroup aux_util
*/
#include "util/u_misc.h"
#include "util/u_sink.h"
struct u_sink_split
{
struct xrt_frame_sink base;
struct xrt_frame_node node;
struct xrt_frame_sink *left;
struct xrt_frame_sink *right;
};
static void
split_frame(struct xrt_frame_sink *xfs, struct xrt_frame *xf)
{
struct u_sink_split *s = (struct u_sink_split *)xfs;
s->left->push_frame(s->left, xf);
s->right->push_frame(s->right, xf);
}
static void
break_apart(struct xrt_frame_node *node)
{}
static void
destroy(struct xrt_frame_node *node)
{
struct u_sink_split *s = container_of(node, struct u_sink_split, node);
free(s);
}
/*
*
* Exported functions.
*
*/
void
u_sink_split_create(struct xrt_frame_context *xfctx,
struct xrt_frame_sink *left,
struct xrt_frame_sink *right,
struct xrt_frame_sink **out_xfs)
{
struct u_sink_split *s = U_TYPED_CALLOC(struct u_sink_split);
s->base.push_frame = split_frame;
s->node.break_apart = break_apart;
s->node.destroy = destroy;
s->left = left;
s->right = right;
*out_xfs = &s->base;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment