// // AudioSolo.cpp // // // Created by Clement Brisset on 11/5/18. // Copyright 2018 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "AudioSolo.h" #include bool AudioSolo::isSoloing() const { Lock lock(_mutex); return !_nodesSoloed.empty(); } QVector AudioSolo::getUUIDs() const { Lock lock(_mutex); return _nodesSoloed.values().toVector(); } void AudioSolo::addUUIDs(QVector uuidList) { // create a reliable NLPacket with space for the solo UUIDs auto soloPacket = NLPacket::create(PacketType::AudioSoloRequest, uuidList.size() * NUM_BYTES_RFC4122_UUID + sizeof(bool), true); soloPacket->writePrimitive(true); { Lock lock(_mutex); for (auto uuid : uuidList) { if (_nodesSoloed.contains(uuid)) { qWarning() << "Uuid already in solo list:" << uuid; } else { // write the node ID to the packet soloPacket->write(uuid.toRfc4122()); _nodesSoloed.insert(uuid); } } } // send off this ignore packet reliably to the matching node auto nodeList = DependencyManager::get(); nodeList->broadcastToNodes(std::move(soloPacket), { NodeType::AudioMixer }); } void AudioSolo::removeUUIDs(QVector uuidList) { // create a reliable NLPacket with space for the solo UUIDs auto soloPacket = NLPacket::create(PacketType::AudioSoloRequest, uuidList.size() * NUM_BYTES_RFC4122_UUID + sizeof(bool), true); soloPacket->writePrimitive(false); { Lock lock(_mutex); for (auto uuid : uuidList) { if (!_nodesSoloed.contains(uuid)) { qWarning() << "Uuid not in solo list:" << uuid; } else { // write the node ID to the packet soloPacket->write(uuid.toRfc4122()); _nodesSoloed.remove(uuid); } } } // send off this ignore packet reliably to the matching node auto nodeList = DependencyManager::get(); nodeList->broadcastToNodes(std::move(soloPacket), { NodeType::AudioMixer }); } void AudioSolo::reset() { removeUUIDs(getUUIDs()); }