summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Schweer <ws.seh.de>2006-10-01 11:32:30 +0000
committerWerner Schweer <ws.seh.de>2006-10-01 11:32:30 +0000
commitd2bb1a4af04061b623cf4ab5d34f1ad12e6f8b77 (patch)
tree1cf2208959320dfc8bdd58e022a5d1a293a54ff6
parent2e6a0d57ebadfd5d21df28099c103d4b5c858b3c (diff)
changed locking of audio and midi sequencer thread
-rw-r--r--muse/ChangeLog3
-rw-r--r--muse/muse/audio.cpp2
-rw-r--r--muse/muse/marker/markerview.cpp4
-rw-r--r--muse/muse/midi.cpp2
-rw-r--r--muse/muse/midiseq.cpp23
-rw-r--r--muse/muse/midiseq.h2
6 files changed, 16 insertions, 20 deletions
diff --git a/muse/ChangeLog b/muse/ChangeLog
index 3d928e0a..6289b3b3 100644
--- a/muse/ChangeLog
+++ b/muse/ChangeLog
@@ -1,3 +1,6 @@
+1.10 (ws)
+ - changed locking of audio and midi sequencer thread (in my setup this
+ results in xrun free operation at 2.9 msec latency (kernel 2.6.18-rt5)
26.9 (ng) DeicsOnze 0.4.5
- add four level of quality
24.9 (ng) DeicsOnze 0.4.3
diff --git a/muse/muse/audio.cpp b/muse/muse/audio.cpp
index 32bf208d..d46786d7 100644
--- a/muse/muse/audio.cpp
+++ b/muse/muse/audio.cpp
@@ -471,7 +471,7 @@ printf("invalidate prefetch buffer\n");
}
}
- midiSeq->msgProcess(frames);
+ processMidi(frames);
GroupList* gl = song->groups();
AuxList* al = song->auxs();
diff --git a/muse/muse/marker/markerview.cpp b/muse/muse/marker/markerview.cpp
index 398b15c6..ae1f871a 100644
--- a/muse/muse/marker/markerview.cpp
+++ b/muse/muse/marker/markerview.cpp
@@ -389,8 +389,8 @@ void MarkerView::markerChanged(int val)
for (int k = 0; k < n; ++k) {
MarkerItem* item = (MarkerItem*)(table->topLevelItem(k));
if (item->marker() == &i->second) {
- ((QTreeWidgetItem*)item)->setSelected(true);
-// table->setCurrentItem(item);
+// ((QTreeWidgetItem*)item)->setSelected(true);
+ table->setCurrentItem(item);
return;
}
}
diff --git a/muse/muse/midi.cpp b/muse/muse/midi.cpp
index 5cd6d8a9..4b037fe2 100644
--- a/muse/muse/midi.cpp
+++ b/muse/muse/midi.cpp
@@ -637,6 +637,7 @@ void Audio::initDevices()
void Audio::processMidi(unsigned frames)
{
+ midiBusy = true;
MidiOutPortList* ol = song->midiOutPorts();
for (iMidiOutPort id = ol->begin(); id != ol->end(); ++id) {
(*id)->process(_curTickPos, _nextTickPos, _pos, frames);
@@ -659,6 +660,7 @@ void Audio::processMidi(unsigned frames)
}
port->afterProcess();
}
+ midiBusy = false;
}
//---------------------------------------------------------
diff --git a/muse/muse/midiseq.cpp b/muse/muse/midiseq.cpp
index bf774698..53d71c68 100644
--- a/muse/muse/midiseq.cpp
+++ b/muse/muse/midiseq.cpp
@@ -44,6 +44,8 @@ MidiSeq* midiSeq;
static const unsigned char mmcStopMsg[] = { 0x7f, 0x7f, 0x06, 0x01 };
static const unsigned char mmcDeferredPlayMsg[] = { 0x7f, 0x7f, 0x06, 0x03 };
+volatile bool midiBusy;
+
//---------------------------------------------------------
// readMsg
//---------------------------------------------------------
@@ -60,12 +62,8 @@ static void readMsg(void* p, void*)
void MidiSeq::processMsg(const ThreadMsg* m)
{
-
AudioMsg* msg = (AudioMsg*)m;
switch (msg->id) {
- case MS_PROCESS:
- audio->processMidi(msg->time);
- break;
case SEQM_SEEK:
processSeek();
break;
@@ -513,6 +511,11 @@ void MidiSeq::processTimerTick()
if (idle)
return;
+ if (midiBusy) {
+ // we hit audio: midiSeq->msgProcess
+ // miss this timer tick
+ return;
+ }
unsigned curFrame = audio->curFrame();
/* if (!extSyncFlag.value()) {
@@ -551,18 +554,6 @@ void MidiSeq::msgMsg(int id)
Thread::sendMsg(&msg);
}
-//---------------------------------------------------------
-// msgProcess
-//---------------------------------------------------------
-
-void MidiSeq::msgProcess(unsigned frames)
- {
- AudioMsg msg;
- msg.id = MS_PROCESS;
- msg.time = frames;
- Thread::sendMsg(&msg);
- }
-
void MidiSeq::msgSeek() { msgMsg(SEQM_SEEK); }
void MidiSeq::msgStop() { msgMsg(MS_STOP); }
void MidiSeq::msgStart() { msgMsg(MS_START); }
diff --git a/muse/muse/midiseq.h b/muse/muse/midiseq.h
index 346aa8b4..98739749 100644
--- a/muse/muse/midiseq.h
+++ b/muse/muse/midiseq.h
@@ -84,7 +84,6 @@ class MidiSeq : public Thread {
void mmcInput(int id, int cmd, const AL::Pos&);
void msgMsg(int id);
- void msgProcess(unsigned frames);
void msgSeek();
void msgStart();
void msgStop();
@@ -94,5 +93,6 @@ class MidiSeq : public Thread {
};
extern MidiSeq* midiSeq;
+extern volatile bool midiBusy;
#endif