Merge lp:~mixxxdevelopers/mixxx/fixes_midi_burnout into lp:~mixxxdevelopers/mixxx/trunk

Proposed by William Good
Status: Merged
Merged at revision: 3257
Proposed branch: lp:~mixxxdevelopers/mixxx/fixes_midi_burnout
Merge into: lp:~mixxxdevelopers/mixxx/trunk
Diff against target: 147 lines (+49/-7)
7 files modified
mixxx/build/depends.py (+1/-0)
mixxx/src/controllers/controller.h (+3/-2)
mixxx/src/controllers/controllermanager.cpp (+6/-1)
mixxx/src/controllers/midi/portmidicontroller.cpp (+4/-3)
mixxx/src/controllers/midi/portmidicontroller.h (+1/-1)
mixxx/src/sleepableqthread.cpp (+8/-0)
mixxx/src/sleepableqthread.h (+26/-0)
To merge this branch: bzr merge lp:~mixxxdevelopers/mixxx/fixes_midi_burnout
Reviewer Review Type Date Requested Status
Mixxx Development Team Pending
Review via email: mp+106679@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'mixxx/build/depends.py'
--- mixxx/build/depends.py 2012-05-19 00:27:41 +0000
+++ mixxx/build/depends.py 2012-05-21 17:49:20 +0000
@@ -581,6 +581,7 @@
581 "tapfilter.cpp",581 "tapfilter.cpp",
582582
583 "util/pa_ringbuffer.c",583 "util/pa_ringbuffer.c",
584 "sleepableqthread.cpp",
584585
585 # Add the QRC file which compiles in some extra resources586 # Add the QRC file which compiles in some extra resources
586 # (prefs icons, etc.)587 # (prefs icons, etc.)
587588
=== modified file 'mixxx/src/controllers/controller.h'
--- mixxx/src/controllers/controller.h 2012-04-29 01:40:37 +0000
+++ mixxx/src/controllers/controller.h 2012-05-21 17:49:20 +0000
@@ -122,8 +122,9 @@
122 private slots:122 private slots:
123 virtual int open() = 0;123 virtual int open() = 0;
124 virtual int close() = 0;124 virtual int close() = 0;
125 // Requests that the device poll if it is a polling device.125 // Requests that the device poll if it is a polling device. Returns true
126 virtual void poll() { }126 // if events were handled.
127 virtual bool poll() { return false; }
127128
128 private:129 private:
129 // This must be reimplemented by sub-classes desiring to send raw bytes to a130 // This must be reimplemented by sub-classes desiring to send raw bytes to a
130131
=== modified file 'mixxx/src/controllers/controllermanager.cpp'
--- mixxx/src/controllers/controllermanager.cpp 2012-05-01 14:45:33 +0000
+++ mixxx/src/controllers/controllermanager.cpp 2012-05-21 17:49:20 +0000
@@ -7,6 +7,7 @@
77
8#include <QSet>8#include <QSet>
99
10#include "sleepableqthread.h"
10#include "controllers/controllermanager.h"11#include "controllers/controllermanager.h"
11#include "controllers/defs_controllers.h"12#include "controllers/defs_controllers.h"
12#include "controllers/controllerlearningeventfilter.h"13#include "controllers/controllerlearningeventfilter.h"
@@ -246,11 +247,15 @@
246}247}
247248
248void ControllerManager::pollDevices() {249void ControllerManager::pollDevices() {
250 bool eventsProcessed(false);
249 foreach (Controller* pDevice, m_controllers) {251 foreach (Controller* pDevice, m_controllers) {
250 if (pDevice->isOpen() && pDevice->isPolling()) {252 if (pDevice->isOpen() && pDevice->isPolling()) {
251 pDevice->poll();253 eventsProcessed = pDevice->poll() || eventsProcessed;
252 }254 }
253 }255 }
256 // if we didn't process anything, sleep a bit to avoid burning/hogging
257 // cpu cycles
258 if (!eventsProcessed) SleepableQThread::msleep(1);
254}259}
255260
256QList<QString> ControllerManager::getPresetList(QString extension) {261QList<QString> ControllerManager::getPresetList(QString extension) {
257262
=== modified file 'mixxx/src/controllers/midi/portmidicontroller.cpp'
--- mixxx/src/controllers/midi/portmidicontroller.cpp 2012-04-24 05:42:04 +0000
+++ mixxx/src/controllers/midi/portmidicontroller.cpp 2012-05-21 17:49:20 +0000
@@ -134,18 +134,18 @@
134 return 0;134 return 0;
135}135}
136136
137void PortMidiController::poll() {137bool PortMidiController::poll() {
138 // Poll the controller for new data138 // Poll the controller for new data
139 int numEvents = 0;139 int numEvents = 0;
140140
141 if (m_pInputStream) {141 if (m_pInputStream) {
142 PmError gotEvents = Pm_Poll(m_pInputStream);142 PmError gotEvents = Pm_Poll(m_pInputStream);
143 if (gotEvents == FALSE) {143 if (gotEvents == FALSE) {
144 return;144 return false;
145 }145 }
146 if (gotEvents < 0) {146 if (gotEvents < 0) {
147 qWarning() << "PortMidi error:" << Pm_GetErrorText(gotEvents);147 qWarning() << "PortMidi error:" << Pm_GetErrorText(gotEvents);
148 return;148 return false;
149 }149 }
150150
151 numEvents = Pm_Read(m_pInputStream, m_midiBuffer, MIXXX_PORTMIDI_BUFFER_LEN);151 numEvents = Pm_Read(m_pInputStream, m_midiBuffer, MIXXX_PORTMIDI_BUFFER_LEN);
@@ -198,6 +198,7 @@
198 m_cReceiveMsg_index = 0;198 m_cReceiveMsg_index = 0;
199 }199 }
200 }200 }
201 return numEvents > 0;
201}202}
202203
203void PortMidiController::send(unsigned int word) {204void PortMidiController::send(unsigned int word) {
204205
=== modified file 'mixxx/src/controllers/midi/portmidicontroller.h'
--- mixxx/src/controllers/midi/portmidicontroller.h 2012-04-24 07:19:23 +0000
+++ mixxx/src/controllers/midi/portmidicontroller.h 2012-05-21 17:49:20 +0000
@@ -36,7 +36,7 @@
36 private slots:36 private slots:
37 virtual int open();37 virtual int open();
38 virtual int close();38 virtual int close();
39 virtual void poll();39 virtual bool poll();
4040
41 private:41 private:
42 void send(unsigned int word);42 void send(unsigned int word);
4343
=== added file 'mixxx/src/sleepableqthread.cpp'
--- mixxx/src/sleepableqthread.cpp 1970-01-01 00:00:00 +0000
+++ mixxx/src/sleepableqthread.cpp 2012-05-21 17:49:20 +0000
@@ -0,0 +1,8 @@
1// sleepableqthread.cpp
2// Created May 21, 2012 by Bill Good <bkgood at gmail dot com>
3//
4// This is just a dummy file meant to be shoved in the build list so that moc
5// runs on the class and linker errors are avoided.
6
7#include "sleepableqthread.h"
8
09
=== added file 'mixxx/src/sleepableqthread.h'
--- mixxx/src/sleepableqthread.h 1970-01-01 00:00:00 +0000
+++ mixxx/src/sleepableqthread.h 2012-05-21 17:49:20 +0000
@@ -0,0 +1,26 @@
1// sleepableqthread.h
2// Created May 21, 2012 by Bill Good <bkgood at gmail dot com>
3
4#include <QThread>
5
6// Subclass of QThread exposing static sleep methods. Qt developers know
7// better than us and therefore made these methods protected but I'm a
8// rebel.
9class SleepableQThread : public QThread {
10 Q_OBJECT;
11 Q_DISABLE_COPY(SleepableQThread);
12public:
13 explicit SleepableQThread(QObject *parent = NULL) : QThread(parent) { }
14 virtual ~SleepableQThread() { }
15 static void sleep(unsigned long secs) {
16 QThread::sleep(secs);
17 }
18
19 static void msleep(unsigned long msecs) {
20 QThread::msleep(msecs);
21 }
22
23 static void usleep(unsigned long usecs) {
24 QThread::usleep(usecs);
25 }
26};

Subscribers

People subscribed via source and target branches