Commit 3c86a8d1 authored by sletz's avatar sletz
Browse files

Correct bug in CoreAudio driver sample rate management.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1720 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 5515a607
......@@ -15,6 +15,10 @@ Kjetil S.Matheussen
Jackdmp changes log
---------------------------
2007-12-03 Stephane Letz <letz@grame.fr>
* Correct bug in CoreAudio driver sample rate management.
2007-11-30 Stephane Letz <letz@grame.fr>
* Correct JackMachNotifyChannel::ClientNotify.
......
......@@ -101,6 +101,12 @@ static void printError(OSStatus err)
break;
case kAudioDevicePermissionsError:
JackLog("error code : kAudioDevicePermissionsError\n");
break;
case kAudioHardwareBadObjectError:
JackLog("error code : kAudioHardwareBadObjectError\n");
break;
case kAudioHardwareUnsupportedOperationError:
JackLog("error code : kAudioHardwareUnsupportedOperationError\n");
break;
default:
JackLog("error code : unknown\n");
......@@ -404,7 +410,9 @@ int JackCoreAudioDriver::Open(jack_nframes_t nframes,
ComponentResult err1;
UInt32 outSize;
UInt32 enableIO;
AudioStreamBasicDescription srcFormat, dstFormat, sampleRate;
AudioStreamBasicDescription srcFormat, dstFormat;
Float64 sampleRate;
long in_nChannels = 0;
long out_nChannels = 0;
char capture_driver_name[256];
......@@ -525,46 +533,24 @@ int JackCoreAudioDriver::Open(jack_nframes_t nframes,
}
// Set sample rate
if (capturing && inchannels > 0) {
outSize = sizeof(AudioStreamBasicDescription);
err = AudioDeviceGetProperty(fDeviceID, 0, true, kAudioDevicePropertyStreamFormat, &outSize, &sampleRate);
if (err != noErr) {
jack_error("Cannot get current sample rate");
printError(err);
return -1;
}
if (samplerate != (unsigned long)sampleRate.mSampleRate) {
sampleRate.mSampleRate = (Float64)samplerate;
err = AudioDeviceSetProperty(fDeviceID, NULL, 0, true, kAudioDevicePropertyStreamFormat, outSize, &sampleRate);
if (err != noErr) {
jack_error("Cannot set sample rate = %ld", samplerate);
printError(err);
return -1;
}
}
}
if (playing && outchannels > 0) {
outSize = sizeof(AudioStreamBasicDescription);
err = AudioDeviceGetProperty(fDeviceID, 0, false, kAudioDevicePropertyStreamFormat, &outSize, &sampleRate);
if (err != noErr) {
jack_error("Cannot get current sample rate");
printError(err);
return -1;
}
if (samplerate != (unsigned long)sampleRate.mSampleRate) {
sampleRate.mSampleRate = (Float64)samplerate;
err = AudioDeviceSetProperty(fDeviceID, NULL, 0, false, kAudioDevicePropertyStreamFormat, outSize, &sampleRate);
if (err != noErr) {
jack_error("Cannot set sample rate = %ld", samplerate);
printError(err);
return -1;
}
}
}
outSize = sizeof(Float64);
err = AudioDeviceGetProperty(fDeviceID, 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyNominalSampleRate, &outSize, &sampleRate);
if (err != noErr) {
jack_error("Cannot get current sample rate");
printError(err);
return -1;
}
if (samplerate != (jack_nframes_t)sampleRate) {
sampleRate = (Float64)samplerate;
err = AudioDeviceSetProperty(fDeviceID, NULL, 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyNominalSampleRate, outSize, &sampleRate);
if (err != noErr) {
jack_error("Cannot set sample rate = %ld", samplerate);
printError(err);
return -1;
}
}
// AUHAL
ComponentDescription cd = {kAudioUnitType_Output, kAudioUnitSubType_HALOutput, kAudioUnitManufacturer_Apple, 0, 0};
Component HALOutput = FindNextComponent(NULL, &cd);
......
......@@ -36,6 +36,13 @@ namespace Jack
//#define IO_CPU 1
typedef UInt8 CAAudioHardwareDeviceSectionID;
#define kAudioDeviceSectionInput ((CAAudioHardwareDeviceSectionID)0x01)
#define kAudioDeviceSectionOutput ((CAAudioHardwareDeviceSectionID)0x00)
#define kAudioDeviceSectionGlobal ((CAAudioHardwareDeviceSectionID)0x00)
#define kAudioDeviceSectionWildcard ((CAAudioHardwareDeviceSectionID)0xFF)
/*!
\brief The CoreAudio driver.
......
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