Commit 2e96fbf1 authored by sletz's avatar sletz
Browse files

In JackCoreAudioDriver, move code called in MeasureCallback to be called once in IO thread.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4018 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 3de1ee6e
......@@ -29,6 +29,10 @@ Arnold Krille
---------------------------
Jackdmp changes log
---------------------------
2010-05-27 Stephane Letz <letz@grame.fr>
* In JackCoreAudioDriver, move code called in MeasureCallback to be called once in IO thread.
2010-05-07 Stephane Letz <letz@grame.fr>
......
......@@ -27,17 +27,15 @@
using namespace Jack;
void change_thread_log_function(jack_log_function_t log_function)
static bool change_thread_log_function(jack_log_function_t log_function)
{
if (!jack_tls_set(JackGlobals::fKeyLogFunction, (void*)log_function))
{
jack_error("failed to set thread log function");
}
return (jack_tls_get(JackGlobals::fKeyLogFunction) == NULL
&& jack_tls_set(JackGlobals::fKeyLogFunction, (void*)log_function));
}
SERVER_EXPORT void set_threaded_log_function()
SERVER_EXPORT bool set_threaded_log_function()
{
change_thread_log_function(JackMessageBufferAdd);
return change_thread_log_function(JackMessageBufferAdd);
}
void jack_log_function(int level, const char *message)
......
......@@ -53,10 +53,9 @@ extern "C"
typedef void (* jack_log_function_t)(int level, const char *message);
void change_thread_log_function(jack_log_function_t log_function);
void jack_log_function(int level, const char *message);
SERVER_EXPORT void set_threaded_log_function();
SERVER_EXPORT bool set_threaded_log_function();
#ifdef __cplusplus
}
......
......@@ -194,6 +194,22 @@ OSStatus JackCoreAudioDriver::Render(void *inRefCon,
driver->fActionFags = ioActionFlags;
driver->fCurrentTime = (AudioTimeStamp *)inTimeStamp;
driver->fDriverOutputData = ioData;
// Setup threadded based log function once...
if (set_threaded_log_function()) {
jack_log("set_threaded_log_function");
JackMachThread::GetParams(pthread_self(), &driver->fEngineControl->fPeriod, &driver->fEngineControl->fComputation, &driver->fEngineControl->fConstraint);
if (driver->fComputationGrain > 0) {
jack_log("JackCoreAudioDriver::Render : RT thread computation setup to %d percent of period", int(driver->fComputationGrain * 100));
driver->fEngineControl->fComputation = driver->fEngineControl->fPeriod * driver->fComputationGrain;
}
// Signal waiting start function...
driver->fState = true;
}
driver->CycleTakeBeginTime();
return driver->Process();
}
......@@ -221,33 +237,6 @@ int JackCoreAudioDriver::Write()
return 0;
}
// Will run only once
OSStatus JackCoreAudioDriver::MeasureCallback(AudioDeviceID inDevice,
const AudioTimeStamp* inNow,
const AudioBufferList* inInputData,
const AudioTimeStamp* inInputTime,
AudioBufferList* outOutputData,
const AudioTimeStamp* inOutputTime,
void* inClientData)
{
JackCoreAudioDriver* driver = (JackCoreAudioDriver*)inClientData;
AudioDeviceStop(driver->fDeviceID, MeasureCallback);
jack_log("JackCoreAudioDriver::MeasureCallback called");
JackMachThread::GetParams(pthread_self(), &driver->fEngineControl->fPeriod, &driver->fEngineControl->fComputation, &driver->fEngineControl->fConstraint);
if (driver->fComputationGrain > 0) {
jack_log("JackCoreAudioDriver::MeasureCallback : RT thread computation setup to %d percent of period", int(driver->fComputationGrain * 100));
driver->fEngineControl->fComputation = driver->fEngineControl->fPeriod * driver->fComputationGrain;
}
// Signal waiting start function...
driver->fState = true;
// Setup threadded based log function
set_threaded_log_function();
return noErr;
}
OSStatus JackCoreAudioDriver::SRNotificationCallback(AudioDeviceID inDevice,
UInt32 inChannel,
......@@ -1682,27 +1671,10 @@ int JackCoreAudioDriver::Start()
{
jack_log("JackCoreAudioDriver::Start");
JackAudioDriver::Start();
/*
#ifdef MAC_OS_X_VERSION_10_5
OSStatus err = AudioDeviceCreateIOProcID(fDeviceID, MeasureCallback, this, &fMesureCallbackID);
#else
OSStatus err = AudioDeviceAddIOProc(fDeviceID, MeasureCallback, this);
#endif
*/
OSStatus err = AudioDeviceAddIOProc(fDeviceID, MeasureCallback, this);
if (err != noErr)
return -1;
err = AudioOutputUnitStart(fAUHAL);
OSStatus err = AudioOutputUnitStart(fAUHAL);
if (err != noErr)
return -1;
if ((err = AudioDeviceStart(fDeviceID, MeasureCallback)) != noErr) {
jack_error("Cannot start MeasureCallback");
printError(err);
return -1;
}
// Waiting for Measure callback to be called (= driver has started)
fState = false;
......@@ -1724,15 +1696,6 @@ int JackCoreAudioDriver::Start()
int JackCoreAudioDriver::Stop()
{
jack_log("JackCoreAudioDriver::Stop");
AudioDeviceStop(fDeviceID, MeasureCallback);
/*
#ifdef MAC_OS_X_VERSION_10_5
AudioDeviceDestroyIOProcID(fDeviceID, fMesureCallbackID);
#else
AudioDeviceRemoveIOProc(fDeviceID, MeasureCallback);
#endif
*/
AudioDeviceRemoveIOProc(fDeviceID, MeasureCallback);
return (AudioOutputUnitStop(fAUHAL) == noErr) ? 0 : -1;
}
......
......@@ -96,14 +96,6 @@ class JackCoreAudioDriver : public JackAudioDriver
UInt32 inNumberFrames,
AudioBufferList *ioData);
static OSStatus MeasureCallback(AudioDeviceID inDevice,
const AudioTimeStamp* inNow,
const AudioBufferList* inInputData,
const AudioTimeStamp* inInputTime,
AudioBufferList* outOutputData,
const AudioTimeStamp* inOutputTime,
void* inClientData);
static OSStatus DeviceNotificationCallback(AudioDeviceID inDevice,
UInt32 inChannel,
Boolean isInput,
......
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