mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-07 19:34:56 +00:00
parent
fa3f5edcc2
commit
ff0ba89e91
@ -85,6 +85,8 @@ struct Mixer
|
||||
{
|
||||
mixer_devinfo_t *info;
|
||||
unsigned num;
|
||||
|
||||
bool report_state;
|
||||
};
|
||||
|
||||
|
||||
@ -342,14 +344,50 @@ static bool open_audio_device(dev_t dev)
|
||||
}
|
||||
|
||||
|
||||
static void configure_mixer(Genode::Env &env, Mixer &mixer, Genode::Xml_node config)
|
||||
static void report_mixer_state(Mixer &mixer, Genode::Env *env = nullptr)
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
static Reporter mixer_reporter(env, "mixer_state");
|
||||
static Constructible<Expanding_reporter> mixer_reporter { };
|
||||
|
||||
bool const v = config.attribute_value<bool>("report_mixer", false);
|
||||
mixer_reporter.enabled(v);
|
||||
if (!mixer.report_state)
|
||||
return;
|
||||
|
||||
if (env && !mixer_reporter.constructed())
|
||||
mixer_reporter.construct(*env, "mixer_state", "mixer_state");
|
||||
|
||||
if (!mixer_reporter.constructed())
|
||||
return;
|
||||
|
||||
mixer_reporter->generate([&] (Xml_generator &xml) {
|
||||
|
||||
for (unsigned i = 0; i < mixer.num; i++) {
|
||||
if (mixer.info[i].type == AUDIO_MIXER_CLASS)
|
||||
continue;
|
||||
|
||||
unsigned mixer_class = mixer.info[i].mixer_class;
|
||||
char const * const class_name = mixer.info[mixer_class].label.name;
|
||||
char const * const name = mixer.info[i].label.name;
|
||||
char const * const value = get_mixer_value(&mixer.info[i]);
|
||||
|
||||
if (value) {
|
||||
xml.node("mixer", [&]() {
|
||||
char tmp[64];
|
||||
Format::snprintf(tmp, sizeof(tmp), "%s.%s",
|
||||
class_name, name);
|
||||
|
||||
xml.attribute("field", tmp);
|
||||
xml.attribute("value", value);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
static void configure_mixer(Genode::Env &env, Mixer &mixer, Genode::Xml_node config)
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
config.for_each_sub_node("mixer", [&] (Xml_node node) {
|
||||
|
||||
@ -362,31 +400,8 @@ static void configure_mixer(Genode::Env &env, Mixer &mixer, Genode::Xml_node con
|
||||
set_mixer_value(mixer, field.string(), value.string());
|
||||
});
|
||||
|
||||
if (mixer_reporter.enabled()) try {
|
||||
Genode::Reporter::Xml_generator xml(mixer_reporter, [&]() {
|
||||
|
||||
for (unsigned i = 0; i < mixer.num; i++) {
|
||||
if (mixer.info[i].type == AUDIO_MIXER_CLASS)
|
||||
continue;
|
||||
|
||||
unsigned mixer_class = mixer.info[i].mixer_class;
|
||||
char const * const class_name = mixer.info[mixer_class].label.name;
|
||||
char const * const name = mixer.info[i].label.name;
|
||||
char const * const value = get_mixer_value(&mixer.info[i]);
|
||||
|
||||
if (value) {
|
||||
xml.node("mixer", [&]() {
|
||||
char tmp[64];
|
||||
Format::snprintf(tmp, sizeof(tmp), "%s.%s",
|
||||
class_name, name);
|
||||
|
||||
xml.attribute("field", tmp);
|
||||
xml.attribute("value", value);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (...) { Genode::warning("Could not report mixer state"); }
|
||||
mixer.report_state = config.attribute_value<bool>("report_mixer", false);
|
||||
report_mixer_state(mixer, &env);
|
||||
}
|
||||
|
||||
|
||||
@ -601,6 +616,8 @@ extern "C" void notify_record()
|
||||
extern "C" void notify_hp_sense(int const sense)
|
||||
{
|
||||
set_mixer_value(mixer, "record.adc-0:1_source", sense ? "mic2" : "mic");
|
||||
|
||||
report_mixer_state(mixer, nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user