profiler: add followerClock block

Add a new followerClock block in the profiler info. This is only set
when the follower could be a driver and it contains the clock info used
for following the driver, mostly the rate difference and delay.

Dump this info in pw-profiler -J

Make sure we always set the info in the clock, especially also when we
are following.
This commit is contained in:
Wim Taymans 2024-10-09 11:27:23 +02:00
parent d605a820d2
commit fa1ec61cf0
6 changed files with 95 additions and 8 deletions

View file

@ -26,6 +26,7 @@ static const struct spa_type_info spa_type_profiler[] = {
{ SPA_PROFILER_clock, SPA_TYPE_Struct, SPA_TYPE_INFO_PROFILER_BASE "clock", NULL, },
{ SPA_PROFILER_driverBlock, SPA_TYPE_Struct, SPA_TYPE_INFO_PROFILER_BASE "driverBlock", NULL, },
{ SPA_PROFILER_followerBlock, SPA_TYPE_Struct, SPA_TYPE_INFO_PROFILER_BASE "followerBlock", NULL, },
{ SPA_PROFILER_followerClock, SPA_TYPE_Struct, SPA_TYPE_INFO_PROFILER_BASE "followerClock", NULL, },
{ 0, 0, NULL, NULL },
};

View file

@ -40,7 +40,9 @@ enum spa_profiler {
* Long : clock delay,
* Double : clock rate_diff,
* Long : clock next_nsec,
* Int : transport_state)) */
* Int : transport_state,
* Int : clock cycle,
* Long : xrun duration)) */
SPA_PROFILER_driverBlock, /**< generic driver info block
* (Struct(
* Int : driver_id,
@ -65,7 +67,18 @@ enum spa_profiler {
* Int : status,
* Fraction : latency,
* Int : xrun_count)) */
SPA_PROFILER_followerClock, /**< follower clock information
* (Struct(
* Int : clock id,
* String: clock name,
* Long : clock nsec,
* Fraction : clock rate,
* Long : clock position,
* Long : clock duration,
* Long : clock delay,
* Double : clock rate_diff,
* Long : clock next_nsec,
* Long : xrun duration)) */
SPA_PROFILER_START_CUSTOM = 0x1000000,
};

View file

@ -2826,7 +2826,7 @@ static int update_time(struct state *state, uint64_t current_time, snd_pcm_sfram
state->next_time += (uint64_t)(state->threshold / corr * 1e9 / state->rate);
if (SPA_LIKELY(!follower && state->clock)) {
if (SPA_LIKELY(state->clock)) {
state->clock->nsec = current_time;
state->clock->rate = state->driver_rate;
state->clock->position += state->clock->duration;

View file

@ -784,7 +784,7 @@ static int update_time(struct seq_state *state, uint64_t nsec, bool follower)
}
state->next_time += (uint64_t)(state->threshold / corr * 1e9 / state->rate.denom);
if (!follower && state->clock) {
if (SPA_LIKELY(state->clock)) {
state->clock->nsec = nsec;
state->clock->rate = state->rate;
state->clock->position += state->clock->duration;