Commit c02981ed authored by sletz's avatar sletz
Browse files

Ensure that client-side message buffer thread calls thread_init callback...

Ensure that client-side message buffer thread calls thread_init callback if/when it is set by the client (backport of JACK1 rev 3838).

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3839 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 74b7dd42
......@@ -30,6 +30,7 @@ Devin Anderson
2009-12-02 Stephane Letz <letz@grame.fr>
* Special code in JackCoreAudio driver to handle completely buggy Digidesign CoreAudio user-land driver.
* Ensure that client-side message buffer thread calls thread_init callback if/when it is set by the client (backport of JACK1 rev 3838).
2009-12-01 Stephane Letz <letz@grame.fr>
......
......@@ -848,6 +848,8 @@ int JackClient::SetInitCallback(JackThreadInitCallback callback, void *arg)
} else {
fInitArg = arg;
fInit = callback;
/* make sure that the message buffer thread is initialized too */
JackMessageBuffer::fInstance->SetInitCallback(callback, arg);
return 0;
}
}
......
......@@ -29,7 +29,7 @@ namespace Jack
JackMessageBuffer* JackMessageBuffer::fInstance = NULL;
JackMessageBuffer::JackMessageBuffer()
:fThread(this),fInBuffer(0),fOutBuffer(0),fOverruns(0),fRunning(false)
:fInit(NULL),fInitArg(NULL),fThread(this),fInBuffer(0),fOutBuffer(0),fOverruns(0),fRunning(false)
{}
JackMessageBuffer::~JackMessageBuffer()
......@@ -82,6 +82,15 @@ bool JackMessageBuffer::Execute()
while (fRunning) {
fGuard.Lock();
fGuard.Wait();
/* the client asked for all threads to run a thread
initialization callback, which includes us.
*/
if (fInit) {
fInit(fInitArg);
fInit = NULL;
/* and we're done */
fGuard.Signal();
}
Flush();
fGuard.Unlock();
}
......@@ -115,5 +124,20 @@ void JackMessageBufferAdd(int level, const char *message)
}
}
void JackMessageBuffer::SetInitCallback(JackThreadInitCallback callback, void *arg)
{
fGuard.Lock();
/* set up the callback */
fInitArg = arg;
fInit = callback;
/* wake msg buffer thread */
fGuard.Signal();
/* wait for it to be done */
fGuard.Wait();
/* and we're done */
fGuard.Unlock();
}
};
......@@ -57,6 +57,8 @@ class JackMessageBuffer : public JackRunnableInterface
private:
JackThreadInitCallback fInit;
void* fInitArg;
JackMessage fBuffers[MB_BUFFERS];
JackThread fThread;
JackProcessSync fGuard;
......@@ -82,6 +84,7 @@ class JackMessageBuffer : public JackRunnableInterface
void static Destroy();
void AddMessage(int level, const char *message);
void 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