diff options
-rw-r--r-- | muse/muse/audioinput.cpp | 4 | ||||
-rw-r--r-- | muse/muse/driver/audiodev.h | 1 | ||||
-rw-r--r-- | muse/muse/driver/jack.cpp | 55 | ||||
-rw-r--r-- | muse/muse/driver/jackaudio.h | 1 | ||||
-rw-r--r-- | muse/muse/song.cpp | 14 | ||||
-rw-r--r-- | muse/synti/mus/mus.cpp | 2 |
6 files changed, 43 insertions, 34 deletions
diff --git a/muse/muse/audioinput.cpp b/muse/muse/audioinput.cpp index 6fe50c12..8fb25947 100644 --- a/muse/muse/audioinput.cpp +++ b/muse/muse/audioinput.cpp @@ -97,10 +97,10 @@ void AudioInput::activate1() for (int i = 0; i < channels(); ++i) { char buffer[128]; snprintf(buffer, 128, "%s-%d", _name.toAscii().data(), i); + // following happens on reconnect to JACK server: if (jackPorts[i]) printf("AudioInput::activate(): already active!\n"); - else - jackPorts[i] = audioDriver->registerInPort(buffer, false); + jackPorts[i] = audioDriver->registerInPort(buffer, false); } } diff --git a/muse/muse/driver/audiodev.h b/muse/muse/driver/audiodev.h index d83e5dd0..e25ddced 100644 --- a/muse/muse/driver/audiodev.h +++ b/muse/muse/driver/audiodev.h @@ -34,6 +34,7 @@ class AudioDriver : public Driver { virtual ~AudioDriver() {} virtual void start(int priority) = 0; + virtual void restart() {} 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 7a2168b4..08e2a494 100644 --- a/muse/muse/driver/jack.cpp +++ b/muse/muse/driver/jack.cpp @@ -138,9 +138,6 @@ static void processShutdown(void*) if (audioState == AUDIO_RUNNING) fprintf(stderr, "MusE: sequencer still running, something is very wrong.\n"); jackAudio->zeroClientPtr(); // jack disconnect client no longer valid -// delete jackAudio; -// jackAudio = 0; -// audioDriver = 0; } //--------------------------------------------------------- @@ -223,23 +220,29 @@ bool initJackAudio() if (debugMsg) fprintf(stderr, "init Jack Audio: register device\n"); - if (client) { - 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); - } - if (client) { - audioDriver = jackAudio; - return false; - } - return true; + 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() + { + _client = jack_client_new(jackRegisteredName); + registerClient(); } //--------------------------------------------------------- @@ -603,10 +606,10 @@ void JackAudio::start(int) void JackAudio::stop() { - if (jack_deactivate(_client)) { - fprintf (stderr, "JACK: cannot deactivate client"); - } - //printf("JackAudio::stop() %p\n", _client); + if (_client == 0) + return; + if (jack_deactivate(_client)) + fprintf (stderr, "JACK: cannot deactivate client\n"); } //--------------------------------------------------------- @@ -615,8 +618,7 @@ void JackAudio::stop() unsigned JackAudio::framePos() const { - jack_nframes_t n = jack_frame_time(_client); - return n; + return _client ? jack_frame_time(_client) : 0; } //--------------------------------------------------------- @@ -730,7 +732,8 @@ void JackAudio::startTransport() void JackAudio::stopTransport() { // printf("JACK: stopTransport\n"); - jack_transport_stop(_client); + if (_client) + jack_transport_stop(_client); } //--------------------------------------------------------- diff --git a/muse/muse/driver/jackaudio.h b/muse/muse/driver/jackaudio.h index 9a0a4b8b..204fb9cf 100644 --- a/muse/muse/driver/jackaudio.h +++ b/muse/muse/driver/jackaudio.h @@ -39,6 +39,7 @@ class JackAudio : public AudioDriver { virtual ~JackAudio(); virtual bool init(); virtual void start(int); + virtual void restart(); virtual void stop (); virtual void zeroClientPtr() { _client = 0; } virtual unsigned framePos() const; diff --git a/muse/muse/song.cpp b/muse/muse/song.cpp index 44c58bc7..f277ac49 100644 --- a/muse/muse/song.cpp +++ b/muse/muse/song.cpp @@ -454,10 +454,10 @@ void Song::setPlay(bool f) void Song::setStop(bool f) { // only allow the user to set the button "on" - if (!f) - muse->stopAction->setChecked(true); - else + if (f) audio->msgPlay(false); + else + muse->stopAction->setChecked(true); } //--------------------------------------------------------- @@ -1241,6 +1241,7 @@ void Song::seqSignal(int fd) 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" @@ -1259,8 +1260,11 @@ void Song::seqSignal(int fd) "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"); - muse->seqRestart(); +printf("restarting!\n"); + audioDriver->restart(); + if (!muse->seqStart()) + return; + audioDriver->graphChanged(); } } break; diff --git a/muse/synti/mus/mus.cpp b/muse/synti/mus/mus.cpp index 062fd69c..fbc59334 100644 --- a/muse/synti/mus/mus.cpp +++ b/muse/synti/mus/mus.cpp @@ -195,7 +195,7 @@ int main(int argc, char* argv[]) QString instanceName; QString s(pluginName.left(pluginName.size()-3)); s += "-%1"; - static const int MAX_INSTANCES = 500; + static const int MAX_INSTANCES = 100; for (i = 0; i < MAX_INSTANCES; ++i) { instanceName = s.arg(i); const char* jackIdString = strdup(instanceName.toLocal8Bit().data()); |