clock: remove clock interface

Remove the clock interface, we need to get timing information with an io
area to get the required precision and performance.
This commit is contained in:
Wim Taymans 2018-07-17 09:50:51 +02:00
parent 83bb8dc599
commit fba00fb791
22 changed files with 31 additions and 516 deletions

View file

@ -1,127 +0,0 @@
/* Simple Plugin API
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __SPA_CLOCK_H__
#define __SPA_CLOCK_H__
#ifdef __cplusplus
extern "C" {
#endif
#define SPA_TYPE__Clock SPA_TYPE_INTERFACE_BASE "Clock"
#define SPA_TYPE_CLOCK_BASE SPA_TYPE__Clock ":"
/** The state of the clock */
enum spa_clock_state {
SPA_CLOCK_STATE_STOPPED, /*< the clock is stopped */
SPA_CLOCK_STATE_PAUSED, /*< the clock is paused */
SPA_CLOCK_STATE_RUNNING, /*< the clock is running */
};
#include <spa/utils/defs.h>
#include <spa/pod/builder.h>
/**
* A time provider.
*/
struct spa_clock {
/* the version of this clock. This can be used to expand this
* structure in the future */
#define SPA_VERSION_CLOCK 0
uint32_t version;
/** extra clock information */
const struct spa_dict *info;
/** The current state of the clock */
enum spa_clock_state state;
/**
* Get the parameters of \a clock.
*
* The returned \a props is a snapshot of the current configuration and
* can be modified. The modifications will take effect after a call
* to set_props.
*
* \param clock a spa_clock
* \param id the paramter id to enumerate
* \param index state while iterating, 0 for the first param
* \param param result parameter
* \param builder builder for \a param
* \return 1 on success
* 0 when no more items are available
* -EINVAL when invalid parameters are provided
* -ENOTSUP when there are no parameters
* implemented on \a clock
* -ENOENT when the param with id is not supported
*/
int (*enum_params) (struct spa_clock *clock,
uint32_t id, uint32_t *index,
struct spa_pod **param,
struct spa_pod_builder *builder);
/**
* Set the configurable properties in \a clock.
*
* Usually, \a props will be obtained from spa_clock::get_props and then
* modified but it is also possible to set another #struct spa_props object
* as long as its keys and types match those of struct spa_props::get_props.
*
* Properties with keys that are not known are ignored.
*
* If \a props is NULL, all the properties are reset to their defaults.
*
* \param clock a spa_clock
* \param id the paramter id to configure
* \param flags extra parameter flags
* \param param the parameter to configure
* \return 0 on success
* -EINVAL when invalid parameters are provided
* -ENOTSUP when no parameters can be
* modified on \a clock.
* -ENOENT when the param with id is not supported
*/
int (*set_param) (struct spa_clock *clock,
uint32_t id, uint32_t flags,
const struct spa_pod *param);
/** Get the time of \a clock
*
* Get an atomic snapshot between the time of the monotonic clock and
* the clock specific time expressed in ticks.
*
* \param clock the clock
* \param rate result rate. This is the number of ticks per second
* \param ticks result number of ticks. There are \a rate ticks per second.
* \param monotonic_time the time of the monotonic clock when \a ticks was
* obtained.
*/
int (*get_time) (struct spa_clock *clock,
int32_t *rate,
int64_t *ticks,
int64_t *monotonic_time);
};
#define spa_clock_enum_params(n,...) (n)->enum_params((n),__VA_ARGS__)
#define spa_clock_set_param(n,...) (n)->set_param((n),__VA_ARGS__)
#define spa_clock_get_time(n,...) (n)->get_time((n),__VA_ARGS__)
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_CLOCK_H__ */

View file

@ -6,13 +6,6 @@ spa_buffer_headers = [
install_headers(spa_buffer_headers, install_headers(spa_buffer_headers,
subdir : 'spa/buffer') subdir : 'spa/buffer')
spa_clock_headers = [
'clock/clock.h',
]
install_headers(spa_clock_headers,
subdir : 'spa/clock')
spa_graph_headers = [ spa_graph_headers = [
'graph/graph.h', 'graph/graph.h',
] ]

View file

@ -35,13 +35,11 @@ extern "C" {
#define SPA_TYPE_EVENT_NODE__Error SPA_TYPE_EVENT_NODE_BASE "Error" #define SPA_TYPE_EVENT_NODE__Error SPA_TYPE_EVENT_NODE_BASE "Error"
#define SPA_TYPE_EVENT_NODE__Buffering SPA_TYPE_EVENT_NODE_BASE "Buffering" #define SPA_TYPE_EVENT_NODE__Buffering SPA_TYPE_EVENT_NODE_BASE "Buffering"
#define SPA_TYPE_EVENT_NODE__RequestRefresh SPA_TYPE_EVENT_NODE_BASE "RequestRefresh" #define SPA_TYPE_EVENT_NODE__RequestRefresh SPA_TYPE_EVENT_NODE_BASE "RequestRefresh"
#define SPA_TYPE_EVENT_NODE__RequestClockUpdate SPA_TYPE_EVENT_NODE_BASE "RequestClockUpdate"
struct spa_type_event_node { struct spa_type_event_node {
uint32_t Error; uint32_t Error;
uint32_t Buffering; uint32_t Buffering;
uint32_t RequestRefresh; uint32_t RequestRefresh;
uint32_t RequestClockUpdate;
}; };
static inline void static inline void
@ -51,32 +49,9 @@ spa_type_event_node_map(struct spa_type_map *map, struct spa_type_event_node *ty
type->Error = spa_type_map_get_id(map, SPA_TYPE_EVENT_NODE__Error); type->Error = spa_type_map_get_id(map, SPA_TYPE_EVENT_NODE__Error);
type->Buffering = spa_type_map_get_id(map, SPA_TYPE_EVENT_NODE__Buffering); type->Buffering = spa_type_map_get_id(map, SPA_TYPE_EVENT_NODE__Buffering);
type->RequestRefresh = spa_type_map_get_id(map, SPA_TYPE_EVENT_NODE__RequestRefresh); type->RequestRefresh = spa_type_map_get_id(map, SPA_TYPE_EVENT_NODE__RequestRefresh);
type->RequestClockUpdate = spa_type_map_get_id(map, SPA_TYPE_EVENT_NODE__RequestClockUpdate);
} }
} }
struct spa_event_node_request_clock_update_body {
struct spa_pod_object_body body;
#define SPA_EVENT_NODE_REQUEST_CLOCK_UPDATE_TIME (1 << 0)
#define SPA_EVENT_NODE_REQUEST_CLOCK_UPDATE_SCALE (1 << 1)
#define SPA_EVENT_NODE_REQUEST_CLOCK_UPDATE_STATE (1 << 2)
struct spa_pod_int update_mask SPA_ALIGNED(8);
struct spa_pod_long timestamp SPA_ALIGNED(8);
struct spa_pod_long offset SPA_ALIGNED(8);
};
struct spa_event_node_request_clock_update {
struct spa_pod pod;
struct spa_event_node_request_clock_update_body body;
};
#define SPA_EVENT_NODE_REQUEST_CLOCK_UPDATE_INIT(type,update_mask,timestamp,offset) \
SPA_EVENT_INIT_FULL(struct spa_event_node_request_clock_update, \
sizeof(struct spa_event_node_request_clock_update_body), type, \
SPA_POD_INT_INIT(update_mask), \
SPA_POD_LONG_INIT(timestamp), \
SPA_POD_LONG_INIT(offset))
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
#endif #endif

View file

@ -41,6 +41,9 @@ extern "C" {
/** An io area to exchange buffers with a port */ /** An io area to exchange buffers with a port */
#define SPA_TYPE_IO__Buffers SPA_TYPE_IO_BASE "Buffers" #define SPA_TYPE_IO__Buffers SPA_TYPE_IO_BASE "Buffers"
/** IO area with clock information */
#define SPA_TYPE_IO__Clock SPA_TYPE_IO_BASE "Clock"
/** Buffers IO area /** Buffers IO area
* *
* IO information for a port on a node. This is allocated * IO information for a port on a node. This is allocated
@ -69,10 +72,18 @@ struct spa_io_control_range {
uint32_t max_size; /**< maximum size of data */ uint32_t max_size; /**< maximum size of data */
}; };
/** A time source */
struct spa_io_clock {
uint64_t nsec; /**< time in nanoseconds */
struct spa_fraction rate; /**< rate */
uint32_t position; /**< current position expressed in rate */
};
struct spa_type_io { struct spa_type_io {
uint32_t Buffers; uint32_t Buffers;
uint32_t ControlRange; uint32_t ControlRange;
uint32_t Prop; uint32_t Prop;
uint32_t Clock;
}; };
static inline void spa_type_io_map(struct spa_type_map *map, struct spa_type_io *type) static inline void spa_type_io_map(struct spa_type_map *map, struct spa_type_io *type)
@ -81,6 +92,7 @@ static inline void spa_type_io_map(struct spa_type_map *map, struct spa_type_io
type->Buffers = spa_type_map_get_id(map, SPA_TYPE_IO__Buffers); type->Buffers = spa_type_map_get_id(map, SPA_TYPE_IO__Buffers);
type->ControlRange = spa_type_map_get_id(map, SPA_TYPE_IO_CONTROL__Range); type->ControlRange = spa_type_map_get_id(map, SPA_TYPE_IO_CONTROL__Range);
type->Prop = spa_type_map_get_id(map, SPA_TYPE_IO__Prop); type->Prop = spa_type_map_get_id(map, SPA_TYPE_IO__Prop);
type->Clock = spa_type_map_get_id(map, SPA_TYPE_IO__Clock);
} }
} }

View file

@ -556,6 +556,8 @@ impl_node_port_set_io(struct spa_node *node,
this->io = data; this->io = data;
else if (id == t->io.ControlRange) else if (id == t->io.ControlRange)
this->range = data; this->range = data;
else if (id == t->io.Clock)
this->clock = data;
else else
return -ENOENT; return -ENOENT;

View file

@ -577,6 +577,8 @@ impl_node_port_set_io(struct spa_node *node,
if (id == t->io.Buffers) if (id == t->io.Buffers)
this->io = data; this->io = data;
else if (id == t->io.Clock)
this->clock = data;
else else
return -ENOENT; return -ENOENT;
@ -678,50 +680,6 @@ static const struct spa_node impl_node = {
impl_node_process, impl_node_process,
}; };
static int impl_clock_enum_params(struct spa_clock *clock, uint32_t id, uint32_t *index,
struct spa_pod **param,
struct spa_pod_builder *builder)
{
return -ENOTSUP;
}
static int impl_clock_set_param(struct spa_clock *clock,
uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
return -ENOTSUP;
}
static int impl_clock_get_time(struct spa_clock *clock,
int32_t *rate,
int64_t *ticks,
int64_t *monotonic_time)
{
struct state *this;
spa_return_val_if_fail(clock != NULL, -EINVAL);
this = SPA_CONTAINER_OF(clock, struct state, clock);
if (rate)
*rate = SPA_USEC_PER_SEC;
if (ticks)
*ticks = this->last_ticks;
if (monotonic_time)
*monotonic_time = this->last_monotonic;
return 0;
}
static const struct spa_clock impl_clock = {
SPA_VERSION_CLOCK,
NULL,
SPA_CLOCK_STATE_STOPPED,
impl_clock_enum_params,
impl_clock_set_param,
impl_clock_get_time,
};
static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface) static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface)
{ {
struct state *this; struct state *this;
@ -733,8 +691,6 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
if (interface_id == this->type.node) if (interface_id == this->type.node)
*interface = &this->node; *interface = &this->node;
else if (interface_id == this->type.clock)
*interface = &this->clock;
else else
return -ENOENT; return -ENOENT;
@ -796,7 +752,6 @@ impl_init(const struct spa_handle_factory *factory,
init_type(&this->type, this->map); init_type(&this->type, this->map);
this->node = impl_node; this->node = impl_node;
this->clock = impl_clock;
this->stream = SND_PCM_STREAM_CAPTURE; this->stream = SND_PCM_STREAM_CAPTURE;
reset_props(&this->props); reset_props(&this->props);
@ -818,7 +773,6 @@ impl_init(const struct spa_handle_factory *factory,
static const struct spa_interface_info impl_interfaces[] = { static const struct spa_interface_info impl_interfaces[] = {
{SPA_TYPE__Node,}, {SPA_TYPE__Node,},
{SPA_TYPE__Clock,},
}; };
static int static int

View file

@ -487,7 +487,7 @@ push_frames(struct state *state,
if (b->h) { if (b->h) {
b->h->seq = state->sample_count; b->h->seq = state->sample_count;
b->h->pts = state->last_monotonic; b->h->pts = SPA_TIMESPEC_TO_TIME(&state->now);
b->h->dts_offset = 0; b->h->dts_offset = 0;
} }
@ -562,8 +562,11 @@ static void alsa_on_playback_timeout_event(struct spa_source *source)
state->filled = state->buffer_frames - avail; state->filled = state->buffer_frames - avail;
state->last_ticks = state->sample_count - state->filled; if (state->clock) {
state->last_monotonic = (int64_t) state->now.tv_sec * SPA_NSEC_PER_SEC + (int64_t) state->now.tv_nsec; state->clock->nsec = SPA_TIMESPEC_TO_TIME(&state->now);
state->clock->rate = SPA_FRACTION(state->rate, 1);
state->clock->position = state->sample_count - state->filled;
}
spa_log_trace(state->log, "timeout %ld %d %ld %ld %ld", state->filled, state->threshold, spa_log_trace(state->log, "timeout %ld %d %ld %ld %ld", state->filled, state->threshold,
state->sample_count, state->now.tv_sec, state->now.tv_nsec); state->sample_count, state->now.tv_sec, state->now.tv_nsec);
@ -616,7 +619,6 @@ static void alsa_on_capture_timeout_event(struct spa_source *source)
snd_pcm_status_t *status; snd_pcm_status_t *status;
struct timespec now; struct timespec now;
if (state->started && read(state->timerfd, &exp, sizeof(uint64_t)) != sizeof(uint64_t)) if (state->started && read(state->timerfd, &exp, sizeof(uint64_t)) != sizeof(uint64_t))
spa_log_warn(state->log, "error reading timerfd: %s", strerror(errno)); spa_log_warn(state->log, "error reading timerfd: %s", strerror(errno));
@ -631,8 +633,11 @@ static void alsa_on_capture_timeout_event(struct spa_source *source)
snd_pcm_status_get_htstamp(status, &state->now); snd_pcm_status_get_htstamp(status, &state->now);
clock_gettime(CLOCK_MONOTONIC, &now); clock_gettime(CLOCK_MONOTONIC, &now);
state->last_ticks = state->sample_count + avail; if (state->clock) {
state->last_monotonic = (int64_t) state->now.tv_sec * SPA_NSEC_PER_SEC + (int64_t) state->now.tv_nsec; state->clock->nsec = SPA_TIMESPEC_TO_TIME(&state->now);
state->clock->rate = SPA_FRACTION(state->rate, 1);
state->clock->position = state->sample_count + avail;
}
spa_log_trace(state->log, "timeout %ld %d %ld %ld %ld %ld %ld", avail, state->threshold, spa_log_trace(state->log, "timeout %ld %d %ld %ld %ld %ld %ld", avail, state->threshold,
state->sample_count, state->now.tv_sec, state->now.tv_nsec, state->sample_count, state->now.tv_sec, state->now.tv_nsec,

View file

@ -33,7 +33,6 @@ extern "C" {
#include <spa/support/log.h> #include <spa/support/log.h>
#include <spa/utils/list.h> #include <spa/utils/list.h>
#include <spa/clock/clock.h>
#include <spa/node/node.h> #include <spa/node/node.h>
#include <spa/node/io.h> #include <spa/node/io.h>
#include <spa/param/buffers.h> #include <spa/param/buffers.h>
@ -63,7 +62,6 @@ struct buffer {
struct type { struct type {
uint32_t node; uint32_t node;
uint32_t clock;
uint32_t format; uint32_t format;
uint32_t props; uint32_t props;
uint32_t prop_device; uint32_t prop_device;
@ -89,7 +87,6 @@ struct type {
static inline void init_type(struct type *type, struct spa_type_map *map) static inline void init_type(struct type *type, struct spa_type_map *map)
{ {
type->node = spa_type_map_get_id(map, SPA_TYPE__Node); type->node = spa_type_map_get_id(map, SPA_TYPE__Node);
type->clock = spa_type_map_get_id(map, SPA_TYPE__Clock);
type->format = spa_type_map_get_id(map, SPA_TYPE__Format); type->format = spa_type_map_get_id(map, SPA_TYPE__Format);
type->props = spa_type_map_get_id(map, SPA_TYPE__Props); type->props = spa_type_map_get_id(map, SPA_TYPE__Props);
type->prop_device = spa_type_map_get_id(map, SPA_TYPE_PROPS__device); type->prop_device = spa_type_map_get_id(map, SPA_TYPE_PROPS__device);
@ -116,7 +113,6 @@ static inline void init_type(struct type *type, struct spa_type_map *map)
struct state { struct state {
struct spa_handle handle; struct spa_handle handle;
struct spa_node node; struct spa_node node;
struct spa_clock clock;
uint32_t seq; uint32_t seq;
@ -150,6 +146,7 @@ struct state {
struct spa_port_info info; struct spa_port_info info;
struct spa_io_buffers *io; struct spa_io_buffers *io;
struct spa_io_control_range *range; struct spa_io_control_range *range;
struct spa_io_clock *clock;
struct buffer buffers[MAX_BUFFERS]; struct buffer buffers[MAX_BUFFERS];
unsigned int n_buffers; unsigned int n_buffers;
@ -168,8 +165,6 @@ struct state {
snd_htimestamp_t now; snd_htimestamp_t now;
int64_t sample_count; int64_t sample_count;
int64_t filled; int64_t filled;
int64_t last_ticks;
int64_t last_monotonic;
uint64_t underrun; uint64_t underrun;
}; };

View file

@ -28,7 +28,6 @@
#include <spa/support/log.h> #include <spa/support/log.h>
#include <spa/support/loop.h> #include <spa/support/loop.h>
#include <spa/utils/list.h> #include <spa/utils/list.h>
#include <spa/clock/clock.h>
#include <spa/node/node.h> #include <spa/node/node.h>
#include <spa/node/io.h> #include <spa/node/io.h>
#include <spa/param/audio/format-utils.h> #include <spa/param/audio/format-utils.h>
@ -46,7 +45,6 @@
struct type { struct type {
uint32_t node; uint32_t node;
uint32_t clock;
uint32_t format; uint32_t format;
uint32_t props; uint32_t props;
uint32_t prop_live; uint32_t prop_live;
@ -74,7 +72,6 @@ struct type {
static inline void init_type(struct type *type, struct spa_type_map *map) static inline void init_type(struct type *type, struct spa_type_map *map)
{ {
type->node = spa_type_map_get_id(map, SPA_TYPE__Node); type->node = spa_type_map_get_id(map, SPA_TYPE__Node);
type->clock = spa_type_map_get_id(map, SPA_TYPE__Clock);
type->format = spa_type_map_get_id(map, SPA_TYPE__Format); type->format = spa_type_map_get_id(map, SPA_TYPE__Format);
type->props = spa_type_map_get_id(map, SPA_TYPE__Props); type->props = spa_type_map_get_id(map, SPA_TYPE__Props);
type->prop_live = spa_type_map_get_id(map, SPA_TYPE_PROPS__live); type->prop_live = spa_type_map_get_id(map, SPA_TYPE_PROPS__live);
@ -141,7 +138,6 @@ typedef int (*render_func_t) (struct impl *this, void *samples, size_t n_samples
struct impl { struct impl {
struct spa_handle handle; struct spa_handle handle;
struct spa_node node; struct spa_node node;
struct spa_clock clock;
struct type type; struct type type;
struct spa_type_map *map; struct spa_type_map *map;
@ -1069,52 +1065,6 @@ static const struct spa_node impl_node = {
impl_node_process, impl_node_process,
}; };
static int impl_clock_enum_params(struct spa_clock *clock, uint32_t id, uint32_t *index,
struct spa_pod **param, struct spa_pod_builder *builder)
{
return -ENOTSUP;
}
static int impl_clock_set_param(struct spa_clock *clock, uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
return -ENOTSUP;
}
static int
impl_clock_get_time(struct spa_clock *clock,
int32_t *rate,
int64_t *ticks,
int64_t *monotonic_time)
{
struct timespec now;
uint64_t tnow;
spa_return_val_if_fail(clock != NULL, -EINVAL);
if (rate)
*rate = SPA_NSEC_PER_SEC;
clock_gettime(CLOCK_MONOTONIC, &now);
tnow = SPA_TIMESPEC_TO_TIME(&now);
if (ticks)
*ticks = tnow;
if (monotonic_time)
*monotonic_time = tnow;
return 0;
}
static const struct spa_clock impl_clock = {
SPA_VERSION_CLOCK,
NULL,
SPA_CLOCK_STATE_STOPPED,
impl_clock_enum_params,
impl_clock_set_param,
impl_clock_get_time,
};
static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface) static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface)
{ {
struct impl *this; struct impl *this;
@ -1126,8 +1076,6 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
if (interface_id == this->type.node) if (interface_id == this->type.node)
*interface = &this->node; *interface = &this->node;
else if (interface_id == this->type.clock)
*interface = &this->clock;
else else
return -ENOENT; return -ENOENT;
@ -1189,7 +1137,6 @@ impl_init(const struct spa_handle_factory *factory,
init_type(&this->type, this->map); init_type(&this->type, this->map);
this->node = impl_node; this->node = impl_node;
this->clock = impl_clock;
reset_props(&this->props); reset_props(&this->props);
this->io_wave = &this->props.wave; this->io_wave = &this->props.wave;
@ -1222,7 +1169,6 @@ impl_init(const struct spa_handle_factory *factory,
static const struct spa_interface_info impl_interfaces[] = { static const struct spa_interface_info impl_interfaces[] = {
{SPA_TYPE__Node,}, {SPA_TYPE__Node,},
{SPA_TYPE__Clock,},
}; };
static int static int

View file

@ -29,7 +29,6 @@
#include <spa/support/log.h> #include <spa/support/log.h>
#include <spa/utils/list.h> #include <spa/utils/list.h>
#include <spa/clock/clock.h>
#include <spa/node/node.h> #include <spa/node/node.h>
#include <spa/node/io.h> #include <spa/node/io.h>
#include <spa/param/buffers.h> #include <spa/param/buffers.h>
@ -62,7 +61,6 @@ struct buffer {
struct type { struct type {
uint32_t node; uint32_t node;
uint32_t clock;
uint32_t format; uint32_t format;
uint32_t props; uint32_t props;
uint32_t prop_min_latency; uint32_t prop_min_latency;
@ -85,7 +83,6 @@ struct type {
static inline void init_type(struct type *type, struct spa_type_map *map) static inline void init_type(struct type *type, struct spa_type_map *map)
{ {
type->node = spa_type_map_get_id(map, SPA_TYPE__Node); type->node = spa_type_map_get_id(map, SPA_TYPE__Node);
type->clock = spa_type_map_get_id(map, SPA_TYPE__Clock);
type->format = spa_type_map_get_id(map, SPA_TYPE__Format); type->format = spa_type_map_get_id(map, SPA_TYPE__Format);
type->props = spa_type_map_get_id(map, SPA_TYPE__Props); type->props = spa_type_map_get_id(map, SPA_TYPE__Props);
type->prop_min_latency = spa_type_map_get_id(map, SPA_TYPE_PROPS__minLatency); type->prop_min_latency = spa_type_map_get_id(map, SPA_TYPE_PROPS__minLatency);
@ -109,7 +106,6 @@ static inline void init_type(struct type *type, struct spa_type_map *map)
struct impl { struct impl {
struct spa_handle handle; struct spa_handle handle;
struct spa_node node; struct spa_node node;
struct spa_clock clock;
uint32_t seq; uint32_t seq;

View file

@ -28,7 +28,6 @@
#include <spa/support/log.h> #include <spa/support/log.h>
#include <spa/support/loop.h> #include <spa/support/loop.h>
#include <spa/utils/list.h> #include <spa/utils/list.h>
#include <spa/clock/clock.h>
#include <spa/node/node.h> #include <spa/node/node.h>
#include <spa/node/io.h> #include <spa/node/io.h>
#include <spa/param/buffers.h> #include <spa/param/buffers.h>
@ -42,7 +41,6 @@
struct type { struct type {
uint32_t node; uint32_t node;
uint32_t clock;
uint32_t format; uint32_t format;
uint32_t props; uint32_t props;
uint32_t prop_live; uint32_t prop_live;
@ -59,7 +57,6 @@ struct type {
static inline void init_type(struct type *type, struct spa_type_map *map) static inline void init_type(struct type *type, struct spa_type_map *map)
{ {
type->node = spa_type_map_get_id(map, SPA_TYPE__Node); type->node = spa_type_map_get_id(map, SPA_TYPE__Node);
type->clock = spa_type_map_get_id(map, SPA_TYPE__Clock);
type->format = spa_type_map_get_id(map, SPA_TYPE__Format); type->format = spa_type_map_get_id(map, SPA_TYPE__Format);
type->props = spa_type_map_get_id(map, SPA_TYPE__Props); type->props = spa_type_map_get_id(map, SPA_TYPE__Props);
type->prop_live = spa_type_map_get_id(map, SPA_TYPE_PROPS__live); type->prop_live = spa_type_map_get_id(map, SPA_TYPE_PROPS__live);
@ -90,7 +87,6 @@ struct buffer {
struct impl { struct impl {
struct spa_handle handle; struct spa_handle handle;
struct spa_node node; struct spa_node node;
struct spa_clock clock;
struct type type; struct type type;
struct spa_type_map *map; struct spa_type_map *map;
@ -763,52 +759,6 @@ static const struct spa_node impl_node = {
impl_node_process, impl_node_process,
}; };
static int impl_clock_enum_params(struct spa_clock *clock, uint32_t id, uint32_t *index,
struct spa_pod **param, struct spa_pod_builder *builder)
{
return -ENOTSUP;
}
static int impl_clock_set_param(struct spa_clock *clock, uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
return -ENOTSUP;
}
static int
impl_clock_get_time(struct spa_clock *clock,
int32_t *rate,
int64_t *ticks,
int64_t *monotonic_time)
{
struct timespec now;
uint64_t tnow;
spa_return_val_if_fail(clock != NULL, -EINVAL);
if (rate)
*rate = SPA_NSEC_PER_SEC;
clock_gettime(CLOCK_MONOTONIC, &now);
tnow = SPA_TIMESPEC_TO_TIME(&now);
if (ticks)
*ticks = tnow;
if (monotonic_time)
*monotonic_time = tnow;
return 0;
}
static const struct spa_clock impl_clock = {
SPA_VERSION_CLOCK,
NULL,
SPA_CLOCK_STATE_STOPPED,
impl_clock_enum_params,
impl_clock_set_param,
impl_clock_get_time,
};
static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface) static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface)
{ {
struct impl *this; struct impl *this;
@ -820,8 +770,6 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
if (interface_id == this->type.node) if (interface_id == this->type.node)
*interface = &this->node; *interface = &this->node;
else if (interface_id == this->type.clock)
*interface = &this->clock;
else else
return -ENOENT; return -ENOENT;
@ -883,7 +831,6 @@ impl_init(const struct spa_handle_factory *factory,
init_type(&this->type, this->map); init_type(&this->type, this->map);
this->node = impl_node; this->node = impl_node;
this->clock = impl_clock;
reset_props(this, &this->props); reset_props(this, &this->props);
spa_list_init(&this->ready); spa_list_init(&this->ready);
@ -912,7 +859,6 @@ impl_init(const struct spa_handle_factory *factory,
static const struct spa_interface_info impl_interfaces[] = { static const struct spa_interface_info impl_interfaces[] = {
{SPA_TYPE__Node,}, {SPA_TYPE__Node,},
{SPA_TYPE__Clock,},
}; };
static int static int

View file

@ -28,7 +28,6 @@
#include <spa/support/log.h> #include <spa/support/log.h>
#include <spa/support/loop.h> #include <spa/support/loop.h>
#include <spa/utils/list.h> #include <spa/utils/list.h>
#include <spa/clock/clock.h>
#include <spa/node/node.h> #include <spa/node/node.h>
#include <spa/node/io.h> #include <spa/node/io.h>
#include <spa/param/buffers.h> #include <spa/param/buffers.h>
@ -42,7 +41,6 @@
struct type { struct type {
uint32_t node; uint32_t node;
uint32_t clock;
uint32_t format; uint32_t format;
uint32_t props; uint32_t props;
uint32_t prop_live; uint32_t prop_live;
@ -60,7 +58,6 @@ struct type {
static inline void init_type(struct type *type, struct spa_type_map *map) static inline void init_type(struct type *type, struct spa_type_map *map)
{ {
type->node = spa_type_map_get_id(map, SPA_TYPE__Node); type->node = spa_type_map_get_id(map, SPA_TYPE__Node);
type->clock = spa_type_map_get_id(map, SPA_TYPE__Clock);
type->format = spa_type_map_get_id(map, SPA_TYPE__Format); type->format = spa_type_map_get_id(map, SPA_TYPE__Format);
type->props = spa_type_map_get_id(map, SPA_TYPE__Props); type->props = spa_type_map_get_id(map, SPA_TYPE__Props);
type->prop_live = spa_type_map_get_id(map, SPA_TYPE_PROPS__live); type->prop_live = spa_type_map_get_id(map, SPA_TYPE_PROPS__live);
@ -93,7 +90,6 @@ struct buffer {
struct impl { struct impl {
struct spa_handle handle; struct spa_handle handle;
struct spa_node node; struct spa_node node;
struct spa_clock clock;
struct type type; struct type type;
struct spa_type_map *map; struct spa_type_map *map;
@ -795,52 +791,6 @@ static const struct spa_node impl_node = {
impl_node_process, impl_node_process,
}; };
static int impl_clock_enum_params(struct spa_clock *clock, uint32_t id, uint32_t *index,
struct spa_pod **param, struct spa_pod_builder *builder)
{
return -ENOTSUP;
}
static int impl_clock_set_param(struct spa_clock *clock, uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
return -ENOTSUP;
}
static int
impl_clock_get_time(struct spa_clock *clock,
int32_t *rate,
int64_t *ticks,
int64_t *monotonic_time)
{
struct timespec now;
uint64_t tnow;
spa_return_val_if_fail(clock != NULL, -EINVAL);
if (rate)
*rate = SPA_NSEC_PER_SEC;
clock_gettime(CLOCK_MONOTONIC, &now);
tnow = SPA_TIMESPEC_TO_TIME(&now);
if (ticks)
*ticks = tnow;
if (monotonic_time)
*monotonic_time = tnow;
return 0;
}
static const struct spa_clock impl_clock = {
SPA_VERSION_CLOCK,
NULL,
SPA_CLOCK_STATE_STOPPED,
impl_clock_enum_params,
impl_clock_set_param,
impl_clock_get_time,
};
static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface) static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface)
{ {
struct impl *this; struct impl *this;
@ -852,8 +802,6 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
if (interface_id == this->type.node) if (interface_id == this->type.node)
*interface = &this->node; *interface = &this->node;
else if (interface_id == this->type.clock)
*interface = &this->clock;
else else
return -ENOENT; return -ENOENT;
@ -915,7 +863,6 @@ impl_init(const struct spa_handle_factory *factory,
init_type(&this->type, this->map); init_type(&this->type, this->map);
this->node = impl_node; this->node = impl_node;
this->clock = impl_clock;
reset_props(this, &this->props); reset_props(this, &this->props);
spa_list_init(&this->empty); spa_list_init(&this->empty);
@ -944,7 +891,6 @@ impl_init(const struct spa_handle_factory *factory,
static const struct spa_interface_info impl_interfaces[] = { static const struct spa_interface_info impl_interfaces[] = {
{SPA_TYPE__Node,}, {SPA_TYPE__Node,},
{SPA_TYPE__Clock,},
}; };
static int static int

View file

@ -28,7 +28,6 @@
#include <spa/support/log.h> #include <spa/support/log.h>
#include <spa/support/loop.h> #include <spa/support/loop.h>
#include <spa/utils/list.h> #include <spa/utils/list.h>
#include <spa/clock/clock.h>
#include <spa/node/node.h> #include <spa/node/node.h>
#include <spa/node/io.h> #include <spa/node/io.h>
#include <spa/param/video/format-utils.h> #include <spa/param/video/format-utils.h>
@ -71,7 +70,6 @@ struct buffer {
struct type { struct type {
uint32_t node; uint32_t node;
uint32_t clock;
uint32_t format; uint32_t format;
uint32_t props; uint32_t props;
uint32_t prop_unknown; uint32_t prop_unknown;
@ -105,7 +103,6 @@ struct type {
static inline void init_type(struct type *type, struct spa_type_map *map) static inline void init_type(struct type *type, struct spa_type_map *map)
{ {
type->node = spa_type_map_get_id(map, SPA_TYPE__Node); type->node = spa_type_map_get_id(map, SPA_TYPE__Node);
type->clock = spa_type_map_get_id(map, SPA_TYPE__Clock);
type->format = spa_type_map_get_id(map, SPA_TYPE__Format); type->format = spa_type_map_get_id(map, SPA_TYPE__Format);
type->props = spa_type_map_get_id(map, SPA_TYPE__Props); type->props = spa_type_map_get_id(map, SPA_TYPE__Props);
type->prop_unknown = spa_type_map_get_id(map, SPA_TYPE_PROPS__unknown); type->prop_unknown = spa_type_map_get_id(map, SPA_TYPE_PROPS__unknown);
@ -189,7 +186,6 @@ struct port {
struct impl { struct impl {
struct spa_handle handle; struct spa_handle handle;
struct spa_node node; struct spa_node node;
struct spa_clock clock;
struct spa_type_map *map; struct spa_type_map *map;
struct spa_log *log; struct spa_log *log;
@ -905,52 +901,6 @@ static const struct spa_node impl_node = {
impl_node_process, impl_node_process,
}; };
static int impl_clock_enum_params(struct spa_clock *clock, uint32_t id, uint32_t *index,
struct spa_pod **param,
struct spa_pod_builder *builder)
{
return -ENOTSUP;
}
static int impl_clock_set_param(struct spa_clock *clock,
uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
return -ENOTSUP;
}
static int impl_clock_get_time(struct spa_clock *clock,
int32_t *rate,
int64_t *ticks,
int64_t *monotonic_time)
{
struct impl *this;
struct port *port;
spa_return_val_if_fail(clock != NULL, -EINVAL);
this = SPA_CONTAINER_OF(clock, struct impl, clock);
port = GET_OUT_PORT(this, 0);
if (rate)
*rate = SPA_USEC_PER_SEC;
if (ticks)
*ticks = port->last_ticks;
if (monotonic_time)
*monotonic_time = port->last_monotonic;
return 0;
}
static const struct spa_clock impl_clock = {
SPA_VERSION_CLOCK,
NULL,
SPA_CLOCK_STATE_STOPPED,
impl_clock_enum_params,
impl_clock_set_param,
impl_clock_get_time,
};
static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface) static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface)
{ {
struct impl *this; struct impl *this;
@ -962,8 +912,6 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
if (interface_id == this->type.node) if (interface_id == this->type.node)
*interface = &this->node; *interface = &this->node;
else if (interface_id == this->type.clock)
*interface = &this->clock;
else else
return -ENOENT; return -ENOENT;
@ -1028,7 +976,6 @@ impl_init(const struct spa_handle_factory *factory,
init_type(&this->type, this->map); init_type(&this->type, this->map);
this->node = impl_node; this->node = impl_node;
this->clock = impl_clock;
reset_props(&this->props); reset_props(&this->props);
@ -1053,7 +1000,6 @@ impl_init(const struct spa_handle_factory *factory,
static const struct spa_interface_info impl_interfaces[] = { static const struct spa_interface_info impl_interfaces[] = {
{SPA_TYPE__Node,}, {SPA_TYPE__Node,},
{SPA_TYPE__Clock,},
}; };
static int impl_enum_interface_info(const struct spa_handle_factory *factory, static int impl_enum_interface_info(const struct spa_handle_factory *factory,

View file

@ -29,7 +29,6 @@
#include <spa/support/log.h> #include <spa/support/log.h>
#include <spa/support/loop.h> #include <spa/support/loop.h>
#include <spa/utils/list.h> #include <spa/utils/list.h>
#include <spa/clock/clock.h>
#include <spa/node/node.h> #include <spa/node/node.h>
#include <spa/node/io.h> #include <spa/node/io.h>
#include <spa/param/video/format-utils.h> #include <spa/param/video/format-utils.h>
@ -45,7 +44,6 @@
struct type { struct type {
uint32_t node; uint32_t node;
uint32_t clock;
uint32_t format; uint32_t format;
uint32_t props; uint32_t props;
uint32_t prop_live; uint32_t prop_live;
@ -67,7 +65,6 @@ struct type {
static inline void init_type(struct type *type, struct spa_type_map *map) static inline void init_type(struct type *type, struct spa_type_map *map)
{ {
type->node = spa_type_map_get_id(map, SPA_TYPE__Node); type->node = spa_type_map_get_id(map, SPA_TYPE__Node);
type->clock = spa_type_map_get_id(map, SPA_TYPE__Clock);
type->format = spa_type_map_get_id(map, SPA_TYPE__Format); type->format = spa_type_map_get_id(map, SPA_TYPE__Format);
type->props = spa_type_map_get_id(map, SPA_TYPE__Props); type->props = spa_type_map_get_id(map, SPA_TYPE__Props);
type->prop_live = spa_type_map_get_id(map, SPA_TYPE_PROPS__live); type->prop_live = spa_type_map_get_id(map, SPA_TYPE_PROPS__live);
@ -118,7 +115,6 @@ struct buffer {
struct impl { struct impl {
struct spa_handle handle; struct spa_handle handle;
struct spa_node node; struct spa_node node;
struct spa_clock clock;
struct type type; struct type type;
struct spa_type_map *map; struct spa_type_map *map;
@ -908,53 +904,6 @@ static const struct spa_node impl_node = {
impl_node_process, impl_node_process,
}; };
static int impl_clock_enum_params(struct spa_clock *clock, uint32_t id, uint32_t *index,
struct spa_pod **param,
struct spa_pod_builder *builder)
{
return -ENOTSUP;
}
static int impl_clock_set_param(struct spa_clock *clock, uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
return -ENOTSUP;
}
static int
impl_clock_get_time(struct spa_clock *clock,
int32_t *rate,
int64_t *ticks,
int64_t *monotonic_time)
{
struct timespec now;
uint64_t tnow;
spa_return_val_if_fail(clock != NULL, -EINVAL);
if (rate)
*rate = SPA_NSEC_PER_SEC;
clock_gettime(CLOCK_MONOTONIC, &now);
tnow = SPA_TIMESPEC_TO_TIME(&now);
if (ticks)
*ticks = tnow;
if (monotonic_time)
*monotonic_time = tnow;
return 0;
}
static const struct spa_clock impl_clock = {
SPA_VERSION_CLOCK,
NULL,
SPA_CLOCK_STATE_STOPPED,
impl_clock_enum_params,
impl_clock_set_param,
impl_clock_get_time,
};
static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface) static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface)
{ {
struct impl *this; struct impl *this;
@ -966,8 +915,6 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
if (interface_id == this->type.node) if (interface_id == this->type.node)
*interface = &this->node; *interface = &this->node;
else if (interface_id == this->type.clock)
*interface = &this->clock;
else else
return -ENOENT; return -ENOENT;
@ -1029,7 +976,6 @@ impl_init(const struct spa_handle_factory *factory,
init_type(&this->type, this->map); init_type(&this->type, this->map);
this->node = impl_node; this->node = impl_node;
this->clock = impl_clock;
reset_props(&this->props); reset_props(&this->props);
spa_list_init(&this->empty); spa_list_init(&this->empty);
@ -1058,7 +1004,6 @@ impl_init(const struct spa_handle_factory *factory,
static const struct spa_interface_info impl_interfaces[] = { static const struct spa_interface_info impl_interfaces[] = {
{SPA_TYPE__Node,}, {SPA_TYPE__Node,},
{SPA_TYPE__Clock,},
}; };
static int static int

View file

@ -27,7 +27,6 @@
#include <spa/support/type-map-impl.h> #include <spa/support/type-map-impl.h>
#include <spa/support/log-impl.h> #include <spa/support/log-impl.h>
#include <spa/support/loop.h> #include <spa/support/loop.h>
#include <spa/clock/clock.h>
#include <spa/node/node.h> #include <spa/node/node.h>
#include <spa/pod/parser.h> #include <spa/pod/parser.h>
#include <spa/param/param.h> #include <spa/param/param.h>
@ -40,7 +39,6 @@ static SPA_LOG_IMPL(default_log);
struct type { struct type {
uint32_t node; uint32_t node;
uint32_t clock;
uint32_t format; uint32_t format;
struct spa_type_param param; struct spa_type_param param;
}; };
@ -298,7 +296,6 @@ int main(int argc, char *argv[])
data.n_support = 4; data.n_support = 4;
data.type.node = spa_type_map_get_id(data.map, SPA_TYPE__Node); data.type.node = spa_type_map_get_id(data.map, SPA_TYPE__Node);
data.type.clock = spa_type_map_get_id(data.map, SPA_TYPE__Clock);
data.type.format = spa_type_map_get_id(data.map, SPA_TYPE__Format); data.type.format = spa_type_map_get_id(data.map, SPA_TYPE__Format);
spa_type_param_map(data.map, &data.type.param); spa_type_param_map(data.map, &data.type.param);

View file

@ -120,20 +120,11 @@ pw_spa_node_new(struct pw_core *core,
{ {
struct pw_node *this; struct pw_node *this;
struct impl *impl; struct impl *impl;
void *iface = NULL;
struct pw_type *t = pw_core_get_type(core);
int res;
this = pw_node_new(core, name, properties, sizeof(struct impl) + user_data_size); this = pw_node_new(core, name, properties, sizeof(struct impl) + user_data_size);
if (this == NULL) if (this == NULL)
return NULL; return NULL;
if (handle) {
if ((res = spa_handle_get_interface(handle, t->spa_clock, &iface)) < 0)
iface = NULL;
this->clock = iface;
}
impl = this->user_data; impl = this->user_data;
impl->this = this; impl->this = this;
impl->owner = owner; impl->owner = owner;

View file

@ -20,7 +20,6 @@
#ifndef __PIPEWIRE_SPA_NODE_H__ #ifndef __PIPEWIRE_SPA_NODE_H__
#define __PIPEWIRE_SPA_NODE_H__ #define __PIPEWIRE_SPA_NODE_H__
#include <spa/clock/clock.h>
#include <spa/node/node.h> #include <spa/node/node.h>
#include <pipewire/core.h> #include <pipewire/core.h>

View file

@ -1218,11 +1218,9 @@ struct pw_link *pw_link_new(struct pw_core *core,
pw_node_add_listener(output_node, &impl->output_node_listener, &output_node_events, impl); pw_node_add_listener(output_node, &impl->output_node_listener, &output_node_events, impl);
input_node->live = output_node->live; input_node->live = output_node->live;
if (output_node->clock)
input_node->clock = output_node->clock;
pw_log_debug("link %p: output node %p clock %p, live %d", pw_log_debug("link %p: output node %p live %d",
this, output_node, output_node->clock, output_node->live); this, output_node, output_node->live);
spa_list_append(&output->links, &this->output_link); spa_list_append(&output->links, &this->output_link);
spa_list_append(&input->links, &this->input_link); spa_list_append(&input->links, &this->input_link);

View file

@ -23,7 +23,6 @@
#include <errno.h> #include <errno.h>
#include <time.h> #include <time.h>
#include <spa/clock/clock.h>
#include <spa/lib/debug.h> #include <spa/lib/debug.h>
#include <spa/pod/parser.h> #include <spa/pod/parser.h>

View file

@ -305,9 +305,9 @@ static int do_add_port(struct spa_loop *loop,
out = &this->node->rt.node; out = &this->node->rt.node;
in = &this->rt.mix_node; in = &this->rt.mix_node;
} }
spa_graph_link_add(out, in->state, &this->rt.mix_link);
this->rt.mix_link.signal = spa_graph_link_signal_node; this->rt.mix_link.signal = spa_graph_link_signal_node;
this->rt.mix_link.signal_data = in; this->rt.mix_link.signal_data = in;
spa_graph_link_add(out, in->state, &this->rt.mix_link);
return 0; return 0;
} }

View file

@ -269,7 +269,6 @@ struct pw_node {
struct spa_list driver_list; struct spa_list driver_list;
struct spa_list driver_link; struct spa_list driver_link;
struct spa_clock *clock; /**< handle to SPA clock if any */
struct spa_node *node; /**< SPA node implementation */ struct spa_node *node; /**< SPA node implementation */
struct spa_list resource_list; /**< list of resources for this node */ struct spa_list resource_list; /**< list of resources for this node */

View file

@ -21,7 +21,6 @@
#include <spa/support/type-map.h> #include <spa/support/type-map.h>
#include <spa/utils/defs.h> #include <spa/utils/defs.h>
#include <spa/clock/clock.h>
#include <spa/param/format.h> #include <spa/param/format.h>
#include <spa/param/props.h> #include <spa/param/props.h>
#include <spa/monitor/monitor.h> #include <spa/monitor/monitor.h>
@ -50,7 +49,6 @@ int pw_type_init(struct pw_type *type)
type->spa_log = spa_type_map_get_id(type->map, SPA_TYPE__Log); type->spa_log = spa_type_map_get_id(type->map, SPA_TYPE__Log);
type->spa_node = spa_type_map_get_id(type->map, SPA_TYPE__Node); type->spa_node = spa_type_map_get_id(type->map, SPA_TYPE__Node);
type->spa_clock = spa_type_map_get_id(type->map, SPA_TYPE__Clock);
type->spa_monitor = spa_type_map_get_id(type->map, SPA_TYPE__Monitor); type->spa_monitor = spa_type_map_get_id(type->map, SPA_TYPE__Monitor);
type->spa_format = spa_type_map_get_id(type->map, SPA_TYPE__Format); type->spa_format = spa_type_map_get_id(type->map, SPA_TYPE__Format);
type->spa_props = spa_type_map_get_id(type->map, SPA_TYPE__Props); type->spa_props = spa_type_map_get_id(type->map, SPA_TYPE__Props);