summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Schweer <ws.seh.de>2006-10-20 11:37:53 +0000
committerWerner Schweer <ws.seh.de>2006-10-20 11:37:53 +0000
commit6c07d4bd4c8d473746ee8da4d010b5b40987e9b8 (patch)
treec1301b78fae52bab82e190f45c4ddd498661d838
parent0a957162d7fa2c062a32755b2a729e0e3158dd05 (diff)
jack auto start
-rw-r--r--muse/ChangeLog3
-rw-r--r--muse/muse/driver/audiodev.h2
-rw-r--r--muse/muse/driver/jack.cpp101
-rw-r--r--muse/muse/driver/jackaudio.h2
-rw-r--r--muse/muse/muse.h2
-rw-r--r--muse/muse/song.cpp70
-rw-r--r--muse/muse/song.h1
7 files changed, 104 insertions, 77 deletions
diff --git a/muse/ChangeLog b/muse/ChangeLog
index 4d53eb2f..b3b4fba2 100644
--- a/muse/ChangeLog
+++ b/muse/ChangeLog
@@ -1,3 +1,6 @@
+20.10 (ws)
+ - add first support for jack midi
+ - jack autostart
18.10 (ws)
- added routing for jack midi ports. Fixes for "mus".
17.10 (ws)
diff --git a/muse/muse/driver/audiodev.h b/muse/muse/driver/audiodev.h
index e25ddced..416f91c0 100644
--- a/muse/muse/driver/audiodev.h
+++ b/muse/muse/driver/audiodev.h
@@ -34,7 +34,7 @@ class AudioDriver : public Driver {
virtual ~AudioDriver() {}
virtual void start(int priority) = 0;
- virtual void restart() {}
+ virtual bool restart() { return false; } // return true on error
virtual void stop () = 0;
virtual unsigned framePos() const = 0;
virtual float* getBuffer(void* port, unsigned long nframes) = 0;
diff --git a/muse/muse/driver/jack.cpp b/muse/muse/driver/jack.cpp
index 08e2a494..aa970336 100644
--- a/muse/muse/driver/jack.cpp
+++ b/muse/muse/driver/jack.cpp
@@ -192,57 +192,16 @@ char* JackAudio::getJackName()
}
//---------------------------------------------------------
-// initJackAudio
-// return true if JACK not found
-//---------------------------------------------------------
-
-bool initJackAudio()
- {
- if (debugMsg) {
- fprintf(stderr, "init Jack Audio\n");
- jack_set_error_function(jackError);
- }
- else
- jack_set_error_function(noJackError);
-
- jack_client_t* client = 0;
- int i = 0;
- char jackIdString[8];
- for (i = 0; i < 5; ++i) {
- sprintf(jackIdString, "MusE-%d", i+1);
- client = jack_client_new(jackIdString);
- if (client)
- break;
- }
-
- if (i == 5)
- return true;
-
- if (debugMsg)
- fprintf(stderr, "init Jack Audio: register device\n");
-
- jack_set_error_function(jackError);
- if (debugMsg)
- fprintf(stderr, "init Jack Audio: register device\n");
-
- jackAudio = new JackAudio(client, jackIdString);
- if (debugMsg)
- fprintf(stderr, "init Jack Audio: register client\n");
- jackAudio->registerClient();
- AL::sampleRate = jack_get_sample_rate(client);
- segmentSize = jack_get_buffer_size(client);
- audioDriver = jackAudio;
- return false;
- }
-
-//---------------------------------------------------------
// restart
//---------------------------------------------------------
-void JackAudio::restart()
+bool JackAudio::restart()
{
_client = jack_client_new(jackRegisteredName);
+ if (!_client)
+ return true;
registerClient();
+ return false;
}
//---------------------------------------------------------
@@ -685,7 +644,8 @@ QString JackAudio::portName(void* port)
void JackAudio::unregisterPort(Port p)
{
//printf("JACK: unregister Port %p\n", p);
- jack_port_unregister(_client, (jack_port_t*)p);
+ if (_client)
+ jack_port_unregister(_client, (jack_port_t*)p);
}
//---------------------------------------------------------
@@ -782,3 +742,52 @@ int JackAudio::realtimePriority() const
return param.sched_priority;
}
+//---------------------------------------------------------
+// initJackAudio
+// return true if JACK not found
+//---------------------------------------------------------
+
+bool initJackAudio()
+ {
+ if (debugMsg) {
+ fprintf(stderr, "init Jack Audio\n");
+ jack_set_error_function(jackError);
+ }
+ else
+ jack_set_error_function(noJackError);
+
+ jack_client_t* client = 0;
+ jack_status_t status;
+ jack_options_t options = JackNullOption;
+ client = jack_client_open("MusE", options, &status);
+ if (!client) {
+ if (status & JackServerStarted)
+ printf("jack server started...\n");
+ if (status & JackServerFailed)
+ printf("cannot connect to jack server\n");
+ if (status & JackServerError)
+ printf("communication with jack server failed\n");
+ if (status & JackShmFailure)
+ printf("jack cannot access shared memory\n");
+ if (status & JackVersionError)
+ printf("jack server has wrong version\n");
+ return true;
+ }
+
+ if (debugMsg)
+ fprintf(stderr, "init Jack Audio: register device\n");
+
+ jack_set_error_function(jackError);
+ if (debugMsg)
+ fprintf(stderr, "init Jack Audio: register device\n");
+
+ jackAudio = new JackAudio(client, jack_get_client_name(client));
+ if (debugMsg)
+ fprintf(stderr, "init Jack Audio: register client\n");
+ jackAudio->registerClient();
+ AL::sampleRate = jack_get_sample_rate(client);
+ segmentSize = jack_get_buffer_size(client);
+ audioDriver = jackAudio;
+ return false;
+ }
+
diff --git a/muse/muse/driver/jackaudio.h b/muse/muse/driver/jackaudio.h
index 204fb9cf..4b76cb80 100644
--- a/muse/muse/driver/jackaudio.h
+++ b/muse/muse/driver/jackaudio.h
@@ -39,7 +39,7 @@ class JackAudio : public AudioDriver {
virtual ~JackAudio();
virtual bool init();
virtual void start(int);
- virtual void restart();
+ virtual bool restart();
virtual void stop ();
virtual void zeroClientPtr() { _client = 0; }
virtual unsigned framePos() const;
diff --git a/muse/muse/muse.h b/muse/muse/muse.h
index cf8349e6..ee347719 100644
--- a/muse/muse/muse.h
+++ b/muse/muse/muse.h
@@ -181,7 +181,6 @@ class MusE : public QMainWindow // , public Ui::MuseBase
private slots:
void loadProject();
- bool save();
void quitDoc();
void about();
void aboutQt();
@@ -271,6 +270,7 @@ class MusE : public QMainWindow // , public Ui::MuseBase
void setGlobalTempo(int val);
void setTool(int);
void startEditor(Part*, int);
+ bool save();
public:
MusE();
diff --git a/muse/muse/song.cpp b/muse/muse/song.cpp
index f277ac49..628ad661 100644
--- a/muse/muse/song.cpp
+++ b/muse/muse/song.cpp
@@ -1239,35 +1239,9 @@ void Song::seqSignal(int fd)
beat(); // update controller guis
break;
case MSG_JACK_SHUTDOWN:
- {
- muse->seqStop();
-
- // give the user a sensible explanation
- int btn = QMessageBox::critical( muse, tr("Jack shutdown!"),
- tr("Jack has detected a performance problem which has lead to\n"
- "MusE being disconnected.\n"
- "This could happen due to a number of reasons:\n"
- "- a performance issue with your particular setup.\n"
- "- a bug in MusE (or possibly in another connected software).\n"
- "- a random hiccup which might never occur again.\n"
- "- jack was voluntary stopped by you or someone else\n"
- "- jack crashed\n"
- "If there is a persisting problem you are much welcome to discuss it\n"
- "on the MusE mailinglist.\n"
- "(there is information about joining the mailinglist on the MusE\n"
- " homepage which is available through the help menu)\n"
- "\n"
- "To proceed check the status of Jack and try to restart it and then .\n"
- "click on the Restart button."), "restart", "cancel");
- if (btn == 0) {
-printf("restarting!\n");
- audioDriver->restart();
- if (!muse->seqStart())
- return;
- audioDriver->graphChanged();
- }
- }
+ restartJack();
break;
+
case MSG_START_BOUNCE:
{
bool useFreewheel = config.useJackFreewheelMode;
@@ -2469,3 +2443,43 @@ void Song::read20(QDomNode node)
}
}
+//---------------------------------------------------------
+// restartJack
+//---------------------------------------------------------
+
+void Song::restartJack()
+ {
+ muse->seqStop();
+ audioState = AUDIO_STOP;
+ for (;;) {
+ // give the user a sensible explanation
+ int btn = QMessageBox::critical( muse, tr("Jack shutdown!"),
+ tr("Jack has detected a performance problem which has lead to\n"
+ "MusE being disconnected.\n"
+ "This could happen due to a number of reasons:\n"
+ "- a performance issue with your particular setup.\n"
+ "- a bug in MusE (or possibly in another connected software).\n"
+ "- a random hiccup which might never occur again.\n"
+ "- jack was voluntary stopped by you or someone else\n"
+ "- jack crashed\n"
+ "If there is a persisting problem you are much welcome to discuss it\n"
+ "on the MusE mailinglist.\n"
+ "(there is information about joining the mailinglist on the MusE\n"
+ " homepage which is available through the help menu)\n"
+ "\n"
+ "To proceed check the status of Jack and try to restart it and then .\n"
+ "click on the Restart button."),
+ "restart", "cancel", "save project"
+ );
+ if (btn == 0) {
+ if (!audioDriver->restart())
+ break;
+ }
+ else if (btn == 2)
+ muse->save();
+ else if (btn == 1)
+ exit(-1);
+ }
+ muse->seqRestart();
+ }
+
diff --git a/muse/muse/song.h b/muse/muse/song.h
index 33df68c5..3535b06c 100644
--- a/muse/muse/song.h
+++ b/muse/muse/song.h
@@ -130,6 +130,7 @@ class Song : public QObject {
unsigned _len; // song len in ticks
int _globalPitchShift;
void readMarker(QDomNode);
+ void restartJack();
public slots:
void beat();