+/*****************************************************************************
+ * GraphChange: callback when JACK reorders it's process graph.
+ We update latency information.
+ *****************************************************************************/
+
+static int GraphChange( void *p_arg )
+{
+ aout_instance_t *p_aout = (aout_instance_t*) p_arg;
+ struct aout_sys_t *p_sys = p_aout->output.p_sys;
+ unsigned int i;
+ jack_nframes_t port_latency;
+
+ p_sys->latency = 0;
+
+ for( i = 0; i < p_sys->i_channels; ++i )
+ {
+ port_latency = jack_port_get_total_latency( p_sys->p_jack_client,
+ p_sys->p_jack_ports[i] );
+ p_sys->latency = __MAX( p_sys->latency, port_latency );
+ }
+
+ msg_Dbg(p_aout, "JACK graph reordered. Our maximum latency=%d.", p_sys->latency);
+
+ return 0;
+}