Browse Source

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
tags/v1.9.6
sletz 15 years ago
parent
commit
2e96fbf11c
5 changed files with 27 additions and 71 deletions
  1. +4
    -0
      ChangeLog
  2. +5
    -7
      common/JackError.cpp
  3. +1
    -2
      common/JackError.h
  4. +17
    -54
      macosx/coreaudio/JackCoreAudioDriver.cpp
  5. +0
    -8
      macosx/coreaudio/JackCoreAudioDriver.h

+ 4
- 0
ChangeLog View File

@@ -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>


+ 5
- 7
common/JackError.cpp View File

@@ -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)


+ 1
- 2
common/JackError.h View File

@@ -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
}


+ 17
- 54
macosx/coreaudio/JackCoreAudioDriver.cpp View File

@@ -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;
}



+ 0
- 8
macosx/coreaudio/JackCoreAudioDriver.h View File

@@ -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,


Loading…
Cancel
Save