Browse Source

Correct bug in CoreAudio driver sample rate management.

git-svn-id: svn+ssh://jackaudio.org/trunk/jack@1069 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.109.0
sletz 17 years ago
parent
commit
c25e45e4ae
3 changed files with 26 additions and 40 deletions
  1. +1
    -1
      configure.ac
  2. +17
    -37
      drivers/coreaudio/coreaudio_driver.c
  3. +8
    -2
      drivers/coreaudio/coreaudio_driver.h

+ 1
- 1
configure.ac View File

@@ -17,7 +17,7 @@ dnl changes are made
dnl --- dnl ---
JACK_MAJOR_VERSION=0 JACK_MAJOR_VERSION=0
JACK_MINOR_VERSION=107 JACK_MINOR_VERSION=107
JACK_MICRO_VERSION=5
JACK_MICRO_VERSION=6


dnl --- dnl ---
dnl HOWTO: updating the jack protocol version dnl HOWTO: updating the jack protocol version


+ 17
- 37
drivers/coreaudio/coreaudio_driver.c View File

@@ -1,6 +1,6 @@
/* /*
Copyright © Grame, 2003.
Copyright © Johnny Petrantoni, 2003.
Copyright � Grame, 2003.
Copyright � Johnny Petrantoni, 2003.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -45,6 +45,7 @@
May 17, 2006: S.Letz: Minor fix in driver_initialize. May 17, 2006: S.Letz: Minor fix in driver_initialize.
May 18, 2006: S.Letz: Document sample rate default value. May 18, 2006: S.Letz: Document sample rate default value.
May 31, 2006: S.Letz: Apply Rui patch for more consistent driver parameter naming. May 31, 2006: S.Letz: Apply Rui patch for more consistent driver parameter naming.
Dec 04, 2007: S.Letz: Fix a bug in sample rate management (occuring in particular with "aggregate" devices).
*/ */


#include <stdio.h> #include <stdio.h>
@@ -270,7 +271,7 @@ static OSStatus display_device_names()
err = AudioDeviceGetProperty(devices[i], 0, false, kAudioDevicePropertyDeviceName, &size, device_name); err = AudioDeviceGetProperty(devices[i], 0, false, kAudioDevicePropertyDeviceName, &size, device_name);
if (err != noErr) if (err != noErr)
return err; return err;
printf("ICI\n");
printf("Device name = \'%s\', internal_name = \'%s\' (to be used as -d parameter)\n", device_name, internal_name); printf("Device name = \'%s\', internal_name = \'%s\' (to be used as -d parameter)\n", device_name, internal_name);
} }
@@ -555,7 +556,8 @@ static jack_driver_t *coreaudio_driver_new(char* name,
ComponentResult err1; ComponentResult err1;
UInt32 outSize; UInt32 outSize;
UInt32 enableIO; UInt32 enableIO;
AudioStreamBasicDescription srcFormat, dstFormat, sampleRate;
AudioStreamBasicDescription srcFormat, dstFormat;
Float64 sampleRate;
int in_nChannels = 0; int in_nChannels = 0;
int out_nChannels = 0; int out_nChannels = 0;
int i; int i;
@@ -695,44 +697,22 @@ static jack_driver_t *coreaudio_driver_new(char* name,
} }


// Set sample rate // Set sample rate
if (capturing && inchannels > 0) {
outSize = sizeof(AudioStreamBasicDescription);
err = AudioDeviceGetProperty(driver->device_id, 0, true, kAudioDevicePropertyStreamFormat, &outSize, &sampleRate);
if (err != noErr) {
jack_error("Cannot get current sample rate");
printError(err);
goto error;
}

if (samplerate != (unsigned long)sampleRate.mSampleRate) {
sampleRate.mSampleRate = (Float64)samplerate;
err = AudioDeviceSetProperty(driver->device_id, NULL, 0, true, kAudioDevicePropertyStreamFormat, outSize, &sampleRate);
if (err != noErr) {
jack_error("Cannot set sample rate = %ld", samplerate);
printError(err);
goto error;
}
}
outSize = sizeof(Float64);
err = AudioDeviceGetProperty(driver->device_id, 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyNominalSampleRate, &outSize, &sampleRate);
if (err != noErr) {
jack_error("Cannot get current sample rate");
printError(err);
goto error;
} }
if (playing && outchannels > 0) {
outSize = sizeof(AudioStreamBasicDescription);
err = AudioDeviceGetProperty(driver->device_id, 0, false, kAudioDevicePropertyStreamFormat, &outSize, &sampleRate);

if (samplerate != (jack_nframes_t)sampleRate) {
sampleRate = (Float64)samplerate;
err = AudioDeviceSetProperty(driver->device_id, NULL, 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyNominalSampleRate, outSize, &sampleRate);
if (err != noErr) { if (err != noErr) {
jack_error("Cannot get current sample rate");
jack_error("Cannot set sample rate = %ld", samplerate);
printError(err); printError(err);
goto error; goto error;
} }

if (samplerate != (unsigned long)sampleRate.mSampleRate) {
sampleRate.mSampleRate = (Float64)samplerate;
err = AudioDeviceSetProperty(driver->device_id, NULL, 0, false, kAudioDevicePropertyStreamFormat, outSize, &sampleRate);
if (err != noErr) {
jack_error("Cannot set sample rate = %ld", samplerate);
printError(err);
goto error;
}
}
} }


// AUHAL // AUHAL


+ 8
- 2
drivers/coreaudio/coreaudio_driver.h View File

@@ -1,6 +1,6 @@
/* /*
Copyright © Grame, 2003.
Copyright © Johnny Petrantoni, 2003.
Copyright � Grame, 2003.
Copyright � Johnny Petrantoni, 2003.


This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -72,4 +72,10 @@ typedef struct {


#define kVersion 01 #define kVersion 01


typedef UInt8 CAAudioHardwareDeviceSectionID;
#define kAudioDeviceSectionInput ((CAAudioHardwareDeviceSectionID)0x01)
#define kAudioDeviceSectionOutput ((CAAudioHardwareDeviceSectionID)0x00)
#define kAudioDeviceSectionGlobal ((CAAudioHardwareDeviceSectionID)0x00)
#define kAudioDeviceSectionWildcard ((CAAudioHardwareDeviceSectionID)0xFF)

#endif /* __jack_coreaudio_driver_h__ */ #endif /* __jack_coreaudio_driver_h__ */

Loading…
Cancel
Save