diff --git a/spa/include/spa/clock/clock.h b/spa/include/spa/clock/clock.h deleted file mode 100644 index f3bb0d0e1..000000000 --- a/spa/include/spa/clock/clock.h +++ /dev/null @@ -1,127 +0,0 @@ -/* Simple Plugin API - * Copyright (C) 2016 Wim Taymans - * - * 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 -#include - -/** - * 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__ */ diff --git a/spa/include/spa/meson.build b/spa/include/spa/meson.build index 6187a4aa4..cae70833d 100644 --- a/spa/include/spa/meson.build +++ b/spa/include/spa/meson.build @@ -6,13 +6,6 @@ spa_buffer_headers = [ install_headers(spa_buffer_headers, subdir : 'spa/buffer') -spa_clock_headers = [ - 'clock/clock.h', -] - -install_headers(spa_clock_headers, - subdir : 'spa/clock') - spa_graph_headers = [ 'graph/graph.h', ] diff --git a/spa/include/spa/node/event.h b/spa/include/spa/node/event.h index 9b1ac5cd9..98499813b 100644 --- a/spa/include/spa/node/event.h +++ b/spa/include/spa/node/event.h @@ -35,13 +35,11 @@ extern "C" { #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__RequestRefresh SPA_TYPE_EVENT_NODE_BASE "RequestRefresh" -#define SPA_TYPE_EVENT_NODE__RequestClockUpdate SPA_TYPE_EVENT_NODE_BASE "RequestClockUpdate" struct spa_type_event_node { uint32_t Error; uint32_t Buffering; uint32_t RequestRefresh; - uint32_t RequestClockUpdate; }; 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->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->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 } /* extern "C" */ #endif diff --git a/spa/include/spa/node/io.h b/spa/include/spa/node/io.h index 95ae9f037..8c60ebe5d 100644 --- a/spa/include/spa/node/io.h +++ b/spa/include/spa/node/io.h @@ -41,6 +41,9 @@ extern "C" { /** An io area to exchange buffers with a port */ #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 * * 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 */ }; +/** 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 { uint32_t Buffers; uint32_t ControlRange; uint32_t Prop; + uint32_t Clock; }; 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->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->Clock = spa_type_map_get_id(map, SPA_TYPE_IO__Clock); } } diff --git a/spa/plugins/alsa/alsa-sink.c b/spa/plugins/alsa/alsa-sink.c index 44dc88365..efb6387c6 100644 --- a/spa/plugins/alsa/alsa-sink.c +++ b/spa/plugins/alsa/alsa-sink.c @@ -556,6 +556,8 @@ impl_node_port_set_io(struct spa_node *node, this->io = data; else if (id == t->io.ControlRange) this->range = data; + else if (id == t->io.Clock) + this->clock = data; else return -ENOENT; diff --git a/spa/plugins/alsa/alsa-source.c b/spa/plugins/alsa/alsa-source.c index 7f5066d09..c4961980c 100644 --- a/spa/plugins/alsa/alsa-source.c +++ b/spa/plugins/alsa/alsa-source.c @@ -577,6 +577,8 @@ impl_node_port_set_io(struct spa_node *node, if (id == t->io.Buffers) this->io = data; + else if (id == t->io.Clock) + this->clock = data; else return -ENOENT; @@ -678,50 +680,6 @@ static const struct spa_node impl_node = { 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) { 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) *interface = &this->node; - else if (interface_id == this->type.clock) - *interface = &this->clock; else return -ENOENT; @@ -796,7 +752,6 @@ impl_init(const struct spa_handle_factory *factory, init_type(&this->type, this->map); this->node = impl_node; - this->clock = impl_clock; this->stream = SND_PCM_STREAM_CAPTURE; reset_props(&this->props); @@ -818,7 +773,6 @@ impl_init(const struct spa_handle_factory *factory, static const struct spa_interface_info impl_interfaces[] = { {SPA_TYPE__Node,}, - {SPA_TYPE__Clock,}, }; static int diff --git a/spa/plugins/alsa/alsa-utils.c b/spa/plugins/alsa/alsa-utils.c index 72b790900..5791ec34e 100644 --- a/spa/plugins/alsa/alsa-utils.c +++ b/spa/plugins/alsa/alsa-utils.c @@ -487,7 +487,7 @@ push_frames(struct state *state, if (b->h) { 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; } @@ -562,8 +562,11 @@ static void alsa_on_playback_timeout_event(struct spa_source *source) state->filled = state->buffer_frames - avail; - state->last_ticks = state->sample_count - state->filled; - state->last_monotonic = (int64_t) state->now.tv_sec * SPA_NSEC_PER_SEC + (int64_t) state->now.tv_nsec; + if (state->clock) { + 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, 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; struct timespec now; - if (state->started && read(state->timerfd, &exp, sizeof(uint64_t)) != sizeof(uint64_t)) 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); clock_gettime(CLOCK_MONOTONIC, &now); - state->last_ticks = state->sample_count + avail; - state->last_monotonic = (int64_t) state->now.tv_sec * SPA_NSEC_PER_SEC + (int64_t) state->now.tv_nsec; + if (state->clock) { + 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, state->sample_count, state->now.tv_sec, state->now.tv_nsec, diff --git a/spa/plugins/alsa/alsa-utils.h b/spa/plugins/alsa/alsa-utils.h index a446fb6f9..79ebe6bdf 100644 --- a/spa/plugins/alsa/alsa-utils.h +++ b/spa/plugins/alsa/alsa-utils.h @@ -33,7 +33,6 @@ extern "C" { #include #include -#include #include #include #include @@ -63,7 +62,6 @@ struct buffer { struct type { uint32_t node; - uint32_t clock; uint32_t format; uint32_t props; uint32_t prop_device; @@ -89,7 +87,6 @@ struct type { 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->clock = spa_type_map_get_id(map, SPA_TYPE__Clock); type->format = spa_type_map_get_id(map, SPA_TYPE__Format); type->props = spa_type_map_get_id(map, SPA_TYPE__Props); 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 spa_handle handle; struct spa_node node; - struct spa_clock clock; uint32_t seq; @@ -150,6 +146,7 @@ struct state { struct spa_port_info info; struct spa_io_buffers *io; struct spa_io_control_range *range; + struct spa_io_clock *clock; struct buffer buffers[MAX_BUFFERS]; unsigned int n_buffers; @@ -168,8 +165,6 @@ struct state { snd_htimestamp_t now; int64_t sample_count; int64_t filled; - int64_t last_ticks; - int64_t last_monotonic; uint64_t underrun; }; diff --git a/spa/plugins/audiotestsrc/audiotestsrc.c b/spa/plugins/audiotestsrc/audiotestsrc.c index fab8a2260..519c9a145 100644 --- a/spa/plugins/audiotestsrc/audiotestsrc.c +++ b/spa/plugins/audiotestsrc/audiotestsrc.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -46,7 +45,6 @@ struct type { uint32_t node; - uint32_t clock; uint32_t format; uint32_t props; uint32_t prop_live; @@ -74,7 +72,6 @@ struct type { 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->clock = spa_type_map_get_id(map, SPA_TYPE__Clock); type->format = spa_type_map_get_id(map, SPA_TYPE__Format); type->props = spa_type_map_get_id(map, SPA_TYPE__Props); 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 spa_handle handle; struct spa_node node; - struct spa_clock clock; struct type type; struct spa_type_map *map; @@ -1069,52 +1065,6 @@ static const struct spa_node impl_node = { 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) { 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) *interface = &this->node; - else if (interface_id == this->type.clock) - *interface = &this->clock; else return -ENOENT; @@ -1189,7 +1137,6 @@ impl_init(const struct spa_handle_factory *factory, init_type(&this->type, this->map); this->node = impl_node; - this->clock = impl_clock; reset_props(&this->props); 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[] = { {SPA_TYPE__Node,}, - {SPA_TYPE__Clock,}, }; static int diff --git a/spa/plugins/bluez5/a2dp-sink.c b/spa/plugins/bluez5/a2dp-sink.c index ae3860686..d621afbf5 100644 --- a/spa/plugins/bluez5/a2dp-sink.c +++ b/spa/plugins/bluez5/a2dp-sink.c @@ -29,7 +29,6 @@ #include #include -#include #include #include #include @@ -62,7 +61,6 @@ struct buffer { struct type { uint32_t node; - uint32_t clock; uint32_t format; uint32_t props; uint32_t prop_min_latency; @@ -85,7 +83,6 @@ struct type { 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->clock = spa_type_map_get_id(map, SPA_TYPE__Clock); type->format = spa_type_map_get_id(map, SPA_TYPE__Format); 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); @@ -109,7 +106,6 @@ static inline void init_type(struct type *type, struct spa_type_map *map) struct impl { struct spa_handle handle; struct spa_node node; - struct spa_clock clock; uint32_t seq; diff --git a/spa/plugins/test/fakesink.c b/spa/plugins/test/fakesink.c index db245c6c3..4f1ded250 100644 --- a/spa/plugins/test/fakesink.c +++ b/spa/plugins/test/fakesink.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -42,7 +41,6 @@ struct type { uint32_t node; - uint32_t clock; uint32_t format; uint32_t props; uint32_t prop_live; @@ -59,7 +57,6 @@ struct type { 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->clock = spa_type_map_get_id(map, SPA_TYPE__Clock); type->format = spa_type_map_get_id(map, SPA_TYPE__Format); type->props = spa_type_map_get_id(map, SPA_TYPE__Props); type->prop_live = spa_type_map_get_id(map, SPA_TYPE_PROPS__live); @@ -90,7 +87,6 @@ struct buffer { struct impl { struct spa_handle handle; struct spa_node node; - struct spa_clock clock; struct type type; struct spa_type_map *map; @@ -763,52 +759,6 @@ static const struct spa_node impl_node = { 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) { 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) *interface = &this->node; - else if (interface_id == this->type.clock) - *interface = &this->clock; else return -ENOENT; @@ -883,7 +831,6 @@ impl_init(const struct spa_handle_factory *factory, init_type(&this->type, this->map); this->node = impl_node; - this->clock = impl_clock; reset_props(this, &this->props); 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[] = { {SPA_TYPE__Node,}, - {SPA_TYPE__Clock,}, }; static int diff --git a/spa/plugins/test/fakesrc.c b/spa/plugins/test/fakesrc.c index cad0351f2..2c2c0e7f3 100644 --- a/spa/plugins/test/fakesrc.c +++ b/spa/plugins/test/fakesrc.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -42,7 +41,6 @@ struct type { uint32_t node; - uint32_t clock; uint32_t format; uint32_t props; uint32_t prop_live; @@ -60,7 +58,6 @@ struct type { 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->clock = spa_type_map_get_id(map, SPA_TYPE__Clock); type->format = spa_type_map_get_id(map, SPA_TYPE__Format); type->props = spa_type_map_get_id(map, SPA_TYPE__Props); type->prop_live = spa_type_map_get_id(map, SPA_TYPE_PROPS__live); @@ -93,7 +90,6 @@ struct buffer { struct impl { struct spa_handle handle; struct spa_node node; - struct spa_clock clock; struct type type; struct spa_type_map *map; @@ -795,52 +791,6 @@ static const struct spa_node impl_node = { 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) { 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) *interface = &this->node; - else if (interface_id == this->type.clock) - *interface = &this->clock; else return -ENOENT; @@ -915,7 +863,6 @@ impl_init(const struct spa_handle_factory *factory, init_type(&this->type, this->map); this->node = impl_node; - this->clock = impl_clock; reset_props(this, &this->props); 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[] = { {SPA_TYPE__Node,}, - {SPA_TYPE__Clock,}, }; static int diff --git a/spa/plugins/v4l2/v4l2-source.c b/spa/plugins/v4l2/v4l2-source.c index 1c4651c0d..cce6697e4 100644 --- a/spa/plugins/v4l2/v4l2-source.c +++ b/spa/plugins/v4l2/v4l2-source.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -71,7 +70,6 @@ struct buffer { struct type { uint32_t node; - uint32_t clock; uint32_t format; uint32_t props; uint32_t prop_unknown; @@ -105,7 +103,6 @@ struct type { 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->clock = spa_type_map_get_id(map, SPA_TYPE__Clock); type->format = spa_type_map_get_id(map, SPA_TYPE__Format); type->props = spa_type_map_get_id(map, SPA_TYPE__Props); type->prop_unknown = spa_type_map_get_id(map, SPA_TYPE_PROPS__unknown); @@ -189,7 +186,6 @@ struct port { struct impl { struct spa_handle handle; struct spa_node node; - struct spa_clock clock; struct spa_type_map *map; struct spa_log *log; @@ -905,52 +901,6 @@ static const struct spa_node impl_node = { 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) { 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) *interface = &this->node; - else if (interface_id == this->type.clock) - *interface = &this->clock; else return -ENOENT; @@ -1028,7 +976,6 @@ impl_init(const struct spa_handle_factory *factory, init_type(&this->type, this->map); this->node = impl_node; - this->clock = impl_clock; reset_props(&this->props); @@ -1053,7 +1000,6 @@ impl_init(const struct spa_handle_factory *factory, static const struct spa_interface_info impl_interfaces[] = { {SPA_TYPE__Node,}, - {SPA_TYPE__Clock,}, }; static int impl_enum_interface_info(const struct spa_handle_factory *factory, diff --git a/spa/plugins/videotestsrc/videotestsrc.c b/spa/plugins/videotestsrc/videotestsrc.c index efe37f668..5fe8ab1f1 100644 --- a/spa/plugins/videotestsrc/videotestsrc.c +++ b/spa/plugins/videotestsrc/videotestsrc.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -45,7 +44,6 @@ struct type { uint32_t node; - uint32_t clock; uint32_t format; uint32_t props; uint32_t prop_live; @@ -67,7 +65,6 @@ struct type { 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->clock = spa_type_map_get_id(map, SPA_TYPE__Clock); type->format = spa_type_map_get_id(map, SPA_TYPE__Format); type->props = spa_type_map_get_id(map, SPA_TYPE__Props); type->prop_live = spa_type_map_get_id(map, SPA_TYPE_PROPS__live); @@ -118,7 +115,6 @@ struct buffer { struct impl { struct spa_handle handle; struct spa_node node; - struct spa_clock clock; struct type type; struct spa_type_map *map; @@ -908,53 +904,6 @@ static const struct spa_node impl_node = { 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) { 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) *interface = &this->node; - else if (interface_id == this->type.clock) - *interface = &this->clock; else return -ENOENT; @@ -1029,7 +976,6 @@ impl_init(const struct spa_handle_factory *factory, init_type(&this->type, this->map); this->node = impl_node; - this->clock = impl_clock; reset_props(&this->props); 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[] = { {SPA_TYPE__Node,}, - {SPA_TYPE__Clock,}, }; static int diff --git a/spa/tools/spa-inspect.c b/spa/tools/spa-inspect.c index 668b07a9b..41d35f8b5 100644 --- a/spa/tools/spa-inspect.c +++ b/spa/tools/spa-inspect.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -40,7 +39,6 @@ static SPA_LOG_IMPL(default_log); struct type { uint32_t node; - uint32_t clock; uint32_t format; struct spa_type_param param; }; @@ -298,7 +296,6 @@ int main(int argc, char *argv[]) data.n_support = 4; 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); spa_type_param_map(data.map, &data.type.param); diff --git a/src/modules/spa/spa-node.c b/src/modules/spa/spa-node.c index 0f1c17b44..6455eff89 100644 --- a/src/modules/spa/spa-node.c +++ b/src/modules/spa/spa-node.c @@ -120,20 +120,11 @@ pw_spa_node_new(struct pw_core *core, { struct pw_node *this; 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); if (this == 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 = this; impl->owner = owner; diff --git a/src/modules/spa/spa-node.h b/src/modules/spa/spa-node.h index 476c71085..d7cdf7283 100644 --- a/src/modules/spa/spa-node.h +++ b/src/modules/spa/spa-node.h @@ -20,7 +20,6 @@ #ifndef __PIPEWIRE_SPA_NODE_H__ #define __PIPEWIRE_SPA_NODE_H__ -#include #include #include diff --git a/src/pipewire/link.c b/src/pipewire/link.c index 6ea3292fe..05fef4083 100644 --- a/src/pipewire/link.c +++ b/src/pipewire/link.c @@ -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); 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", - this, output_node, output_node->clock, output_node->live); + pw_log_debug("link %p: output node %p live %d", + this, output_node, output_node->live); spa_list_append(&output->links, &this->output_link); spa_list_append(&input->links, &this->input_link); diff --git a/src/pipewire/node.c b/src/pipewire/node.c index d51b84eff..796757a8e 100644 --- a/src/pipewire/node.c +++ b/src/pipewire/node.c @@ -23,7 +23,6 @@ #include #include -#include #include #include diff --git a/src/pipewire/port.c b/src/pipewire/port.c index 55e52d1af..19b690fa5 100644 --- a/src/pipewire/port.c +++ b/src/pipewire/port.c @@ -305,9 +305,9 @@ static int do_add_port(struct spa_loop *loop, out = &this->node->rt.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_data = in; + spa_graph_link_add(out, in->state, &this->rt.mix_link); return 0; } diff --git a/src/pipewire/private.h b/src/pipewire/private.h index 563acba03..51e90d41c 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -269,7 +269,6 @@ struct pw_node { struct spa_list driver_list; struct spa_list driver_link; - struct spa_clock *clock; /**< handle to SPA clock if any */ struct spa_node *node; /**< SPA node implementation */ struct spa_list resource_list; /**< list of resources for this node */ diff --git a/src/pipewire/type.c b/src/pipewire/type.c index 89c9b3c25..3deee224f 100644 --- a/src/pipewire/type.c +++ b/src/pipewire/type.c @@ -21,7 +21,6 @@ #include #include -#include #include #include #include @@ -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_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_format = spa_type_map_get_id(type->map, SPA_TYPE__Format); type->spa_props = spa_type_map_get_id(type->map, SPA_TYPE__Props);