mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-20 06:07:59 +00:00
os: add mixer utility header for Channel struct
The notion of a channel is shared by the mixer backend as well as the frontend. To make dealing with reports between those easier move the Channel definition to a global header. Issue #1770.
This commit is contained in:
parent
2c9d2e1d32
commit
fe1a0e5f65
62
repos/os/include/mixer/channel.h
Normal file
62
repos/os/include/mixer/channel.h
Normal file
@ -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 <util/string.h>
|
||||
#include <util/xml_node.h>
|
||||
|
||||
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<long>("number", 0);
|
||||
volume = node.attribute_value<long>("volume", 0);
|
||||
active = node.attribute_value<long>("active", 0);
|
||||
muted = node.attribute_value<long>("muted", 0);
|
||||
} catch (...) { throw Invalid_channel(); }
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__MIXER__CHANNEL_H_ */
|
Loading…
Reference in New Issue
Block a user