diff options
author | xerus2000 <27jf@pm.me> | 2020-11-13 21:35:08 +0100 |
---|---|---|
committer | xerus2000 <27jf@pm.me> | 2020-11-13 21:35:08 +0100 |
commit | 8e18c532f3bb04177093581f2ec1bc993225079e (patch) | |
tree | 56b4492feeaa7ca036de3b9cd91bc0e566c78d36 /src | |
parent | 2d9dcff9256b8b092af0d6d89f94b797e441c95a (diff) | |
parent | 3a9048073bf045c40ae015d61634bf6248540ce2 (diff) |
Merge remote-tracking branch 'upstream/2.3' into cleanup-headers
Diffstat (limited to 'src')
88 files changed, 636 insertions, 508 deletions
diff --git a/src/analyzer/analyzerbeats.cpp b/src/analyzer/analyzerbeats.cpp index 953e7af77f..62b98115cb 100644 --- a/src/analyzer/analyzerbeats.cpp +++ b/src/analyzer/analyzerbeats.cpp @@ -25,8 +25,9 @@ QList<mixxx::AnalyzerPluginInfo> AnalyzerBeats::availablePlugins() { // static mixxx::AnalyzerPluginInfo AnalyzerBeats::defaultPlugin() { - DEBUG_ASSERT(availablePlugins().size() > 0); - return availablePlugins().at(0); + const auto plugins = availablePlugins(); + DEBUG_ASSERT(!plugins.isEmpty()); + return plugins.at(0); } AnalyzerBeats::AnalyzerBeats(UserSettingsPointer pConfig, bool enforceBpmDetection) @@ -72,10 +73,11 @@ bool AnalyzerBeats::initialize(TrackPointer tio, int sampleRate, int totalSample m_bPreferencesReanalyzeImported = m_bpmSettings.getReanalyzeImported(); m_bPreferencesFastAnalysis = m_bpmSettings.getFastAnalysis(); - if (availablePlugins().size() > 0) { + const auto plugins = availablePlugins(); + if (!plugins.isEmpty()) { m_pluginId = defaultPlugin().id; QString pluginId = m_bpmSettings.getBeatPluginId(); - for (const auto& info : availablePlugins()) { + for (const auto& info : plugins) { if (info.id == pluginId) { m_pluginId = pluginId; // configured Plug-In available break; diff --git a/src/analyzer/analyzerkey.cpp b/src/analyzer/analyzerkey.cpp index 38e3bc2c89..fc9bb3ee09 100644 --- a/src/analyzer/analyzerkey.cpp +++ b/src/analyzer/analyzerkey.cpp @@ -25,8 +25,9 @@ QList<mixxx::AnalyzerPluginInfo> AnalyzerKey::availablePlugins() { // static mixxx::AnalyzerPluginInfo AnalyzerKey::defaultPlugin() { - DEBUG_ASSERT(availablePlugins().size() > 0); - return availablePlugins().at(0); + const auto plugins = availablePlugins(); + DEBUG_ASSERT(!plugins.isEmpty()); + return plugins.at(0); } AnalyzerKey::AnalyzerKey(KeyDetectionSettings keySettings) @@ -54,10 +55,11 @@ bool AnalyzerKey::initialize(TrackPointer tio, int sampleRate, int totalSamples) m_bPreferencesFastAnalysisEnabled = m_keySettings.getFastAnalysis(); m_bPreferencesReanalyzeEnabled = m_keySettings.getReanalyzeWhenSettingsChange(); - if (availablePlugins().size() > 0) { + const auto plugins = availablePlugins(); + if (!plugins.isEmpty()) { m_pluginId = defaultPlugin().id; QString pluginId = m_keySettings.getKeyPluginId(); - for (const auto& info : availablePlugins()) { + for (const auto& info : plugins) { if (info.id == pluginId) { m_pluginId = pluginId; // configured Plug-In available break; diff --git a/src/broadcast/broadcastmanager.cpp b/src/broadcast/broadcastmanager.cpp index 71958f08c3..0831d806cf 100644 --- a/src/broadcast/broadcastmanager.cpp +++ b/src/broadcast/broadcastmanager.cpp @@ -43,7 +43,7 @@ BroadcastManager::BroadcastManager(SettingsManager* pSettingsManager, // Initialize connections list from the current state of BroadcastSettings QList<BroadcastProfilePtr> profiles = m_pBroadcastSettings->profiles(); - for(BroadcastProfilePtr profile : profiles) { + for (const BroadcastProfilePtr& profile : profiles) { addConnection(profile); } @@ -99,7 +99,7 @@ void BroadcastManager::slotControlEnabled(double v) { if (v > 0.0) { bool atLeastOneEnabled = false; QList<BroadcastProfilePtr> profiles = m_pBroadcastSettings->profiles(); - for(BroadcastProfilePtr profile : profiles) { + for (const BroadcastProfilePtr& profile : profiles) { if (profile->getEnabled()) { atLeastOneEnabled = true; break; @@ -138,7 +138,7 @@ void BroadcastManager::slotProfileRemoved(BroadcastProfilePtr profile) { void BroadcastManager::slotProfilesChanged() { QVector<NetworkOutputStreamWorkerPtr> workers = m_pNetworkStream->outputWorkers(); - for(NetworkOutputStreamWorkerPtr pWorker : workers) { + for (const NetworkOutputStreamWorkerPtr& pWorker : workers) { ShoutConnectionPtr connection = qSharedPointerCast<ShoutConnection>(pWorker); if (connection) { BroadcastProfilePtr profile = connection->profile(); @@ -197,7 +197,7 @@ bool BroadcastManager::removeConnection(BroadcastProfilePtr profile) { ShoutConnectionPtr BroadcastManager::findConnectionForProfile(BroadcastProfilePtr profile) { QVector<NetworkOutputStreamWorkerPtr> workers = m_pNetworkStream->outputWorkers(); - for(NetworkOutputStreamWorkerPtr pWorker : workers) { + for (const NetworkOutputStreamWorkerPtr& pWorker : workers) { ShoutConnectionPtr connection = qSharedPointerCast<ShoutConnection>(pWorker); if (connection.isNull()) continue; diff --git a/src/control/controlobjectscript.cpp b/src/control/controlobjectscript.cpp index d95d0c0176..429a4d0230 100644 --- a/src/control/controlobjectscript.cpp +++ b/src/control/controlobjectscript.cpp @@ -22,7 +22,7 @@ bool ControlObjectScript::addScriptConnection(const ScriptConnection& conn) { Qt::QueuedConnection); } - for (const auto& priorConnection: m_scriptConnections) { + for (const auto& priorConnection : qAsConst(m_scriptConnections)) { if (conn == priorConnection) { qWarning() << "Connection " + conn.id.toString() + " already connected to (" + diff --git a/src/controllers/controllerinputmappingtablemodel.cpp b/src/controllers/controllerinputmappingtablemodel.cpp index cd143383aa..73db610044 100644 --- a/src/controllers/controllerinputmappingtablemodel.cpp +++ b/src/controllers/controllerinputmappingtablemodel.cpp @@ -19,7 +19,7 @@ void ControllerInputMappingTableModel::apply() { // Clear existing input mappings and insert all the input mappings in // the table into the preset. QMultiHash<uint16_t, MidiInputMapping> mappings; - for (const MidiInputMapping& mapping : m_midiInputMappings) { + for (const MidiInputMapping& mapping : qAsConst(m_midiInputMappings)) { // There can be multiple input mappings for the same input // MidiKey, so we need to use a QMultiHash here. mappings.insert(mapping.key.key, mapping); diff --git a/src/controllers/controllermanager.cpp b/src/controllers/controllermanager.cpp index ef113ce820..bf68c1513d 100644 --- a/src/controllers/controllermanager.cpp +++ b/src/controllers/controllermanager.cpp @@ -347,7 +347,7 @@ void ControllerManager::pollDevices() { } mixxx::Duration start = mixxx::Time::elapsed(); - for (Controller* pDevice : m_controllers) { + for (Controller* pDevice : qAsConst(m_controllers)) { if (pDevice->isOpen() && pDevice->isPolling()) { pDevice->poll(); } diff --git a/src/controllers/controlleroutputmappingtablemodel.cpp b/src/controllers/controlleroutputmappingtablemodel.cpp index 1ae8b1dd73..676442cb1e 100644 --- a/src/controllers/controlleroutputmappingtablemodel.cpp +++ b/src/controllers/controlleroutputmappingtablemodel.cpp @@ -19,7 +19,7 @@ void ControllerOutputMappingTableModel::apply() { // Clear existing output mappings and insert all the output mappings in // the table into the preset. QMultiHash<ConfigKey, MidiOutputMapping> mappings; - for (const MidiOutputMapping& mapping : m_midiOutputMappings) { + for (const MidiOutputMapping& mapping : qAsConst(m_midiOutputMappings)) { // There can be multiple output mappings for the same output // control, so we need to use a QMultiHash here. mappings.insert(mapping.controlKey, mapping); diff --git a/src/controllers/controllerpresetinfoenumerator.cpp b/src/controllers/controllerpresetinfoenumerator.cpp index 56bffda51a..c36b4fd02d 100644 --- a/src/controllers/controllerpresetinfoenumerator.cpp +++ b/src/controllers/controllerpresetinfoenumerator.cpp @@ -51,7 +51,7 @@ void PresetInfoEnumerator::loadSupportedPresets() { m_hidPresets.clear(); m_bulkPresets.clear(); - for (const QString& dirPath : m_controllerDirPaths) { + for (const QString& dirPath : qAsConst(m_controllerDirPaths)) { QDirIterator it(dirPath); while (it.hasNext()) { it.next(); diff --git a/src/controllers/hid/hidblacklist.h b/src/controllers/hid/hidblacklist.h deleted file mode 100644 index 0d8fbef1a7..0000000000 --- a/src/controllers/hid/hidblacklist.h +++ /dev/null @@ -1,18 +0,0 @@ -// Blacklisted HID devices - -#pragma once - -typedef struct hid_blacklist { - unsigned short vendor_id; - unsigned short product_id; - unsigned short usage_page; - unsigned short usage; - int interface_number; -} hid_blacklist_t; - -hid_blacklist_t hid_blacklisted[] = { - {0x5ac, 0x253, 0xff00, 0x1, -1}, // Apple laptop chassis - {0x5ac, 0x8242, 0xc, 0x1, -1}, // Apple IR Remote Controller - {0x1157, 0x300, 0x1, 0x2, -1}, // EKS Otus mouse pad (OS/X,windows) - {0x1157, 0x300, 0x0, 0x0, 0x3}, // EKS Otus mouse pad (linux) -}; diff --git a/src/controllers/hid/hiddenylist.h b/src/controllers/hid/hiddenylist.h new file mode 100644 index 0000000000..1a1fdb05b1 --- /dev/null +++ b/src/controllers/hid/hiddenylist.h @@ -0,0 +1,17 @@ +#pragma once + +typedef struct hid_denylist { + unsigned short vendor_id; + unsigned short product_id; + unsigned short usage_page; + unsigned short usage; + int interface_number; +} hid_denylist_t; + +/// USB HID device that should not be recognized as controllers +hid_denylist_t hid_denylisted[] = { + {0x5ac, 0x253, 0xff00, 0x1, -1}, // Apple laptop chassis + {0x5ac, 0x8242, 0xc, 0x1, -1}, // Apple IR Remote Controller + {0x1157, 0x300, 0x1, 0x2, -1}, // EKS Otus mouse pad (OS/X,windows) + {0x1157, 0x300, 0x0, 0x0, 0x3}, // EKS Otus mouse pad (linux) +}; diff --git a/src/controllers/hid/hidenumerator.cpp b/src/controllers/hid/hidenumerator.cpp index e2243e584d..330425f4d9 100644 --- a/src/controllers/hid/hidenumerator.cpp +++ b/src/controllers/hid/hidenumerator.cpp @@ -1,58 +1,63 @@ +#include "controllers/hid/hidenumerator.h" + #include <hidapi.h> #include "controllers/hid/hidcontroller.h" -#include "controllers/hid/hidenumerator.h" -#include "controllers/hid/hidblacklist.h" +#include "controllers/hid/hiddenylist.h" -HidEnumerator::HidEnumerator(UserSettingsPointer pConfig) - : ControllerEnumerator(), m_pConfig(pConfig) { -} - -HidEnumerator::~HidEnumerator() { - qDebug() << "Deleting HID devices..."; - while (m_devices.size() > 0) { - delete m_devices.takeLast(); - } - hid_exit(); -} +namespace { -bool isDeviceBlacklisted(struct hid_device_info* cur_dev) { - bool interface_number_valid = cur_dev->interface_number != -1; - const int blacklist_len = sizeof(hid_blacklisted)/sizeof(hid_blacklisted[0]); - for (int bl_index=0;bl_index<blacklist_len;bl_index++) { - hid_blacklist_t blacklisted = hid_blacklisted[bl_index]; +bool recognizeDevice(const hid_device_info& device_info) { + bool interface_number_valid = device_info.interface_number != -1; + const int denylist_len = sizeof(hid_denylisted) / sizeof(hid_denylisted[0]); + for (int bl_index = 0; bl_index < denylist_len; bl_index++) { + hid_denylist_t denylisted = hid_denylisted[bl_index]; // If vendor ids do not match, skip. - if (cur_dev->vendor_id != blacklisted.vendor_id) + if (device_info.vendor_id != denylisted.vendor_id) continue; // If product IDs do not match, skip. - if (cur_dev->product_id != blacklisted.product_id) + if (device_info.product_id != denylisted.product_id) continue; - // Blacklist entry based on interface number - if (blacklisted.interface_number != -1) { + |