Skip to content

Commit

Permalink
Merge pull request #13737 from acolombier/feat/improve-screen-renderi…
Browse files Browse the repository at this point in the history
…ng-framework

feat: improve screen rendering framework
  • Loading branch information
Swiftb0y authored Oct 27, 2024
2 parents 75a44d6 + 533cedb commit 701a6ec
Show file tree
Hide file tree
Showing 21 changed files with 211 additions and 235 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2789,6 +2789,7 @@ if(QML)
src/qml/qmlvisibleeffectsmodel.cpp
src/qml/qmlchainpresetmodel.cpp
src/qml/qmlwaveformoverview.cpp
src/qml/qmlmixxxcontrollerscreen.cpp
# The following sources need to be in this target to get QML_ELEMENT properly interpreted
src/control/controlmodel.cpp
src/control/controlsortfiltermodel.cpp
Expand All @@ -2800,6 +2801,7 @@ if(QML)
# and :/mixxx.org/imports/Mixxx/Controls are placed into beginning of the binary
qt_finalize_target(mixxx)


install(
DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}/res/qml"
Expand Down
8 changes: 4 additions & 4 deletions res/controllers/DummyDeviceDefaultScreen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Mixxx.Controls 1.0 as MixxxControls

import "." as Skin

Item {
Mixxx.ControllerScreen {
id: root

required property string screenId
Expand All @@ -23,7 +23,7 @@ Item {
property string group: "[Channel1]"
property var deckPlayer: Mixxx.PlayerManager.getPlayer(root.group)

function init(controlerName, isDebug) {
init: function(controlerName, isDebug) {
console.log(`Screen ${root.screenId} has started`)
switch (root.screenId) {
case "jog":
Expand All @@ -34,13 +34,13 @@ Item {
}
}

function shutdown() {
shutdown: function() {
console.log(`Screen ${root.screenId} is stopping`)
loader.sourceComponent = splash
}

// function transformFrame(input: ArrayBuffer, timestamp: date) {
function transformFrame(input, timestamp) {
transformFrame: function(input, timestamp) {
return new ArrayBuffer(0);
}

Expand Down
7 changes: 5 additions & 2 deletions src/controllers/bulk/bulkcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "controllers/bulk/bulksupported.h"
#include "controllers/defs_controllers.h"
#include "moc_bulkcontroller.cpp"
#include "util/cmdlineargs.h"
#include "util/time.h"
#include "util/trace.h"

Expand Down Expand Up @@ -264,13 +265,13 @@ void BulkController::send(const QList<int>& data, unsigned int length) {
sendBytes(temp);
}

void BulkController::sendBytes(const QByteArray& data) {
bool BulkController::sendBytes(const QByteArray& data) {
VERIFY_OR_DEBUG_ASSERT(!m_pMapping ||
m_pMapping->getDeviceDirection() &
LegacyControllerMapping::DeviceDirection::Outgoing) {
qDebug() << "The mapping for the bulk device" << getName()
<< "doesn't require sending data. Ignoring sending request.";
return;
return false;
}

int ret;
Expand All @@ -287,8 +288,10 @@ void BulkController::sendBytes(const QByteArray& data) {
if (ret < 0) {
qCWarning(m_logOutput) << "Unable to send data to" << getName()
<< "serial #" << m_sUID << "-" << libusb_error_name(ret);
return false;
} else if (CmdlineArgs::Instance().getControllerDebug()) {
qCDebug(m_logOutput) << transferred << "bytes sent to" << getName()
<< "serial #" << m_sUID;
}
return true;
}
2 changes: 1 addition & 1 deletion src/controllers/bulk/bulkcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class BulkController : public Controller {
private:
// For devices which only support a single report, reportID must be set to
// 0x0.
void sendBytes(const QByteArray& data) override;
bool sendBytes(const QByteArray& data) override;

bool matchProductInfo(const ProductInfo& product);

Expand Down
5 changes: 3 additions & 2 deletions src/controllers/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ class Controller : public QObject {

public:
// This must be reimplemented by sub-classes desiring to send raw bytes to a
// controller.
virtual void sendBytes(const QByteArray& data) = 0;
// controller. Return true in case of successful completion, false in case
// of partial completion or failure.
virtual bool sendBytes(const QByteArray& data) = 0;

private: // but used by ControllerManager

Expand Down
1 change: 1 addition & 0 deletions src/controllers/controllerscreenpreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ControllerScreenPreview::ControllerScreenPreview(
setMaximumWidth(screen.size.width());
m_pStat->setAlignment(Qt::AlignRight);
auto pLayout = make_parented<QVBoxLayout>(this);
pLayout->setContentsMargins(0, 0, 0, 0);
auto* pBottomLayout = new QHBoxLayout();
pLayout->addWidget(m_pFrame);
pBottomLayout->addWidget(make_parented<QLabel>(
Expand Down
3 changes: 2 additions & 1 deletion src/controllers/hid/hidcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,11 @@ int HidController::close() {
/// This function is only for class compatibility with the (midi)controller
/// and will not do the same as for MIDI devices,
/// because sending of raw bytes is not a supported HIDAPI feature.
void HidController::sendBytes(const QByteArray& data) {
bool HidController::sendBytes(const QByteArray& data) {
// Some HIDAPI backends will fail if the device uses ReportIDs (as practical all DJ controllers),
// because 0 is no valid ReportID for these devices.
m_pHidIoThread->updateCachedOutputReportData(0, data, false);
return true;
}

ControllerJSProxy* HidController::jsProxy() {
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/hid/hidcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class HidController final : public Controller {
private:
// For devices which only support a single report, reportID must be set to
// 0x0.
void sendBytes(const QByteArray& data) override;
bool sendBytes(const QByteArray& data) override;

const mixxx::hid::DeviceInfo m_deviceInfo;

Expand Down
4 changes: 3 additions & 1 deletion src/controllers/midi/hss1394controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,15 @@ void Hss1394Controller::sendShortMsg(unsigned char status, unsigned char byte1,
}
}

void Hss1394Controller::sendBytes(const QByteArray& data) {
bool Hss1394Controller::sendBytes(const QByteArray& data) {
const int bytesSent = m_pChannel->SendChannelBytes(
reinterpret_cast<const unsigned char*>(data.constData()), data.size());

qCDebug(m_logOutput) << MidiUtils::formatSysexMessage(getName(), data);
if (bytesSent != data.size()) {
qCWarning(m_logOutput) << "Sent" << bytesSent << "of" << data.size() << "bytes (SysEx)";
//m_pChannel->Flush();
return false;
}
return true;
}
2 changes: 1 addition & 1 deletion src/controllers/midi/hss1394controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Hss1394Controller : public MidiController {
private:
// The sysex data must already contain the start byte 0xf0 and the end byte
// 0xf7.
void sendBytes(const QByteArray& data) override;
bool sendBytes(const QByteArray& data) override;

hss1394::TNodeInfo m_deviceInfo;
int m_iDeviceIndex;
Expand Down
8 changes: 5 additions & 3 deletions src/controllers/midi/portmidicontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,28 +222,30 @@ void PortMidiController::sendShortMsg(unsigned char status, unsigned char byte1,
}
}

void PortMidiController::sendBytes(const QByteArray& data) {
bool PortMidiController::sendBytes(const QByteArray& data) {
// PortMidi does not receive a length argument for the buffer we provide to
// Pm_WriteSysEx. Instead, it scans for a MidiOpCode::EndOfExclusive byte
// to know when the message is over. If one is not provided, it will
// overflow the buffer and cause a segfault.
if (!data.endsWith(MidiUtils::opCodeValue(MidiOpCode::EndOfExclusive))) {
qCDebug(m_logOutput) << "SysEx message does not end with 0xF7 -- ignoring.";
return;
return false;
}

if (m_pOutputDevice.isNull() || !m_pOutputDevice->isOpen()) {
return;
return false;
}

PmError err = m_pOutputDevice->writeSysEx((unsigned char*)data.constData());
if (err == pmNoError) {
qCDebug(m_logOutput) << QStringLiteral("outgoing: ")
<< MidiUtils::formatSysexMessage(getName(), data);
return true;
} else {
// Use two qWarnings() to ensure line break works on all operating systems
qCWarning(m_logOutput) << "Error sending SysEx message:"
<< MidiUtils::formatSysexMessage(getName(), data);
qCWarning(m_logOutput) << "PortMidi error:" << Pm_GetErrorText(err);
}
return false;
}
2 changes: 1 addition & 1 deletion src/controllers/midi/portmidicontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class PortMidiController : public MidiController {
private:
// The sysex data must already contain the start byte 0xf0 and the end byte
// 0xf7.
void sendBytes(const QByteArray& data) override;
bool sendBytes(const QByteArray& data) override;

bool isPolling() const override {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/rendering/controllerrenderingengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ void ControllerRenderingEngine::send(Controller* controller, const QByteArray& f
DEBUG_ASSERT_THIS_QOBJECT_THREAD_AFFINITY();
ScopedTimer t(QStringLiteral("ControllerRenderingEngine::send"));
if (!frame.isEmpty()) {
controller->sendBytes(frame);
VERIFY_OR_TERMINATE(controller->sendBytes(frame), "Unable to send frame to device");
}

if (CmdlineArgs::Instance()
Expand Down
Loading

0 comments on commit 701a6ec

Please sign in to comment.