mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
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:
parent
83bb8dc599
commit
fba00fb791
22 changed files with 31 additions and 516 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ extern "C" {
|
|||
#include <spa/support/log.h>
|
||||
#include <spa/utils/list.h>
|
||||
|
||||
#include <spa/clock/clock.h>
|
||||
#include <spa/node/node.h>
|
||||
#include <spa/node/io.h>
|
||||
#include <spa/param/buffers.h>
|
||||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue