Browse Source

Add a sample_rate change listener in CoreAudio driver.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1721 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.69
sletz 18 years ago
parent
commit
caee59aed3
2 changed files with 39 additions and 9 deletions
  1. +4
    -0
      ChangeLog
  2. +35
    -9
      macosx/JackCoreAudioDriver.cpp

+ 4
- 0
ChangeLog View File

@@ -15,6 +15,10 @@ Kjetil S.Matheussen
Jackdmp changes log
---------------------------

2007-12-04 Stephane Letz <letz@grame.fr>

* Add a sample_rate change listener in CoreAudio driver.

2007-12-03 Stephane Letz <letz@grame.fr>

* Correct bug in CoreAudio driver sample rate management.


+ 35
- 9
macosx/JackCoreAudioDriver.cpp View File

@@ -250,13 +250,32 @@ OSStatus JackCoreAudioDriver::DeviceNotificationCallback(AudioDeviceID inDevice,
void* inClientData)
{
JackCoreAudioDriver* driver = (JackCoreAudioDriver*)inClientData;
if (inPropertyID == kAudioDeviceProcessorOverload) {
JackLog("JackCoreAudioDriver::NotificationCallback kAudioDeviceProcessorOverload\n");
#ifdef DEBUG
//driver->fLogFile->Capture(AudioGetCurrentHostTime() - AudioConvertNanosToHostTime(LOG_SAMPLE_DURATION * 1000000), AudioGetCurrentHostTime(), true, "Captured Latency Log for I/O Cycle Overload\n");
#endif
driver->NotifyXRun(GetMicroSeconds());
}
switch (inPropertyID) {
case kAudioDeviceProcessorOverload:
JackLog("JackCoreAudioDriver::NotificationCallback kAudioDeviceProcessorOverload\n");
#ifdef DEBUG
//driver->fLogFile->Capture(AudioGetCurrentHostTime() - AudioConvertNanosToHostTime(LOG_SAMPLE_DURATION * 1000000), AudioGetCurrentHostTime(), true, "Captured Latency Log for I/O Cycle Overload\n");
#endif
driver->NotifyXRun(GetMicroSeconds());
break;
case kAudioDevicePropertyNominalSampleRate: {
UInt32 outSize = sizeof(Float64);
Float64 sampleRate;
OSStatus err = AudioDeviceGetProperty(driver->fDeviceID, 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyNominalSampleRate, &outSize, &sampleRate);
if (err != noErr) {
jack_error("Cannot get current sample rate");
printError(err);
return kAudioHardwareUnsupportedOperationError;
}
JackLog("JackCoreAudioDriver::NotificationCallback kAudioDevicePropertyNominalSampleRate %ld\n", long(sampleRate));
if (jack_nframes_t(sampleRate) != driver->fEngineControl->fSampleRate) {
jack_error("Critical error : new %ld sample rate, engine will not run correctly anymore", long(sampleRate));
}
break;
}
}
return noErr;
}

@@ -735,12 +754,18 @@ int JackCoreAudioDriver::Open(jack_nframes_t nframes,
printError(err1);
goto error;
}
err = AudioDeviceAddPropertyListener(fDeviceID, 0, true, kAudioDevicePropertyNominalSampleRate, DeviceNotificationCallback, this);
if (err != noErr) {
jack_error("Error calling AudioDeviceAddPropertyListener with kAudioDevicePropertyNominalSampleRate");
printError(err1);
goto error;
}

fDriverOutputData = 0;

#if IO_CPU

outSize = sizeof(float);
outSize = sizeof(float);
iousage = 0.4f;
err = AudioDeviceSetProperty(fDeviceID, NULL, 0, false, kAudioDevicePropertyIOCycleUsage, outSize, &iousage);
if (err != noErr) {
@@ -769,6 +794,7 @@ int JackCoreAudioDriver::Close()
AudioDeviceRemoveIOProc(fDeviceID, MeasureCallback);
AudioDeviceRemovePropertyListener(fDeviceID, 0, true, kAudioDeviceProcessorOverload, DeviceNotificationCallback);
AudioDeviceRemovePropertyListener(fDeviceID, 0, true, kAudioHardwarePropertyDevices, DeviceNotificationCallback);
AudioDeviceRemovePropertyListener(fDeviceID, 0, true, kAudioDevicePropertyNominalSampleRate, DeviceNotificationCallback);
free(fJackInputData);
AudioUnitUninitialize(fAUHAL);
CloseComponent(fAUHAL);


Loading…
Cancel
Save