milan-avb: AAF media-clock recovery estimator + play-loop actuator + io_changed, SET_CLOCK_SOURCE switch, skip CRF audio data plane

This commit is contained in:
hackerman-kl 2026-05-31 15:06:14 +02:00 committed by Wim Taymans
parent 66959ca678
commit 90114c9839
5 changed files with 465 additions and 0 deletions

View file

@ -12,6 +12,10 @@
#include <spa/utils/ringbuffer.h>
#include <spa/param/audio/format.h>
#include <spa/node/io.h>
#include "mc-recover.h"
#include "play-loop.h"
#include <pipewire/pipewire.h>
@ -38,6 +42,7 @@ struct stream {
struct spa_source *flush_timer;
uint64_t flush_last_ns;
bool is_crf;
uint64_t next_txtime;
int prio;
int mtt;
int t_uncertainty;
@ -66,6 +71,32 @@ struct stream {
uint64_t format;
uint32_t stride;
struct spa_audio_info info;
/* milan-avb: AAF media-clock recovery (listener / STREAM_INPUT only).
* Active only while the CLOCK_DOMAIN selects the AAF (INPUT_STREAM)
* clock source whose location points at this stream. Estimator state in
* struct mc_recover (mc-recover.h); recovered from avtp_timestamp deltas. */
bool mc_aaf_active;
struct mc_recover mc;
/* milan-avb: actuator I/O areas (set via .io_changed). io_rate_match is the
* resampler knob NULL unless the adapter inserted a resampler. */
struct spa_io_rate_match *io_rate_match;
struct spa_io_position *io_position;
/* milan-avb: previous 1 Hz sample for the local consume-rate log. */
uint64_t play_last_consume_tai;
uint64_t play_last_ticks;
uint64_t play_log_last_ns;
bool play_primed;
/* milan-avb: actuator state; servos the ring to play_target (play-loop.h). */
struct play_loop play;
int32_t play_target;
/* milan-avb: optional raw PCM dump for offline analysis (THDN, waveform). */
FILE *raw_dump_fp;
size_t raw_dump_bytes;
};
#include "msrp.h"
@ -81,4 +112,9 @@ int stream_activate(struct stream *stream, uint16_t index, uint64_t now);
int stream_deactivate(struct stream *stream, uint64_t now);
int stream_activate_virtual(struct stream *stream, uint16_t index);
/* milan-avb: re-evaluate each input stream's media-clock recovery against the
* current CLOCK_DOMAIN selection. Call after SET_CLOCK_SOURCE for on-the-fly
* clock-source switching. */
void avb_stream_update_clock_source(struct server *server);
#endif /* AVB_STREAM_H */