record_play_mixer: report Play and Record sessions

The state-report now contains all active Play and Record sessions
and will get updated whenever a session is created or destroyed.

Issue #5174.
This commit is contained in:
Josef Söntgen 2024-04-16 16:04:55 +02:00 committed by Christian Helmuth
parent e0f5a2ddc5
commit e1ebcd8019
4 changed files with 46 additions and 1 deletions

View File

@ -70,6 +70,28 @@ period of 80 ms could be configured to a jitter of 10 ms. In the presence of
multiple jitter attributes (e.g, one present in the <config> node and one
present in a <policy> node, the highest value takes effect.
State report
~~~~~~~~~~~~
The mixer generates a state-report that contains all active Play and
Record sessions. This information can be used to augment the configuration
by specifying the complete label in each '<play>' and '<policy>' (for
Record session) node.
The following snippet shows an examplary state-report:
! <state>
! <play label="audio_drv -> mic_right"/>
! <play label="audio_drv -> mic_left"/>
! <play label="waveform_player -> right"/>
! <play label="waveform_player -> left"/>
! <record label="audio_drv -> right"/>
! <record label="audio_drv -> left"/>
! </state>
The state-report additionally also reflects the current version of the
configuration if the '<config>' node contains a 'version' attribute.
Example
~~~~~~~

View File

@ -91,6 +91,11 @@ struct Mixer::Main : Record_session::Operations, Play_session::Operations
});
}
void update_record_sessions_state() override
{
_update_state_report();
}
/**
* Play_session::Operations
*/
@ -103,6 +108,11 @@ struct Mixer::Main : Record_session::Operations, Play_session::Operations
audio_signal.bind_inputs(_audio_signals, _play_sessions); });
}
void update_play_sessions_state() override
{
_update_state_report();
}
/**
* Play_session::Operations
*/
@ -116,7 +126,14 @@ struct Mixer::Main : Record_session::Operations, Play_session::Operations
{
if (_clock_from_config.constructed())
xml.attribute("clock_value", _clock_from_config->us());
(void)xml;
_play_sessions.for_each([&] (Play_session const &play_session) {
xml.node("play", [&] {
xml.attribute("label", play_session.label()); });
});
_record_sessions.for_each([&] (Record_session const &record_session) {
xml.node("record", [&] {
xml.attribute("label", record_session.label()); });
});
}
void _update_state_report()

View File

@ -35,6 +35,7 @@ class Mixer::Play_session : public Session_object<Play::Session, Play_session>,
struct Operations : virtual Clock_operations
{
virtual void update_play_sessions_state() = 0;
virtual void bind_play_sessions_to_audio_signals() = 0;
virtual void wakeup_record_clients() = 0;
};
@ -238,6 +239,7 @@ class Mixer::Play_session : public Session_object<Play::Session, Play_session>,
_operations(operations)
{
_operations.bind_play_sessions_to_audio_signals();
_operations.update_play_sessions_state();
}
void global_jitter_us(unsigned us) { _expected_jitter_us = us; };
@ -462,6 +464,7 @@ class Mixer::Play_root : public Root_component<Play_session>
{
Genode::destroy(md_alloc(), session);
_operations.bind_play_sessions_to_audio_signals();
_operations.update_play_sessions_state();
}
public:

View File

@ -38,6 +38,7 @@ class Mixer::Record_session : public Session_object<Record::Session, Record_sess
struct Operations : virtual Clock_operations
{
virtual void update_record_sessions_state() = 0;
virtual void bind_sample_producers_to_record_sessions() = 0;
};
@ -94,6 +95,7 @@ class Mixer::Record_session : public Session_object<Record::Session, Record_sess
_operations(operations)
{
_operations.bind_sample_producers_to_record_sessions();
_operations.update_record_sessions_state();
}
void wakeup()
@ -250,6 +252,7 @@ class Mixer::Record_root : public Root_component<Record_session>
void _destroy_session(Record_session *session) override
{
Genode::destroy(md_alloc(), session);
_operations.update_record_sessions_state();
}
public: