summaryrefslogtreecommitdiff
path: root/muse2/muse/driver
diff options
context:
space:
mode:
authorOrcan Ogetbil <oget.fedora@gmail.com>2011-09-08 02:05:32 +0000
committerOrcan Ogetbil <oget.fedora@gmail.com>2011-09-08 02:05:32 +0000
commitd3e8a1b4c98cb3ba8b73f367ea88ad23f8dbca66 (patch)
tree921e5193e46287f0c34f4eff1590efb1df18d20f /muse2/muse/driver
parentff0c5e9154e7a3d71d2465639b5e0da1ea2c7242 (diff)
introducing namespaces
Diffstat (limited to 'muse2/muse/driver')
-rw-r--r--muse2/muse/driver/alsamidi.cpp10
-rw-r--r--muse2/muse/driver/dummyaudio.cpp60
-rw-r--r--muse2/muse/driver/jack.cpp118
-rw-r--r--muse2/muse/driver/jackaudio.h5
-rw-r--r--muse2/muse/driver/jackmidi.cpp46
-rw-r--r--muse2/muse/driver/rtctimer.cpp8
6 files changed, 131 insertions, 116 deletions
diff --git a/muse2/muse/driver/alsamidi.cpp b/muse2/muse/driver/alsamidi.cpp
index cde3febf..07688a33 100644
--- a/muse2/muse/driver/alsamidi.cpp
+++ b/muse2/muse/driver/alsamidi.cpp
@@ -294,7 +294,7 @@ void MidiAlsaDevice::writeRouting(int level, Xml& xml) const
bool MidiAlsaDevice::putMidiEvent(const MidiPlayEvent& e)
{
- if (midiOutputTrace) {
+ if (MusEGlobal::midiOutputTrace) {
printf("MidiOut: midiAlsa: ");
e.dump();
}
@@ -472,7 +472,7 @@ bool MidiAlsaDevice::putEvent(snd_seq_event_t* event)
bool initMidiAlsa()
{
- if (debugMsg)
+ if (MusEGlobal::debugMsg)
printf("initMidiAlsa\n");
int error = snd_seq_open(&alsaSeq, "hw", SND_SEQ_OPEN_DUPLEX, SND_SEQ_NONBLOCK);
if (error < 0) {
@@ -510,7 +510,7 @@ bool initMidiAlsa()
if (capability & inCap)
flags |= 2;
dev->setrwFlags(flags);
- if (debugMsg)
+ if (MusEGlobal::debugMsg)
printf("ALSA port add: <%s>, %d:%d flags %d 0x%0x\n",
snd_seq_port_info_get_name(pinfo),
adr.client, adr.port,
@@ -765,7 +765,7 @@ void alsaProcessMidiInput()
}
if (mdev == 0 || curPort == -1) {
- if (debugMsg) {
+ if (MusEGlobal::debugMsg) {
fprintf(stderr, "no port %d:%d found for received alsa event\n",
ev->source.client, ev->source.port);
}
@@ -778,7 +778,7 @@ void alsaProcessMidiInput()
{
if(mdev == 0)
{
- if (debugMsg)
+ if (MusEGlobal::debugMsg)
{
fprintf(stderr, "no port %d:%d found for received alsa event\n",
ev->source.client, ev->source.port);
diff --git a/muse2/muse/driver/dummyaudio.cpp b/muse2/muse/driver/dummyaudio.cpp
index dae21a26..77b08252 100644
--- a/muse2/muse/driver/dummyaudio.cpp
+++ b/muse2/muse/driver/dummyaudio.cpp
@@ -98,7 +98,7 @@ class DummyAudioDevice : public AudioDevice {
// p3.3.30
//if (nframes > dummyFrames) {
//printf("error: segment size > 1024\n");
- if (nframes > segmentSize) {
+ if (nframes > MusEGlobal::segmentSize) {
printf("DummyAudioDevice::getBuffer nframes > segment size\n");
exit(-1);
@@ -140,7 +140,7 @@ class DummyAudioDevice : public AudioDevice {
return _framePos; }
virtual unsigned frameTime() const {
- return lrint(curTime() * sampleRate);
+ return lrint(curTime() * MusEGlobal::sampleRate);
}
virtual bool isRealtime() { return realtimeFlag; }
//virtual int realtimePriority() const { return 40; }
@@ -215,7 +215,7 @@ DummyAudioDevice::DummyAudioDevice()
// Added by Tim. p3.3.15
// p3.3.30
//posix_memalign((void**)&buffer, 16, sizeof(float) * dummyFrames);
- posix_memalign((void**)&buffer, 16, sizeof(float) * config.dummyAudioBufSize);
+ posix_memalign((void**)&buffer, 16, sizeof(float) * MusEConfig::config.dummyAudioBufSize);
dummyThread = 0;
realtimeFlag = false;
@@ -227,6 +227,8 @@ DummyAudioDevice::DummyAudioDevice()
cmdQueue.clear();
}
+namespace MusEApp {
+
//---------------------------------------------------------
// exitDummyAudio
//---------------------------------------------------------
@@ -239,6 +241,8 @@ void exitDummyAudio()
audioDevice = NULL;
}
+} // namespace MusEApp
+
//---------------------------------------------------------
// initDummyAudio
//---------------------------------------------------------
@@ -289,13 +293,13 @@ static void* dummyLoop(void* ptr)
//unsigned int tickRate = 25;
// p3.3.30
- //sampleRate = 25600;
- sampleRate = config.dummyAudioSampleRate;
- //segmentSize = dummyFrames;
- segmentSize = config.dummyAudioBufSize;
+ //MusEGlobal::sampleRate = 25600;
+ MusEGlobal::sampleRate = MusEConfig::config.dummyAudioSampleRate;
+ //MusEGlobal::segmentSize = dummyFrames;
+ MusEGlobal::segmentSize = MusEConfig::config.dummyAudioBufSize;
#if 0
- //unsigned int tickRate = sampleRate / dummyFrames;
- unsigned int tickRate = sampleRate / segmentSize;
+ //unsigned int tickRate = MusEGlobal::sampleRate / dummyFrames;
+ unsigned int tickRate = MusEGlobal::sampleRate / MusEGlobal::segmentSize;
AlsaTimer timer;
fprintf(stderr, "Get alsa timer for dummy driver:\n");
@@ -312,7 +316,7 @@ static void* dummyLoop(void* ptr)
/* Depending on nature of the timer, the requested tickRate might not
* be available. The return value is the nearest available frequency,
- * so use this to reset our dummpy sampleRate to keep everything
+ * so use this to reset our dummpy MusEGlobal::sampleRate to keep everything
* consistent.
*/
tickRate = timer.setTimerFreq( /*250*/ tickRate );
@@ -322,7 +326,7 @@ static void* dummyLoop(void* ptr)
if(tickRate == 0)
tickRate = timer.getTimerFreq();
- sampleRate = tickRate * segmentSize;
+ MusEGlobal::sampleRate = tickRate * MusEGlobal::segmentSize;
timer.startTimer();
#endif
@@ -335,7 +339,7 @@ static void* dummyLoop(void* ptr)
/*
- doSetuid();
+ MusEGlobal::doSetuid();
struct sched_param rt_param;
int rv;
memset(&rt_param, 0, sizeof(sched_param));
@@ -364,13 +368,13 @@ static void* dummyLoop(void* ptr)
fprintf(stderr, "Unable to set thread to SCHED_FIFO\n");
}
}
- undoSetuid();
+ MusEGlobal::undoSetuid();
*/
#ifndef __APPLE__
- doSetuid();
+ MusEGlobal::doSetuid();
//if (realTimePriority) {
- if (realTimeScheduling) {
+ if (MusEGlobal::realTimeScheduling) {
//
// check if we really got realtime priviledges
//
@@ -382,7 +386,7 @@ static void* dummyLoop(void* ptr)
{
if (policy != SCHED_FIFO)
printf("audio dummy thread _NOT_ running SCHED_FIFO\n");
- else if (debugMsg) {
+ else if (MusEGlobal::debugMsg) {
struct sched_param rt_param;
memset(&rt_param, 0, sizeof(sched_param));
int type;
@@ -394,7 +398,7 @@ static void* dummyLoop(void* ptr)
}
}
}
- undoSetuid();
+ MusEGlobal::undoSetuid();
#endif
#if 0
@@ -438,8 +442,8 @@ static void* dummyLoop(void* ptr)
}
}
}
- audio->process(segmentSize);
- int increment = segmentSize; // 1 //tickRate / sampleRate * segmentSize;
+ audio->process(MusEGlobal::segmentSize);
+ int increment = MusEGlobal::segmentSize; // 1 //tickRate / MusEGlobal::sampleRate * MusEGlobal::segmentSize;
drvPtr->_framePos+=increment;
if (drvPtr->state == Audio::PLAY)
{
@@ -452,12 +456,12 @@ static void* dummyLoop(void* ptr)
{
//if(audioState == AUDIO_RUNNING)
if(audio->isRunning())
- //audio->process(segmentSize, drvPtr->state);
- audio->process(segmentSize);
+ //audio->process(MusEGlobal::segmentSize, drvPtr->state);
+ audio->process(MusEGlobal::segmentSize);
//else if (audioState == AUDIO_START1)
// audioState = AUDIO_START2;
- //usleep(dummyFrames*1000000/AL::sampleRate);
- usleep(segmentSize*1000000/sampleRate);
+ //usleep(dummyFrames*1000000/AL::MusEGlobal::sampleRate);
+ usleep(MusEGlobal::segmentSize*1000000/MusEGlobal::sampleRate);
//if(dummyAudio->seekflag)
if(drvPtr->seekflag)
{
@@ -471,9 +475,9 @@ static void* dummyLoop(void* ptr)
//if(dummyAudio->state == Audio::PLAY)
// dummyAudio->pos += dummyFrames;
- drvPtr->_framePos += segmentSize;
+ drvPtr->_framePos += MusEGlobal::segmentSize;
if(drvPtr->state == Audio::PLAY)
- drvPtr->playPos += segmentSize;
+ drvPtr->playPos += MusEGlobal::segmentSize;
}
#endif
@@ -487,7 +491,7 @@ void DummyAudioDevice::start(int priority)
_realTimePriority = priority;
pthread_attr_t* attributes = 0;
- if (realTimeScheduling && _realTimePriority > 0) {
+ if (MusEGlobal::realTimeScheduling && _realTimePriority > 0) {
attributes = (pthread_attr_t*) malloc(sizeof(pthread_attr_t));
pthread_attr_init(attributes);
@@ -514,11 +518,11 @@ void DummyAudioDevice::start(int priority)
int rv = pthread_create(&dummyThread, attributes, ::dummyLoop, this);
if(rv)
{
- // p4.0.16: realTimeScheduling is unreliable. It is true even in some clearly non-RT cases.
+ // p4.0.16: MusEGlobal::realTimeScheduling is unreliable. It is true even in some clearly non-RT cases.
// I cannot seem to find a reliable answer to the question of "are we RT or not".
// MusE was failing with a stock kernel because of PTHREAD_EXPLICIT_SCHED.
// So we'll just have to try again without attributes.
- if (realTimeScheduling && _realTimePriority > 0)
+ if (MusEGlobal::realTimeScheduling && _realTimePriority > 0)
rv = pthread_create(&dummyThread, NULL, ::dummyLoop, this);
}
diff --git a/muse2/muse/driver/jack.cpp b/muse2/muse/driver/jack.cpp
index 4bc6da0b..f99e07b9 100644
--- a/muse2/muse/driver/jack.cpp
+++ b/muse2/muse/driver/jack.cpp
@@ -54,8 +54,8 @@
//#include "errorhandler.h"
#ifndef RTCAP
-extern void doSetuid();
-extern void undoSetuid();
+extern void MusEGlobal::doSetuid();
+extern void MusEGlobal::undoSetuid();
#endif
#ifdef VST_SUPPORT
@@ -84,19 +84,6 @@ inline bool checkJackClient(jack_client_t* _client)
}
return true;
}
-//---------------------------------------------------------
-// checkAudioDevice - make sure audioDevice exists
-//---------------------------------------------------------
-bool checkAudioDevice()
- {
- if (audioDevice == NULL) {
- if(debugMsg)
- printf("Muse:checkAudioDevice: no audioDevice\n");
- return false;
- }
- return true;
- }
-
//---------------------------------------------------------
// jack_thread_init
@@ -104,7 +91,7 @@ bool checkAudioDevice()
static void jack_thread_init (void* ) // data
{
- doSetuid();
+ MusEGlobal::doSetuid();
/*
if (jackAudio->isRealtime()) {
struct sched_param rt_param;
@@ -138,7 +125,7 @@ static void jack_thread_init (void* ) // data
if (loadVST)
fst_adopt_thread();
#endif
- undoSetuid();
+ MusEGlobal::undoSetuid();
}
/*
@@ -287,11 +274,11 @@ int JackAudioDevice::processAudio(jack_nframes_t frames, void*)
// if (JACK_DEBUG)
// printf("processAudio - >>>>\n");
- segmentSize = frames;
+ MusEGlobal::segmentSize = frames;
if (audio->isRunning())
audio->process((unsigned long)frames);
else {
- if (debugMsg)
+ if (MusEGlobal::debugMsg)
puts("jack calling when audio is disconnected!\n");
}
// if (JACK_DEBUG)
@@ -411,7 +398,7 @@ static void processShutdown(void*)
audio->shutdown();
int c=0;
- while(midiSeqRunning == true) {
+ while(MusEGlobal::midiSeqRunning == true) {
if(c++ >10) {
fprintf(stderr, "sequencer still running, something is very wrong.\n");
break;
@@ -555,13 +542,13 @@ bool initJackAudio()
if (JACK_DEBUG)
printf("initJackAudio()\n");
- if (debugMsg) {
+ if (MusEGlobal::debugMsg) {
fprintf(stderr,"initJackAudio()\n");
jack_set_error_function(jackError);
}
else
jack_set_error_function(noJackError);
- doSetuid();
+ MusEGlobal::doSetuid();
//jack_client_t* client = 0;
//int i = 0;
@@ -589,25 +576,25 @@ bool initJackAudio()
if (status & JackVersionError)
printf("jack server has wrong version\n");
printf("cannot create jack client\n");
- undoSetuid(); // p3.3.51
+ MusEGlobal::undoSetuid(); // p3.3.51
return true;
}
- if (debugMsg)
+ if (MusEGlobal::debugMsg)
fprintf(stderr, "initJackAudio(): client %s opened.\n", jack_get_client_name(client));
if (client) {
jack_set_error_function(jackError);
//jackAudio = new JackAudioDevice(client, jackIdString);
jackAudio = new JackAudioDevice(client, jack_get_client_name(client));
- if (debugMsg)
+ if (MusEGlobal::debugMsg)
fprintf(stderr, "initJackAudio(): registering client...\n");
jackAudio->registerClient();
- sampleRate = jack_get_sample_rate(client);
- segmentSize = jack_get_buffer_size(client);
+ MusEGlobal::sampleRate = jack_get_sample_rate(client);
+ MusEGlobal::segmentSize = jack_get_buffer_size(client);
jack_set_thread_init_callback(client, (JackThreadInitCallback) jack_thread_init, 0);
//jack_set_timebase_callback(client, 0, (JackTimebaseCallback) timebase_callback, 0);
}
- undoSetuid();
+ MusEGlobal::undoSetuid();
/*
// setup midi input/output
@@ -662,14 +649,14 @@ static int bufsize_callback(jack_nframes_t n, void*)
static void freewheel_callback(int starting, void*)
{
- if (debugMsg || JACK_DEBUG)
+ if (MusEGlobal::debugMsg || JACK_DEBUG)
printf("JACK: freewheel_callback: starting%d\n", starting);
audio->setFreewheel(starting);
}
static int srate_callback(jack_nframes_t n, void*)
{
- if (debugMsg || JACK_DEBUG)
+ if (MusEGlobal::debugMsg || JACK_DEBUG)
printf("JACK: sample rate changed: %d\n", n);
return 0;
}
@@ -680,7 +667,7 @@ static int srate_callback(jack_nframes_t n, void*)
static void registration_callback(jack_port_id_t, int, void*)
{
- if(debugMsg || JACK_DEBUG)
+ if(MusEGlobal::debugMsg || JACK_DEBUG)
printf("JACK: registration changed\n");
audio->sendMsgToGui('R');
@@ -758,7 +745,7 @@ void JackAudioDevice::connectJackMidiPorts()
// Ignore our own client ports.
if(jack_port_is_mine(_client, port))
{
- if(debugMsg)
+ if(MusEGlobal::debugMsg)
printf(" ignoring own port: %s\n", *p);
continue;
}
@@ -769,7 +756,7 @@ void JackAudioDevice::connectJackMidiPorts()
//if(strncmp(buffer, "MusE", 4) == 0)
// continue;
- if(debugMsg)
+ if(MusEGlobal::debugMsg)
printf(" found port: %s ", buffer);
// If there are aliases for this port, use the first one - much better for identifying.
@@ -785,7 +772,7 @@ void JackAudioDevice::connectJackMidiPorts()
//char* namep = (na >= 1) ? aliases[0] : buffer;
char* namep = aliases[0];
- if(debugMsg)
+ if(MusEGlobal::debugMsg)
printf("alias: %s\n", aliases[0]);
//int flags = 0;
@@ -862,7 +849,7 @@ void JackAudioDevice::connectJackMidiPorts()
static void client_registration_callback(const char *name, int isRegister, void*)
{
- if (debugMsg || JACK_DEBUG)
+ if (MusEGlobal::debugMsg || JACK_DEBUG)
printf("JACK: client registration changed:%s register:%d\n", name, isRegister);
}
@@ -872,7 +859,7 @@ static void client_registration_callback(const char *name, int isRegister, void*
static void port_connect_callback(jack_port_id_t a, jack_port_id_t b, int isConnect, void*)
{
- if (debugMsg || JACK_DEBUG)
+ if (MusEGlobal::debugMsg || JACK_DEBUG)
{
//jack_port_t* ap = jack_port_by_id(_client, a);
//jack_port_t* bp = jack_port_by_id(_client, b);
@@ -895,7 +882,7 @@ static int graph_callback(void*)
// context, so we send a message to the gui thread which in turn
// calls graphChanged()
audio->sendMsgToGui('C');
- if (debugMsg)
+ if (MusEGlobal::debugMsg)
printf("JACK: graph changed\n");
return 0;
}
@@ -1383,6 +1370,26 @@ void* JackAudioDevice::registerOutPort(const char* name, bool midi)
return p;
}
+namespace MusEGlobal {
+
+//---------------------------------------------------------
+// checkAudioDevice - make sure audioDevice exists
+//---------------------------------------------------------
+
+bool checkAudioDevice()
+ {
+ if (audioDevice == NULL) {
+ if(MusEGlobal::debugMsg)
+ printf("Muse:checkAudioDevice: no audioDevice\n");
+ return false;
+ }
+ return true;
+ }
+
+} // namespace MusEGlobal
+
+namespace MusEApp {
+
//---------------------------------------------------------
// exitJackAudio
//---------------------------------------------------------
@@ -1401,6 +1408,7 @@ void exitJackAudio()
audioDevice = NULL;
}
+} // namespace MusEApp
//---------------------------------------------------------
// connect
@@ -1473,10 +1481,10 @@ void JackAudioDevice::start(int /*priority*/)
printf("JackAudioDevice::start()\n");
if(!checkJackClient(_client)) return;
- doSetuid();
+ MusEGlobal::doSetuid();
if (jack_activate(_client)) {
- undoSetuid(); // p3.3.51
+ MusEGlobal::undoSetuid(); // p3.3.51
fprintf (stderr, "JACK: cannot activate client\n");
exit(-1);
}
@@ -1518,7 +1526,7 @@ void JackAudioDevice::start(int /*priority*/)
// Connect the Jack midi client ports to device ports.
connectJackMidiPorts();
- undoSetuid();
+ MusEGlobal::undoSetuid();
//MUSE_DEBUG("JackAudioDevice::start()\n");
fflush(stdin);
@@ -1609,7 +1617,7 @@ int JackAudioDevice::framesSinceCycleStart() const
int JackAudioDevice::frameDelay() const
{
- jack_nframes_t n = (segmentSize * (segmentCount-1)) - jack_frames_since_cycle_start(client);
+ jack_nframes_t n = (MusEGlobal::segmentSize * (segmentCount-1)) - jack_frames_since_cycle_start(client);
return (int)n;
}
#endif
@@ -1640,7 +1648,7 @@ std::list<QString> JackAudioDevice::outputPorts(bool midi, int aliases)
strncpy(buffer, *p, nsz);
//if (strncmp(buffer, "MusE", 4) == 0)
//{
- // if(debugMsg)
+ // if(MusEGlobal::debugMsg)
// printf("JackAudioDevice::outputPorts ignoring own MusE port: %s\n", *p);
// continue;
//}
@@ -1648,7 +1656,7 @@ std::list<QString> JackAudioDevice::outputPorts(bool midi, int aliases)
// Ignore our own client ports.
if(jack_port_is_mine(_client, port))
{
- if(debugMsg)
+ if(MusEGlobal::debugMsg)
printf("JackAudioDevice::outputPorts ignoring own port: %s\n", *p);
continue;
}
@@ -1713,7 +1721,7 @@ std::list<QString> JackAudioDevice::inputPorts(bool midi, int aliases)
strncpy(buffer, *p, nsz);
//if (strncmp(buffer, "MusE", 4) == 0)
//{
- // if(debugMsg)
+ // if(MusEGlobal::debugMsg)
// printf("JackAudioDevice::inputPorts ignoring own MusE port: %s\n", *p);
// continue;
//}
@@ -1721,7 +1729,7 @@ std::list<QString> JackAudioDevice::inputPorts(bool midi, int aliases)
// Ignore our own client ports.
if(jack_port_is_mine(_client, port))
{
- if(debugMsg)
+ if(MusEGlobal::debugMsg)
printf("JackAudioDevice::inputPorts ignoring own port: %s\n", *p);
continue;
}
@@ -1857,8 +1865,8 @@ void JackAudioDevice::setFreewheel(bool f)
bool JackAudioDevice::dummySync(int state)
{
// Roughly segment time length.
- //timespec ts = { 0, (1000000000 * segmentSize) / sampleRate }; // In nanoseconds.
- unsigned int sl = (1000000 * segmentSize) / sampleRate; // In microseconds.
+ //timespec ts = { 0, (1000000000 * MusEGlobal::segmentSize) / MusEGlobal::sampleRate }; // In nanoseconds.
+ unsigned int sl = (1000000 * MusEGlobal::segmentSize) / MusEGlobal::sampleRate; // In microseconds.
double ct = curTime();
// Wait for a default maximum of 5 seconds.
@@ -2072,7 +2080,7 @@ int JackAudioDevice::setMaster(bool f)
{
// Make Muse the Jack timebase master. Do it unconditionally (second param = 0).
r = jack_set_timebase_callback(_client, 0, (JackTimebaseCallback) timebase_callback, 0);
- if(debugMsg || JACK_DEBUG)
+ if(MusEGlobal::debugMsg || JACK_DEBUG)
{
if(r)
printf("JackAudioDevice::setMaster jack_set_timebase_callback failed: result:%d\n", r);
@@ -2087,7 +2095,7 @@ int JackAudioDevice::setMaster(bool f)
else
{
r = jack_release_timebase(_client);
- if(debugMsg || JACK_DEBUG)
+ if(MusEGlobal::debugMsg || JACK_DEBUG)
{
if(r)
printf("JackAudioDevice::setMaster jack_release_timebase failed: result:%d\n", r);
@@ -2102,7 +2110,7 @@ int JackAudioDevice::setMaster(bool f)
void JackAudioDevice::scanMidiPorts()
{
- if(debugMsg)
+ if(MusEGlobal::debugMsg)
printf("JackAudioDevice::scanMidiPorts:\n");
/*
@@ -2118,7 +2126,7 @@ void JackAudioDevice::scanMidiPorts()
// Ignore our own client ports.
if(jack_port_is_mine(_client, port))
{
- if(debugMsg)
+ if(MusEGlobal::debugMsg)
printf(" ignoring own port: %s\n", *p);
continue;
}
@@ -2130,7 +2138,7 @@ void JackAudioDevice::scanMidiPorts()
//if(strncmp(buffer, "MusE", 4) == 0)
// continue;
- if(debugMsg)
+ if(MusEGlobal::debugMsg)
printf(" found port: %s ", buffer);
// If there are aliases for this port, use the first one - much better for identifying.
@@ -2146,7 +2154,7 @@ void JackAudioDevice::scanMidiPorts()
//char* namep = (na >= 1) ? aliases[0] : buffer;
//char* namep = aliases[0];
//names.insert(std::string(*p));
- if(debugMsg)
+ if(MusEGlobal::debugMsg)
printf("alias: %s\n", aliases[0]);
names.insert(std::string(aliases[0]));
@@ -2166,7 +2174,7 @@ void JackAudioDevice::scanMidiPorts()
for(std::list<MidiDevice*>::iterator imd = to_del.begin(); imd != to_del.end(); ++imd)
{
- if(debugMsg)
+ if(MusEGlobal::debugMsg)
printf(" removing port device:%s\n", (*imd)->name().toLatin1());
midiDevices.remove(*imd);
// This will close (and unregister) the client port.
@@ -2227,7 +2235,7 @@ void JackAudioDevice::scanMidiPorts()
//JackPort jp(0, QString(buffer), flags);
//portList.append(jp);
- if(debugMsg)
+ if(MusEGlobal::debugMsg)
printf(" adding port device:%s\n", qname.toLatin1());
MidiJackDevice* dev = new MidiJackDevice(0, qname);
diff --git a/muse2/muse/driver/jackaudio.h b/muse2/muse/driver/jackaudio.h
index 2b045ac6..d116a2ff 100644
--- a/muse2/muse/driver/jackaudio.h
+++ b/muse2/muse/driver/jackaudio.h
@@ -28,10 +28,13 @@
class MidiPlayEvent;
+namespace MusEGlobal {
+bool checkAudioDevice();
+}
+
//---------------------------------------------------------
// JackAudioDevice
//---------------------------------------------------------
-bool checkAudioDevice();
class JackAudioDevice : public AudioDevice {
diff --git a/muse2/muse/driver/jackmidi.cpp b/muse2/muse/driver/jackmidi.cpp
index 8fc995bb..2e790a10 100644
--- a/muse2/muse/driver/jackmidi.cpp
+++ b/muse2/muse/driver/jackmidi.cpp
@@ -927,7 +927,7 @@ void MidiJackDevice::recordEvent(MidiRecordEvent& event)
if(audio->isPlaying())
event.setLoopNum(audio->loopCount());
- if (midiInputTrace) {
+ if (MusEGlobal::midiInputTrace) {
printf("Jack MidiInput: ");
event.dump();
}
@@ -979,11 +979,11 @@ void MidiJackDevice::recordEvent(MidiRecordEvent& event)
processMidiInputTransformPlugins(event);
- if (filterEvent(event, midiRecordType, false))
+ if (filterEvent(event, MusEGlobal::midiRecordType, false))
return;
if (!applyMidiInputTransformation(event)) {
- if (midiInputTrace)
+ if (MusEGlobal::midiInputTrace)
printf(" midi input transformation: event filtered\n");
return;
}
@@ -1026,7 +1026,7 @@ void MidiJackDevice::eventReceived(jack_midi_event_t* ev)
event.setB(0);
// NOTE: From MusE-2. Not done here in Muse-1 (yet).
- // move all events 2*segmentSize into the future to get
+ // move all events 2*MusEGlobal::segmentSize into the future to get
// jitterfree playback
//
// cycle n-1 n n+1
@@ -1036,7 +1036,7 @@ void MidiJackDevice::eventReceived(jack_midi_event_t* ev)
//
// const SeqTime* st = audio->seqTime();
- //unsigned curFrame = st->startFrame() + segmentSize;
+ //unsigned curFrame = st->startFrame() + MusEGlobal::segmentSize;
// unsigned curFrame = st->lastFrameTime;
//int frameOffset = audio->getFrameOffset();
unsigned pos = audio->pos().frame();
@@ -1076,7 +1076,7 @@ void MidiJackDevice::eventReceived(jack_midi_event_t* ev)
// For now, do not accept if the last byte is not EOX, meaning it's a chunk with more chunks to follow.
if(*(((unsigned char*)ev->buffer) + ev->size - 1) != ME_SYSEX_END)
{
- if(debugMsg)
+ if(MusEGlobal::debugMsg)
printf("MidiJackDevice::eventReceived sysex chunks not supported!\n");
return;
}
@@ -1108,7 +1108,7 @@ void MidiJackDevice::eventReceived(jack_midi_event_t* ev)
//break;
// return;
default:
- if(debugMsg)
+ if(MusEGlobal::debugMsg)
printf("MidiJackDevice::eventReceived unsupported system event 0x%02x\n", type);
return;
}
@@ -1116,13 +1116,13 @@ void MidiJackDevice::eventReceived(jack_midi_event_t* ev)
//return;
break;
default:
- if(debugMsg)
+ if(MusEGlobal::debugMsg)
printf("MidiJackDevice::eventReceived unknown event 0x%02x\n", type);
//printf("MidiJackDevice::eventReceived unknown event 0x%02x size:%d buf:0x%02x 0x%02x 0x%02x ...0x%02x\n", type, ev->size, *(ev->buffer), *(ev->buffer + 1), *(ev->buffer + 2), *(ev->buffer + (ev->size - 1)));
return;
}
- if (midiInputTrace) {
+ if (MusEGlobal::midiInputTrace) {
printf("MidiInput<%s>: ", name().toLatin1().constData());
event.dump();
}
@@ -1148,8 +1148,8 @@ void MidiJackDevice::collectMidiEvents()
if(!_in_client_jackport) // p3.3.55
return;
- //void* port_buf = jack_port_get_buffer(_client_jackport, segmentSize);
- void* port_buf = jack_port_get_buffer(_in_client_jackport, segmentSize); // p3.3.55
+ //void* port_buf = jack_port_get_buffer(_client_jackport, MusEGlobal::segmentSize);
+ void* port_buf = jack_port_get_buffer(_in_client_jackport, MusEGlobal::segmentSize); // p3.3.55
jack_midi_event_t event;
jack_nframes_t eventCount = jack_midi_get_event_count(port_buf);
@@ -1209,14 +1209,14 @@ bool MidiJackDevice::queueEvent(const MidiPlayEvent& e)
// e.dump();
// }
- //if(debugMsg)
+ //if(MusEGlobal::debugMsg)
// printf("MidiJackDevice::queueEvent\n");
//if(!_client_jackport)
if(!_out_client_jackport) // p3.3.55
return false;
- //void* pb = jack_port_get_buffer(_client_jackport, segmentSize);
- void* pb = jack_port_get_buffer(_out_client_jackport, segmentSize); // p3.3.55
+ //void* pb = jack_port_get_buffer(_client_jackport, MusEGlobal::segmentSize);
+ void* pb = jack_port_get_buffer(_out_client_jackport, MusEGlobal::segmentSize); // p3.3.55
//unsigned frameCounter = ->frameTime();
int frameOffset = audio->getFrameOffset();
@@ -1225,10 +1225,10 @@ bool MidiJackDevice::queueEvent(const MidiPlayEvent& e)
if (ft < 0)
ft = 0;
- if (ft >= (int)segmentSize) {
- printf("MidiJackDevice::queueEvent: Event time:%d out of range. offset:%d ft:%d (seg=%d)\n", e.time(), frameOffset, ft, segmentSize);
- if (ft > (int)segmentSize)
- ft = segmentSize - 1;
+ if (ft >= (int)MusEGlobal::segmentSize) {
+ printf("MidiJackDevice::queueEvent: Event time:%d out of range. offset:%d ft:%d (seg=%d)\n", e.time(), frameOffset, ft, MusEGlobal::segmentSize);
+ if (ft > (int)MusEGlobal::segmentSize)
+ ft = MusEGlobal::segmentSize - 1;
}
#ifdef JACK_MIDI_DEBUG
@@ -1308,7 +1308,7 @@ bool MidiJackDevice::queueEvent(const MidiPlayEvent& e)
case ME_START:
case ME_CONTINUE:
case ME_STOP:
- if(debugMsg)
+ if(MusEGlobal::debugMsg)
printf("MidiJackDevice::queueEvent: event type %x not supported\n", e.type());
//return false;
return true; // Absorb the event. Don't want it hanging around in the list. FIXME: Support these? p4.0.15 Tim.
@@ -1580,7 +1580,7 @@ bool MidiJackDevice::processEvent(const MidiPlayEvent& event)
}
else
{
- if(debugMsg)
+ if(MusEGlobal::debugMsg)
printf("MidiJackDevice::processEvent: unknown controller type 0x%x\n", a);
//return false; // Just ignore it.
}
@@ -1605,12 +1605,12 @@ void MidiJackDevice::processMidi()
//if(!_out_client_jackport) // p3.3.55
// return;
- //void* port_buf = jack_port_get_buffer(_client_jackport, segmentSize);
- //void* port_buf = jack_port_get_buffer(_out_client_jackport, segmentSize); // p3.3.55
+ //void* port_buf = jack_port_get_buffer(_client_jackport, MusEGlobal::segmentSize);
+ //void* port_buf = jack_port_get_buffer(_out_client_jackport, MusEGlobal::segmentSize); // p3.3.55
void* port_buf = 0;
if(_out_client_jackport && _writeEnable) // p4.0.15
{
- port_buf = jack_port_get_buffer(_out_client_jackport, segmentSize);
+ port_buf = jack_port_get_buffer(_out_client_jackport, MusEGlobal::segmentSize);
jack_midi_clear_buffer(port_buf);
}
diff --git a/muse2/muse/driver/rtctimer.cpp b/muse2/muse/driver/rtctimer.cpp
index b4b339ed..8410bb04 100644
--- a/muse2/muse/driver/rtctimer.cpp
+++ b/muse2/muse/driver/rtctimer.cpp
@@ -61,16 +61,16 @@ signed int RtcTimer::initTimer()
fprintf(stderr,"RtcTimer::initTimer(): called on initialised timer!\n");
return -1;
}
- doSetuid();
+ MusEGlobal::doSetuid();
timerFd = ::open("/dev/rtc", O_RDONLY);
if (timerFd == -1) {
fprintf(stderr, "fatal error: open /dev/rtc failed: %s\n", strerror(errno));
fprintf(stderr, "hint: check if 'rtc' kernel module is loaded, or used by something else\n");
- undoSetuid();
+ MusEGlobal::undoSetuid();
return timerFd;
}
- if (!setTimerFreq(config.rtcTicks)) {
+ if (!setTimerFreq(MusEConfig::config.rtcTicks)) {
// unable to set timer frequency
return -1;
}
@@ -133,7 +133,7 @@ bool RtcTimer::startTimer()
}
if (ioctl(timerFd, RTC_PIE_ON, 0) == -1) {
perror("MidiThread: start: RTC_PIE_ON failed");
- undoSetuid();
+ MusEGlobal::undoSetuid();
return false;
}
return true;