Commit ae57b1d0 authored by sletz's avatar sletz
Browse files

CoreAudio backend now issue a JackInfoShutdownCallback when an unrecoverable...

CoreAudio backend now issue a JackInfoShutdownCallback when an unrecoverable error is detected (sampling rate change, stream configuration change…)

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3654 0c269be4-1314-0410-8aa9-9f06e86f4224
parent d09d8c3c
......@@ -27,7 +27,8 @@ Paul Davis
2009-10-20 Stephane Letz <letz@grame.fr>
* Add a string parameter to server ==> client notification, add a new "InfoShutdown" callback.
* Add a string parameter to server ==> client notification, add a new JackInfoShutdownCallback type.
* CoreAudio backend now issue a JackInfoShutdownCallback when an unrecoverable error is detected (sampling rate change, stream configuration change)
2009-10-17 Stephane Letz <letz@grame.fr>
......
......@@ -252,8 +252,10 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync,
case kShutDownCallback:
jack_log("JackClient::kShutDownCallback");
if (fInfoShutdown)
fInfoShutdown(message, fInfoShutdownArg);
if (fInfoShutdown) {
fInfoShutdown(value1, message, fInfoShutdownArg);
fInfoShutdown = NULL;
}
break;
}
}
......@@ -591,7 +593,7 @@ void JackClient::ShutDown()
JackGlobals::fServerRunning = false;
if (fInfoShutdown) {
fInfoShutdown("JACK server has been closed", fInfoShutdownArg);
fInfoShutdown(JackFailure, "JACK server has been closed", fInfoShutdownArg);
fInfoShutdown = NULL;
} else if (fShutdown) {
fShutdown(fShutdownArg);
......@@ -789,6 +791,7 @@ void JackClient::OnInfoShutdown(JackInfoShutdownCallback callback, void *arg)
if (IsActive()) {
jack_error("You cannot set callbacks on an active client");
} else {
GetClientControl()->fCallback[kShutDownCallback] = (callback != NULL);
fInfoShutdownArg = arg;
fInfoShutdown = callback;
}
......
......@@ -250,6 +250,11 @@ void JackDriver::NotifySampleRate(jack_nframes_t sample_rate)
fEngine->NotifySampleRate(sample_rate);
fEngineControl->InitFrameTime();
}
void JackDriver::NotifyFailure(int code, const char* reason)
{
fEngine->NotifyFailure(code, reason);
}
void JackDriver::SetMaster(bool onoff)
{
......
......@@ -140,6 +140,7 @@ class SERVER_EXPORT JackDriver : public JackDriverClientInterface
void NotifyXRun(jack_time_t callback_usecs, float delayed_usecs); // XRun notification sent by the driver
void NotifyBufferSize(jack_nframes_t buffer_size); // BufferSize notification sent by the driver
void NotifySampleRate(jack_nframes_t sample_rate); // SampleRate notification sent by the driver
void NotifyFailure(int code, const char* reason); // Failure notification sent by the driver
public:
......
......@@ -298,6 +298,11 @@ void JackEngine::NotifySampleRate(jack_nframes_t sample_rate)
NotifyClients(kSampleRateCallback, true, "", sample_rate, 0);
}
void JackEngine::NotifyFailure(int code, const char* reason)
{
NotifyClients(kShutDownCallback, false, reason, code, 0);
}
void JackEngine::NotifyFreewheel(bool onoff)
{
fEngineControl->fRealTime = !onoff;
......
......@@ -116,6 +116,7 @@ class SERVER_EXPORT JackEngine
// Notifications
void NotifyXRun(jack_time_t callback_usecs, float delayed_usecs);
void NotifyFailure(int code, const char* reason);
void NotifyXRun(int refnum);
void NotifyGraphReorder();
void NotifyBufferSize(jack_nframes_t buffer_size);
......
......@@ -191,6 +191,12 @@ class SERVER_EXPORT JackLockedEngine : public JackLockAble
fEngine.NotifyFreewheel(onoff);
}
void NotifyFailure(int code, const char* reason)
{
JackLock lock(this);
fEngine.NotifyFailure(code, reason);
}
int GetClientPID(const char* name)
{
JackLock lock(this);
......
......@@ -234,12 +234,12 @@ typedef void (*JackShutdownCallback)(void *arg);
* to release client ressources. Warning: jack_client_close() cannot be
* safely used inside the shutdown callback and has to be called outside of
* the callback context.
*
* @param reason a string discribinh the shuntdown reason (backend failure, server crash... etc...)
* @param code a shuntdown code
* @param reason a string discribing the shuntdown reason (backend failure, server crash... etc...)
* @param arg pointer to a client supplied structure
*/
typedef void (*JackInfoShutdownCallback)(const char* reason, void *arg);
typedef void (*JackInfoShutdownCallback)(int code, const char* reason, void *arg);
/**
* Used for the type argument of jack_port_register() for default
......@@ -434,7 +434,12 @@ enum JackStatus {
/**
* Client's protocol version does not match
*/
JackVersionError = 0x400
JackVersionError = 0x400,
/**
* Backend failure
*/
JackBackendError = 0x800
};
/**
......
......@@ -25,6 +25,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "JackClientControl.h"
#include "JackDriverLoader.h"
#include "JackGlobals.h"
#include "JackTools.h"
#include "JackCompilerDeps.h"
#include <iostream>
......@@ -270,12 +271,16 @@ OSStatus JackCoreAudioDriver::DeviceNotificationCallback(AudioDeviceID inDevice,
}
case kAudioDevicePropertyStreamConfiguration: {
jack_error("Cannot handle kAudioDevicePropertyStreamConfiguration : server may not work correctly anymore...");
jack_error("Cannot handle kAudioDevicePropertyStreamConfiguration : server will quit...");
driver->NotifyFailure(JackBackendError, "CoreAudio device stream configuration has changed, backend stopped.");
kill(JackTools::GetPID(), SIGINT);
return kAudioHardwareUnsupportedOperationError;
}
case kAudioDevicePropertyNominalSampleRate: {
jack_error("Cannot handle kAudioDevicePropertyNominalSampleRate : server may not work correctly anymore...");
jack_error("Cannot handle kAudioDevicePropertyNominalSampleRate : server will quit...");
driver->NotifyFailure(JackBackendError, "CoreAudio device sampling rate has changed, backend stopped.");
kill(JackTools::GetPID(), SIGINT);
return kAudioHardwareUnsupportedOperationError;
}
......
......@@ -220,6 +220,12 @@ void jack_shutdown(void *arg)
exit(1);
}
void jack_info_shutdown(int code, const char* reason, void *arg)
{
printf("JACK server failure : %s\n", reason);
exit(1);
}
void Jack_Port_Register(jack_port_id_t port, int mode, void *arg)
{
port_callback_reg++;
......@@ -679,6 +685,7 @@ int main (int argc, char *argv[])
}
jack_on_shutdown(client1, jack_shutdown, 0);
jack_on_info_shutdown(client1, jack_info_shutdown, 0);
if (jack_set_buffer_size_callback(client1, Jack_Update_Buffer_Size, 0) != 0) {
printf("Error when calling buffer_size_callback !\n");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment