mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
alsa: cleanups
Avoid getting the clock time just for debug. Improve time at startup.
This commit is contained in:
parent
d3c7acb137
commit
ab0d1b7fad
4 changed files with 34 additions and 28 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit f777c04ea683d0922f72fba25e74ff9535228609
|
Subproject commit b85b88b53d2d341bc873d4feca5ef7648e559a65
|
||||||
|
|
@ -662,6 +662,7 @@ struct spa_node_methods {
|
||||||
* immediately when idle. */
|
* immediately when idle. */
|
||||||
|
|
||||||
/** port keys */
|
/** port keys */
|
||||||
|
#define SPA_KEY_PORT_NAME "port.name" /**< a port name */
|
||||||
#define SPA_KEY_PORT_MONITOR "port.monitor" /**< this port is a monitor port */
|
#define SPA_KEY_PORT_MONITOR "port.monitor" /**< this port is a monitor port */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
|
|
@ -499,14 +499,12 @@ static int set_timeout(struct state *state, uint64_t time)
|
||||||
{
|
{
|
||||||
struct itimerspec ts;
|
struct itimerspec ts;
|
||||||
|
|
||||||
if (!state->slaved) {
|
ts.it_value.tv_sec = time / SPA_NSEC_PER_SEC;
|
||||||
ts.it_value.tv_sec = time / SPA_NSEC_PER_SEC;
|
ts.it_value.tv_nsec = time % SPA_NSEC_PER_SEC;
|
||||||
ts.it_value.tv_nsec = time % SPA_NSEC_PER_SEC;
|
ts.it_interval.tv_sec = 0;
|
||||||
ts.it_interval.tv_sec = 0;
|
ts.it_interval.tv_nsec = 0;
|
||||||
ts.it_interval.tv_nsec = 0;
|
spa_system_timerfd_settime(state->data_system,
|
||||||
spa_system_timerfd_settime(state->data_system,
|
state->timerfd, SPA_FD_TIMER_ABSTIME, &ts, NULL);
|
||||||
state->timerfd, SPA_FD_TIMER_ABSTIME, &ts, NULL);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -848,7 +846,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 = SPA_TIMESPEC_TO_NSEC(&state->now);
|
b->h->pts = state->next_time;
|
||||||
b->h->dts_offset = 0;
|
b->h->dts_offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1033,7 +1031,6 @@ static void alsa_on_timeout_event(struct spa_source *source)
|
||||||
{
|
{
|
||||||
struct state *state = source->data;
|
struct state *state = source->data;
|
||||||
snd_pcm_uframes_t delay, target;
|
snd_pcm_uframes_t delay, target;
|
||||||
uint64_t nsec;
|
|
||||||
uint64_t expire;
|
uint64_t expire;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
|
@ -1045,19 +1042,27 @@ static void alsa_on_timeout_event(struct spa_source *source)
|
||||||
state->threshold = (state->duration * state->rate + state->rate_denom-1) / state->rate_denom;
|
state->threshold = (state->duration * state->rate + state->rate_denom-1) / state->rate_denom;
|
||||||
}
|
}
|
||||||
|
|
||||||
spa_system_clock_gettime(state->data_system, CLOCK_MONOTONIC, &state->now);
|
|
||||||
if ((res = get_status(state, &delay, &target)) < 0)
|
if ((res = get_status(state, &delay, &target)) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
nsec = SPA_TIMESPEC_TO_NSEC(&state->now);
|
state->current_time = state->next_time;
|
||||||
spa_log_trace_fp(state->log, "timeout %lu %lu %"PRIu64" %"PRIu64" %"PRIi64" %d %"PRIi64,
|
|
||||||
delay, target, nsec, state->next_time, nsec - state->next_time,
|
#ifndef FASTPATH
|
||||||
state->threshold, state->sample_count);
|
if (SPA_UNLIKELY(spa_log_level_enabled(state->log, SPA_LOG_LEVEL_TRACE))) {
|
||||||
|
struct timespec now;
|
||||||
|
uint64_t nsec;
|
||||||
|
spa_system_clock_gettime(state->data_system, CLOCK_MONOTONIC, &now);
|
||||||
|
nsec = SPA_TIMESPEC_TO_NSEC(&now);
|
||||||
|
spa_log_trace_fp(state->log, "timeout %lu %lu %"PRIu64" %"PRIu64" %"PRIi64" %d %"PRIi64,
|
||||||
|
delay, target, nsec, state->current_time, nsec - state->current_time,
|
||||||
|
state->threshold, state->sample_count);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (state->stream == SND_PCM_STREAM_PLAYBACK)
|
if (state->stream == SND_PCM_STREAM_PLAYBACK)
|
||||||
handle_play(state, nsec, delay, target);
|
handle_play(state, state->current_time, delay, target);
|
||||||
else
|
else
|
||||||
handle_capture(state, nsec, delay, target);
|
handle_capture(state, state->current_time, delay, target);
|
||||||
|
|
||||||
set_timeout(state, state->next_time);
|
set_timeout(state, state->next_time);
|
||||||
}
|
}
|
||||||
|
|
@ -1082,15 +1087,15 @@ static void reset_buffers(struct state *this)
|
||||||
|
|
||||||
static int set_timers(struct state *state)
|
static int set_timers(struct state *state)
|
||||||
{
|
{
|
||||||
struct itimerspec ts;
|
struct timespec now;
|
||||||
ts.it_value.tv_sec = 0;
|
spa_system_clock_gettime(state->data_system, CLOCK_MONOTONIC, &now);
|
||||||
if (state->slaved)
|
state->next_time = SPA_TIMESPEC_TO_NSEC(&now);
|
||||||
ts.it_value.tv_nsec = 0;
|
|
||||||
else
|
if (state->slaved) {
|
||||||
ts.it_value.tv_nsec = 1;
|
set_timeout(state, 0);
|
||||||
ts.it_interval.tv_sec = 0;
|
} else {
|
||||||
ts.it_interval.tv_nsec = 0;
|
set_timeout(state, state->next_time);
|
||||||
spa_system_timerfd_settime(state->data_system, state->timerfd, 0, &ts, NULL);
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,10 +135,10 @@ struct state {
|
||||||
unsigned int alsa_sync:1;
|
unsigned int alsa_sync:1;
|
||||||
unsigned int slaved:1;
|
unsigned int slaved:1;
|
||||||
|
|
||||||
snd_htimestamp_t now;
|
|
||||||
int64_t sample_count;
|
int64_t sample_count;
|
||||||
|
|
||||||
int64_t sample_time;
|
int64_t sample_time;
|
||||||
|
uint64_t current_time;
|
||||||
uint64_t next_time;
|
uint64_t next_time;
|
||||||
uint64_t base_time;
|
uint64_t base_time;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue