diff --git a/recipes/src/libmpg123/hash b/recipes/src/libmpg123/hash index bb22072..ba56bbc 100644 --- a/recipes/src/libmpg123/hash +++ b/recipes/src/libmpg123/hash @@ -1 +1 @@ -2018-03-24 44b1460890c468d2aca6be56caf0faf075df29d4 +2018-05-24 15d7bc2940af4abfbea3229d4e2fd84981ac9962 diff --git a/recipes/src/mp3_audio_sink/hash b/recipes/src/mp3_audio_sink/hash index 071ec67..b2e68b4 100644 --- a/recipes/src/mp3_audio_sink/hash +++ b/recipes/src/mp3_audio_sink/hash @@ -1 +1 @@ -2018-03-24 fe37ac4217462df71d74721c1ac22f7158ef210d +2018-05-24 7f16584ef3bc7e7700adc9048f7c64efd0bf6a3e diff --git a/src/app/mp3_audio_sink/component.cc b/src/app/mp3_audio_sink/component.cc index bd99050..993e851 100644 --- a/src/app/mp3_audio_sink/component.cc +++ b/src/app/mp3_audio_sink/component.cc @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -65,6 +66,8 @@ struct Mp3_audio_sink::Decoder Genode::Env &_env; + Attached_rom_dataspace _config_rom { _env, "config" }; + Audio_out::Connection _out_left { _env, "left", true, true }; Audio_out::Connection _out_right { _env, "right", false, false }; Audio_out::Connection *_out[NUM_CHANNELS]; @@ -187,11 +190,39 @@ struct Mp3_audio_sink::Decoder Io_signal_handler _progress_handler { _env.ep(), *this, &Decoder::submit_audio }; + Signal_handler _config_handler { + _env.ep(), *this, &Decoder::_handle_config }; + + void _handle_config() + { + _config_rom.update(); + Xml_node const config = _config_rom.xml(); + + enum { EQ_COUNT = 32 }; + + mpg123_reset_eq(_mh); + config.for_each_sub_node("eq", [&] (Xml_node const &node) { + unsigned band = node.attribute_value("band", 32U); + double value = node.attribute_value("value", 0.0); + if (band < EQ_COUNT && value != 0.0) { + mpg123_eq(_mh, MPG123_LR , band, value); + log("EQ ", band, ": ", mpg123_geteq(_mh, MPG123_LR , band)); + } + }); + + double volume = 0.5; + config.for_each_sub_node("volume", [&] (Xml_node const &node) { + volume = node.attribute_value("linear", volume); }); + mpg123_volume(_mh, 0.5); + } + Decoder(Genode::Env &env) : _env(env) { _out[LEFT] = &_out_left; _out[RIGHT] = &_out_right; _out_left.progress_sigh(_progress_handler); + _config_rom.sigh(_config_handler); + _handle_config(); } };