Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into feat/improve-screen…
Browse files Browse the repository at this point in the history
…-rendering-framework
  • Loading branch information
acolombier committed Oct 16, 2024
2 parents e933a88 + 6efbf8c commit 755e3ad
Show file tree
Hide file tree
Showing 61 changed files with 408 additions and 266 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ jobs:
- name: "Upload Coverage Report to coveralls.io"
if: matrix.name == 'coverage'
continue-on-error: true
uses: coverallsapp/github-action@v2.3.0
uses: coverallsapp/github-action@v2.3.1
with:
flag-name: ubuntu-22.04
path-to-lcov: build/lcov.info
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ jobs:
- name: "Upload GitHub Actions artifacts"
if: matrix.artifacts_path != null
uses: actions/upload-artifact@v4.4.1
uses: actions/upload-artifact@v4.4.3
with:
name: ${{ matrix.artifacts_name }}
path: ${{ matrix.artifacts_path }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ jobs:

- name: "Upload patch artifact"
if: failure() && env.UPLOAD_PATCH_FILE != null
uses: actions/upload-artifact@v4.4.1
uses: actions/upload-artifact@v4.4.3
with:
name: ${{ env.UPLOAD_PATCH_FILE }}
path: ${{ env.UPLOAD_PATCH_FILE }}

- name: "Upload pre-commit.log"
if: failure() && env.UPLOAD_PATCH_FILE == null
uses: actions/upload-artifact@v4.4.1
uses: actions/upload-artifact@v4.4.3
with:
name: pre-commit.log
path: /github/home/.cache/pre-commit/pre-commit.log
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,7 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/track/tracknumbers.cpp
src/track/trackrecord.cpp
src/track/trackref.cpp
src/util/autofilereloader.cpp
src/util/battery/battery.cpp
src/util/cache.cpp
src/util/clipboard.cpp
Expand Down Expand Up @@ -2792,6 +2793,8 @@ if(QML)
# The following sources need to be in this target to get QML_ELEMENT properly interpreted
src/control/controlmodel.cpp
src/control/controlsortfiltermodel.cpp
# needed for qml/qmlautoreload.cpp
src/util/autofilereloader.cpp
)

# qt_finalize_target takes care that the resources :/mixxx.org/imports/Mixxx/
Expand Down
4 changes: 2 additions & 2 deletions src/analyzer/analyzerebur128.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ void AnalyzerEbur128::storeResults(TrackPointer pTrack) {
if (averageLufs == -HUGE_VAL ||
averageLufs == HUGE_VAL ||
// This catches 0 and abnormal values inf and -inf (that may have
// slipped through in libebur for some reason.
util_isnormal(averageLufs)) {
// slipped through in libebur128 for some reason.
!util_isnormal(averageLufs)) {
qWarning() << "AnalyzerEbur128::storeResults() averageLufs invalid:"
<< averageLufs;
return;
Expand Down
20 changes: 10 additions & 10 deletions src/broadcast/broadcastmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ BroadcastManager::BroadcastManager(SettingsManager* pSettingsManager,
shout_init();

// Initialize connections list from the current state of BroadcastSettings
QList<BroadcastProfilePtr> profiles = m_pBroadcastSettings->profiles();
const QList<BroadcastProfilePtr> profiles = m_pBroadcastSettings->profiles();
for (const BroadcastProfilePtr& profile : profiles) {
addConnection(profile);
}
Expand Down Expand Up @@ -92,7 +92,7 @@ void BroadcastManager::slotControlEnabled(double v) {
if (v > 0.0) {
bool atLeastOneEnabled = false;
QList<BroadcastProfilePtr> profiles = m_pBroadcastSettings->profiles();
for (const BroadcastProfilePtr& profile : profiles) {
for (const BroadcastProfilePtr& profile : std::as_const(profiles)) {
if (profile->getEnabled()) {
atLeastOneEnabled = true;
break;
Expand All @@ -111,11 +111,11 @@ void BroadcastManager::slotControlEnabled(double v) {
} else {
m_pBroadcastEnabled->set(false);
m_pStatusCO->forceSet(STATUSCO_UNCONNECTED);
QList<BroadcastProfilePtr> profiles = m_pBroadcastSettings->profiles();
for(BroadcastProfilePtr profile : profiles) {
if (profile->connectionStatus() == BroadcastProfile::STATUS_FAILURE) {
profile->setConnectionStatus(BroadcastProfile::STATUS_UNCONNECTED);
}
const QList<BroadcastProfilePtr> profiles = m_pBroadcastSettings->profiles();
for (BroadcastProfilePtr profile : profiles) {
if (profile->connectionStatus() == BroadcastProfile::STATUS_FAILURE) {
profile->setConnectionStatus(BroadcastProfile::STATUS_UNCONNECTED);
}
}
}

Expand All @@ -131,7 +131,7 @@ void BroadcastManager::slotProfileRemoved(BroadcastProfilePtr profile) {
}

void BroadcastManager::slotProfilesChanged() {
QVector<NetworkOutputStreamWorkerPtr> workers = m_pNetworkStream->outputWorkers();
const QVector<NetworkOutputStreamWorkerPtr> workers = m_pNetworkStream->outputWorkers();
for (const NetworkOutputStreamWorkerPtr& pWorker : workers) {
ShoutConnectionPtr connection = qSharedPointerCast<ShoutConnection>(pWorker);
if (connection) {
Expand Down Expand Up @@ -192,7 +192,7 @@ bool BroadcastManager::removeConnection(BroadcastProfilePtr profile) {
}

ShoutConnectionPtr BroadcastManager::findConnectionForProfile(BroadcastProfilePtr profile) {
QVector<NetworkOutputStreamWorkerPtr> workers = m_pNetworkStream->outputWorkers();
const QVector<NetworkOutputStreamWorkerPtr> workers = m_pNetworkStream->outputWorkers();
for (const NetworkOutputStreamWorkerPtr& pWorker : workers) {
ShoutConnectionPtr connection = qSharedPointerCast<ShoutConnection>(pWorker);
if (connection.isNull()) {
Expand All @@ -213,7 +213,7 @@ void BroadcastManager::slotConnectionStatusChanged(int newState) {
connectedCount = 0, failedCount = 0;

// Collect status info
QList<BroadcastProfilePtr> profiles = m_pBroadcastSettings->profiles();
const QList<BroadcastProfilePtr> profiles = m_pBroadcastSettings->profiles();
for (BroadcastProfilePtr profile : profiles) {
if (!profile->getEnabled()) {
continue;
Expand Down
62 changes: 23 additions & 39 deletions src/controllers/bulk/bulkcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <libusb.h>

#include <algorithm>

#include "controllers/bulk/bulksupported.h"
#include "controllers/defs_controllers.h"
#include "moc_bulkcontroller.cpp"
Expand Down Expand Up @@ -131,12 +133,10 @@ bool BulkController::matchProductInfo(const ProductInfo& product) {
return false;
}

#if defined(__WINDOWS__) || defined(__APPLE__)
value = product.interface_number.toInt(&ok, 16);
if (!ok || m_interfaceNumber != static_cast<unsigned int>(value)) {
if (!ok || m_interfaceNumber != value) {
return false;
}
#endif

// Match found
return true;
Expand All @@ -149,23 +149,18 @@ int BulkController::open() {
}

/* Look up endpoint addresses in supported database */
int i;
for (i = 0; bulk_supported[i].vendor_id; ++i) {
if ((bulk_supported[i].vendor_id == m_vendorId) &&
(bulk_supported[i].product_id == m_productId)) {
m_inEndpointAddr = bulk_supported[i].in_epaddr;
m_outEndpointAddr = bulk_supported[i].out_epaddr;
#if defined(__WINDOWS__) || defined(__APPLE__)
m_interfaceNumber = bulk_supported[i].interface_number;
#endif
break;
}
}

if (bulk_supported[i].vendor_id == 0) {
const bulk_support_lookup* pDevice = std::find_if(
std::cbegin(bulk_supported), std::cend(bulk_supported), [this](const auto& dev) {
return dev.key.vendor_id == m_vendorId && dev.key.product_id == m_productId;
});
if (pDevice == std::cend(bulk_supported)) {
qCWarning(m_logBase) << "USB Bulk device" << getName() << "unsupported";
return -1;
}
m_inEndpointAddr = pDevice->endpoints.in_epaddr;
m_outEndpointAddr = pDevice->endpoints.out_epaddr;
m_interfaceNumber = pDevice->endpoints.interface_number;

// XXX: we should enumerate devices and match vendor, product, and serial
if (m_phandle == nullptr) {
Expand All @@ -177,31 +172,21 @@ int BulkController::open() {
qCWarning(m_logBase) << "Unable to open USB Bulk device" << getName();
return -1;
}

#if defined(__WINDOWS__) || defined(__APPLE__)
if (m_interfaceNumber && libusb_kernel_driver_active(m_phandle, m_interfaceNumber) == 1) {
qCDebug(m_logBase) << "Found a driver active for" << getName();
if (libusb_detach_kernel_driver(m_phandle, 0) == 0)
qCDebug(m_logBase) << "Kernel driver detached for" << getName();
else {
qCWarning(m_logBase) << "Couldn't detach kernel driver for" << getName();
libusb_close(m_phandle);
return -1;
}
if (libusb_set_auto_detach_kernel_driver(m_phandle, true) == LIBUSB_ERROR_NOT_SUPPORTED) {
qCDebug(m_logBase) << "unable to automatically detach kernel driver for" << getName();
}

if (m_interfaceNumber) {
int ret = libusb_claim_interface(m_phandle, m_interfaceNumber);
if (ret < 0) {
if (m_interfaceNumber.has_value()) {
int error = libusb_claim_interface(m_phandle, *m_interfaceNumber);
if (error < 0) {
qCWarning(m_logBase) << "Cannot claim interface for" << getName()
<< ":" << libusb_error_name(ret);
<< ":" << libusb_error_name(error);
libusb_close(m_phandle);
return -1;
} else {
qCDebug(m_logBase) << "Claimed interface for" << getName();
}
}
#endif

setOpen(true);
startEngine();
Expand Down Expand Up @@ -256,15 +241,13 @@ int BulkController::close() {
stopEngine();

// Close device
#if defined(__WINDOWS__) || defined(__APPLE__)
if (m_interfaceNumber) {
int ret = libusb_release_interface(m_phandle, m_interfaceNumber);
if (ret < 0) {
if (m_interfaceNumber.has_value()) {
int error = libusb_release_interface(m_phandle, *m_interfaceNumber);
if (error < 0) {
qCWarning(m_logBase) << "Cannot release interface for" << getName()
<< ":" << libusb_error_name(ret);
<< ":" << libusb_error_name(error);
}
}
#endif
qCInfo(m_logBase) << " Closing device";
libusb_close(m_phandle);
m_phandle = nullptr;
Expand Down Expand Up @@ -300,7 +283,8 @@ bool BulkController::sendBytes(const QByteArray& data) {
(unsigned char*)data.constData(),
data.size(),
&transferred,
0);
5000 // Send timeout in milliseconds
);
if (ret < 0) {
qCWarning(m_logOutput) << "Unable to send data to" << getName()
<< "serial #" << m_sUID << "-" << libusb_error_name(ret);
Expand Down
14 changes: 7 additions & 7 deletions src/controllers/bulk/bulkcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <QAtomicInt>
#include <QThread>
#include <optional>

#include "controllers/controller.h"
#include "controllers/hid/legacyhidcontrollermapping.h"
Expand Down Expand Up @@ -72,13 +73,12 @@ class BulkController : public Controller {

// Local copies of things we need from desc

unsigned short m_vendorId;
unsigned short m_productId;
unsigned char m_inEndpointAddr;
unsigned char m_outEndpointAddr;
#if defined(__WINDOWS__) || defined(__APPLE__)
unsigned int m_interfaceNumber;
#endif
std::uint16_t m_vendorId;
std::uint16_t m_productId;
std::uint8_t m_inEndpointAddr;
std::uint8_t m_outEndpointAddr;
std::optional<std::uint8_t> m_interfaceNumber;

QString m_manufacturer;
QString m_product;

Expand Down
16 changes: 7 additions & 9 deletions src/controllers/bulk/bulkenumerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ BulkEnumerator::~BulkEnumerator() {
libusb_exit(m_context);
}

static bool is_interesting(struct libusb_device_descriptor *desc) {
for (int i = 0; bulk_supported[i].vendor_id; ++i) {
if ((bulk_supported[i].vendor_id == desc->idVendor) &&
(bulk_supported[i].product_id == desc->idProduct)) {
return true;
}
}
return false;
static bool is_interesting(const libusb_device_descriptor& desc) {
return std::any_of(std::cbegin(bulk_supported),
std::cend(bulk_supported),
[&](const auto& dev) {
return dev.key.vendor_id == desc.idVendor && dev.key.product_id == desc.idProduct;
});
}

QList<Controller*> BulkEnumerator::queryDevices() {
Expand All @@ -43,7 +41,7 @@ QList<Controller*> BulkEnumerator::queryDevices() {
struct libusb_device_descriptor desc;

libusb_get_device_descriptor(device, &desc);
if (is_interesting(&desc)) {
if (is_interesting(desc)) {
struct libusb_device_handle* handle = nullptr;
err = libusb_open(device, &handle);
if (err) {
Expand Down
41 changes: 27 additions & 14 deletions src/controllers/bulk/bulksupported.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
#pragma once

#include <cstdint>
#include <optional>

struct bulk_device_id {
std::uint16_t vendor_id;
std::uint16_t product_id;
};

// A list of supported USB bulk devices

#pragma once
struct bulk_device_endpoints {
std::uint8_t in_epaddr;
std::uint8_t out_epaddr;
// we may not know the interface, in which case we should not try to claim it.
// these devices are likely unusable on windows without claiming the correct interface.
std::optional<std::uint8_t> interface_number;
};

typedef struct bulk_supported {
unsigned short vendor_id;
unsigned short product_id;
unsigned char in_epaddr;
unsigned char out_epaddr;
unsigned int interface_number;
} bulk_supported_t;
struct bulk_support_lookup {
bulk_device_id key;
bulk_device_endpoints endpoints;
};

static bulk_supported_t bulk_supported[] = {
{0x06f8, 0xb105, 0x82, 0x03, 0}, // Hercules MP3e2
{0x06f8, 0xb107, 0x83, 0x03, 0}, // Hercules Mk4
{0x06f8, 0xb100, 0x86, 0x06, 0}, // Hercules Mk2
{0x06f8, 0xb120, 0x82, 0x03, 0}, // Hercules MP3 LE / Glow
{0, 0, 0, 0, 0}};
constexpr static bulk_support_lookup bulk_supported[] = {
{{0x06f8, 0xb105}, {0x82, 0x03, std::nullopt}}, // Hercules MP3e2
{{0x06f8, 0xb107}, {0x83, 0x03, std::nullopt}}, // Hercules Mk4
{{0x06f8, 0xb100}, {0x86, 0x06, std::nullopt}}, // Hercules Mk2
{{0x06f8, 0xb120}, {0x82, 0x03, std::nullopt}}, // Hercules MP3 LE / Glow
};
2 changes: 1 addition & 1 deletion src/controllers/controllermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void ControllerManager::slotSetUpDevices() {
qDebug() << "ControllerManager: Setting up devices";

updateControllerList();
QList<Controller*> deviceList = getControllerList(false, true);
const QList<Controller*> deviceList = getControllerList(false, true);
QStringList mappingPaths(getMappingPaths(m_pConfig));

for (Controller* pController : deviceList) {
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/controlpickermenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ ControlPickerMenu::ControlPickerMenu(QWidget* pParent)
"position as loop end") +
noBeatsSeconds;

QList<double> beatSizes = LoopingControl::getBeatSizes();
const QList<double> beatSizes = LoopingControl::getBeatSizes();

QMap<double, QString> humanBeatSizes;
humanBeatSizes[0.03125] = tr("1/32");
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/dlgprefcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ MappingInfo DlgPrefController::enumerateMappingsFromEnumerator(
// re-enumerate on the next open of the preferences.
if (!pMappingEnumerator.isNull()) {
// Get a list of mappings in alphabetical order
QList<MappingInfo> systemMappings =
const QList<MappingInfo> systemMappings =
pMappingEnumerator->getMappingsByExtension(
m_pController->mappingExtension());

Expand Down
4 changes: 2 additions & 2 deletions src/controllers/dlgprefcontrollers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void DlgPrefControllers::destroyControllerWidgets() {
// to keep this dialog and the controllermanager consistent.
QList<Controller*> controllerList =
m_pControllerManager->getControllerList(false, true);
for (auto* pController : controllerList) {
for (auto* pController : std::as_const(controllerList)) {
pController->disconnect(this);
}
while (!m_controllerPages.isEmpty()) {
Expand Down Expand Up @@ -175,7 +175,7 @@ void DlgPrefControllers::setupControllerWidgets() {

std::sort(controllerList.begin(), controllerList.end(), controllerCompare);

for (auto* pController : controllerList) {
for (auto* pController : std::as_const(controllerList)) {
DlgPrefController* pControllerDlg = new DlgPrefController(
this, pController, m_pControllerManager, m_pConfig);
connect(pControllerDlg,
Expand Down
Loading

0 comments on commit 755e3ad

Please sign in to comment.