- // Call HAL to populate list
- m_client.call("ahl-4a", "get_roles", QJsonValue(), [this](bool r, const QJsonValue& val) {
- if (r)
- {
- m_roles.clear();
- //BUG: should be able to add this, but not handled right now: m_roles.append("playback");
- QJsonArray cards = val.toObject()["response"].toArray();
- foreach (const QJsonValue& card, cards)
- {
- m_roles.append(card.toString());
- qDebug() << "Mixer::onClientConnected - added this HAL: " << card.toString();
- }
- emit rolesChanged();
+ for(QObject* role : m_roles) delete role;
+ m_roles.clear();
+
+ for (const QJsonValue & av : v.toArray()) {
+ QString name = av.toObject()["control"].toString();
+ int value = static_cast<int>(av.toObject()["volume"].toDouble() * 100);
+ value = qBound(0, value, 100);
+
+ AudioRole *ar = new AudioRole(name, value);
+ connect(ar, SIGNAL(ValueChanged()), this, SLOT(onRoleValueChanged()));
+ m_roles.append(ar);
+
+ qDebug() << "added role: " << ar->Name()
+ << " value: " << ar->Value();
+ }
+
+ emit rolesChanged();
+}
+
+void Mixer::onClientConnected()
+{
+ m_client.call("audiomixer", "list_controls", QJsonObject(), [this](bool r, const QJsonValue& v) {
+ if (r && v.isObject()) {
+ parseControls(v.toObject()["response"]);