diff --git a/repos/os/include/mixer/channel.h b/repos/os/include/mixer/channel.h new file mode 100644 index 000000000..6c07b1700 --- /dev/null +++ b/repos/os/include/mixer/channel.h @@ -0,0 +1,62 @@ +/* + * \brief Mixer channel class + * \author Josef Soentgen + * \date 2015-10-15 + */ + +/* + * Copyright (C) 2015 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__MIXER__CHANNEL_H_ +#define _INCLUDE__MIXER__CHANNEL_H_ + +#include +#include + +namespace Mixer { + struct Channel; +} + +struct Mixer::Channel +{ + struct Invalid_channel { }; + + typedef Genode::String<128> Label; + typedef Genode::String<32> Name; + + typedef enum { INVALID = -1, LEFT, RIGHT, MAX_CHANNELS } Number; + typedef enum { TYPE_INVALID, INPUT, OUTPUT } Type; + typedef enum { MIN = 0, MAX = 100 } Volume_level; + + Type type; + Number number; + Label label; + int volume; + bool active; + bool muted; + + Channel(Genode::Xml_node const &node) + { + Genode::String<8> tmp; + try { node.attribute("type").value(&tmp); } + catch (...) { throw Invalid_channel(); } + + if (tmp == "input") type = INPUT; + else if (tmp == "output") type = OUTPUT; + else throw Invalid_channel(); + + try { + node.attribute("label").value(&label); + number = (Channel::Number) node.attribute_value("number", 0); + volume = node.attribute_value("volume", 0); + active = node.attribute_value("active", 0); + muted = node.attribute_value("muted", 0); + } catch (...) { throw Invalid_channel(); } + } +}; + +#endif /* _INCLUDE__MIXER__CHANNEL_H_ */