commit 555f53d622aa54171ea2992b995819225d46ee55
parent c4e9eff7225d11bc4f3ef2e525bb945f03015206
Author: fundamental <mark.d.mccurry@gmail.com>
Date: Mon, 25 Jul 2011 03:52:15 -0400
GUI: adding notification when NIO has difficulty
- When NIO does not bind to default Sound or MIDI backend, an alert is displayed
to the user
- Based on: sf.net/tracker/?func=detail&aid=1098881&group_id=62934&atid=502315
Diffstat:
5 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/src/Nio/EngineMgr.cpp b/src/Nio/EngineMgr.cpp
@@ -87,8 +87,9 @@ Engine *EngineMgr::getEng(string name)
return NULL;
}
-void EngineMgr::start()
+bool EngineMgr::start()
{
+ bool expected = true;
if(!(defaultOut&&defaultIn)) {
cerr << "ERROR: It looks like someone broke the Nio Output\n"
<< " Attempting to recover by defaulting to the\n"
@@ -107,6 +108,7 @@ void EngineMgr::start()
cout << "Audio Started" << endl;
}
else {
+ expected = false;
cerr << "ERROR: The default audio output failed to open!" << endl;
OutMgr::getInstance().currentOut = dynamic_cast<AudioOut *>(getEng("NULL"));
OutMgr::getInstance().currentOut->setAudioEn(true);
@@ -118,10 +120,14 @@ void EngineMgr::start()
cout << "MIDI Started" << endl;
}
else { //recover
+ expected = false;
cerr << "ERROR: The default MIDI input failed to open!" << endl;
InMgr::getInstance().current = dynamic_cast<MidiIn *>(getEng("NULL"));
InMgr::getInstance().current->setMidiEn(true);
}
+
+ //Show if expected drivers were booted
+ return expected;
}
void EngineMgr::stop()
diff --git a/src/Nio/EngineMgr.h b/src/Nio/EngineMgr.h
@@ -23,7 +23,7 @@ class EngineMgr
Engine *getEng(std::string name);
/**Start up defaults*/
- void start();
+ bool start();
/**Stop all engines*/
void stop();
diff --git a/src/Nio/Nio.cpp b/src/Nio/Nio.cpp
@@ -26,9 +26,9 @@ Nio::~Nio()
stop();
}
-void Nio::start()
+bool Nio::start()
{
- eng.start();//Drivers start your engines!
+ return eng.start();//Drivers start your engines!
}
void Nio::stop()
diff --git a/src/Nio/Nio.h b/src/Nio/Nio.h
@@ -12,7 +12,7 @@ class Nio
static Nio &getInstance();
~Nio();
- void start();
+ bool start();
void stop();
int setDefaultSource(std::string name);
diff --git a/src/main.cpp b/src/main.cpp
@@ -76,12 +76,14 @@ int Pexitprogram = 0; //if the UI set this to 1, the program will exit
/*
* User Interface thread
*/
-void *thread3(void *)
+void *thread3(void *v)
{
#ifndef DISABLE_GUI
#ifdef FLTK_GUI
+ if(v)
+ fl_alert("Default IO did not initialize.\nDefaulting to NULL backend.");
ui = new MasterUI(master, &Pexitprogram);
ui->showUI();
@@ -469,15 +471,15 @@ int main(int argc, char *argv[])
}
//Run the Nio system
- Nio::getInstance().start();
+ bool ioGood = Nio::getInstance().start();
+
#warning remove welcome message when system is out of beta
cout << "\nThanks for using the Nio system :)" << endl;
#ifndef DISABLE_GUI
- if(noui == 0) {
- pthread_create(&thr3, NULL, thread3, NULL);
- }
+ if(noui == 0)
+ pthread_create(&thr3, NULL, thread3, (void*)!ioGood);
#endif
// pthread_create(&thr4, NULL, thread4, NULL);