Browse Source

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
tags/1.9.9.5
sletz 13 years ago
parent
commit
9e3cb0b505
3 changed files with 9 additions and 6 deletions
  1. +1
    -2
      common/JackClient.cpp
  2. +7
    -3
      common/JackMessageBuffer.cpp
  3. +1
    -1
      common/JackMessageBuffer.h

+ 1
- 2
common/JackClient.cpp View File

@@ -993,8 +993,7 @@ int JackClient::SetInitCallback(JackThreadInitCallback callback, void *arg)
fInitArg = arg; fInitArg = arg;
fInit = callback; fInit = callback;
/* make sure that the message buffer thread is initialized too */ /* make sure that the message buffer thread is initialized too */
JackMessageBuffer::fInstance->SetInitCallback(callback, arg);
return 0;
return JackMessageBuffer::fInstance->SetInitCallback(callback, arg);
} }
} }




+ 7
- 3
common/JackMessageBuffer.cpp View File

@@ -44,10 +44,12 @@ JackMessageBuffer::~JackMessageBuffer()


bool JackMessageBuffer::Start() bool JackMessageBuffer::Start()
{ {
// Before StartSync()...
fRunning = true;
if (fThread.StartSync() == 0) { if (fThread.StartSync() == 0) {
fRunning = true;
return true; return true;
} else { } else {
fRunning = false;
return 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 */ /* set up the callback */
fInitArg = arg; fInitArg = arg;
fInit = callback; fInit = callback;
@@ -171,8 +173,10 @@ void JackMessageBuffer::SetInitCallback(JackThreadInitCallback callback, void *a
fGuard.Wait(); fGuard.Wait();
/* and we're done */ /* and we're done */
fGuard.Unlock(); fGuard.Unlock();
return 0;
} else { } else {
jack_error("JackMessageBuffer::SetInitCallback : callback cannot be executed"); jack_error("JackMessageBuffer::SetInitCallback : callback cannot be executed");
return -1;
} }
} }




+ 1
- 1
common/JackMessageBuffer.h View File

@@ -84,7 +84,7 @@ class JackMessageBuffer : public JackRunnableInterface
bool static Destroy(); bool static Destroy();


void AddMessage(int level, const char *message); void AddMessage(int level, const char *message);
void SetInitCallback(JackThreadInitCallback callback, void *arg);
int SetInitCallback(JackThreadInitCallback callback, void *arg);


static JackMessageBuffer* fInstance; static JackMessageBuffer* fInstance;
}; };


Loading…
Cancel
Save