Commit 9e3cb0b5 authored by sletz's avatar sletz
Browse files

More robust jack_set_thread_init_callback implementation.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4753 0c269be4-1314-0410-8aa9-9f06e86f4224
parent e6a75437
......@@ -993,8 +993,7 @@ int JackClient::SetInitCallback(JackThreadInitCallback callback, void *arg)
fInitArg = arg;
fInit = callback;
/* make sure that the message buffer thread is initialized too */
JackMessageBuffer::fInstance->SetInitCallback(callback, arg);
return 0;
return JackMessageBuffer::fInstance->SetInitCallback(callback, arg);
}
}
......
......@@ -44,10 +44,12 @@ JackMessageBuffer::~JackMessageBuffer()
bool JackMessageBuffer::Start()
{
// Before StartSync()...
fRunning = true;
if (fThread.StartSync() == 0) {
fRunning = true;
return true;
} else {
fRunning = false;
return false;
}
}
......@@ -159,9 +161,9 @@ void JackMessageBufferAdd(int level, const char *message)
}
}
void JackMessageBuffer::SetInitCallback(JackThreadInitCallback callback, void *arg)
int JackMessageBuffer::SetInitCallback(JackThreadInitCallback callback, void *arg)
{
if (fInstance && fInit && fRunning && fGuard.Lock()) {
if (fInstance && callback && fRunning && fGuard.Lock()) {
/* set up the callback */
fInitArg = arg;
fInit = callback;
......@@ -171,8 +173,10 @@ void JackMessageBuffer::SetInitCallback(JackThreadInitCallback callback, void *a
fGuard.Wait();
/* and we're done */
fGuard.Unlock();
return 0;
} else {
jack_error("JackMessageBuffer::SetInitCallback : callback cannot be executed");
return -1;
}
}
......
......@@ -84,7 +84,7 @@ class JackMessageBuffer : public JackRunnableInterface
bool static Destroy();
void AddMessage(int level, const char *message);
void SetInitCallback(JackThreadInitCallback callback, void *arg);
int SetInitCallback(JackThreadInitCallback callback, void *arg);
static JackMessageBuffer* fInstance;
};
......
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