mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-17 14:48:20 +00:00
committed by
Norman Feske
parent
fa3f5edcc2
commit
ff0ba89e91
@ -85,6 +85,8 @@ struct Mixer
|
|||||||
{
|
{
|
||||||
mixer_devinfo_t *info;
|
mixer_devinfo_t *info;
|
||||||
unsigned num;
|
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;
|
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);
|
if (!mixer.report_state)
|
||||||
mixer_reporter.enabled(v);
|
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) {
|
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());
|
set_mixer_value(mixer, field.string(), value.string());
|
||||||
});
|
});
|
||||||
|
|
||||||
if (mixer_reporter.enabled()) try {
|
mixer.report_state = config.attribute_value<bool>("report_mixer", false);
|
||||||
Genode::Reporter::Xml_generator xml(mixer_reporter, [&]() {
|
report_mixer_state(mixer, &env);
|
||||||
|
|
||||||
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"); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -601,6 +616,8 @@ extern "C" void notify_record()
|
|||||||
extern "C" void notify_hp_sense(int const sense)
|
extern "C" void notify_hp_sense(int const sense)
|
||||||
{
|
{
|
||||||
set_mixer_value(mixer, "record.adc-0:1_source", sense ? "mic2" : "mic");
|
set_mixer_value(mixer, "record.adc-0:1_source", sense ? "mic2" : "mic");
|
||||||
|
|
||||||
|
report_mixer_state(mixer, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user