From 07d36782047f8f2c3644f73ce1fc82e6146529f5 Mon Sep 17 00:00:00 2001 From: Stephane Letz Date: Sun, 19 Feb 2012 17:25:08 +0100 Subject: [PATCH] Cleanup. --- macosx/coreaudio/JackCoreAudioDriver.cpp | 45 +++++++++++------------- macosx/coreaudio/JackCoreAudioDriver.h | 1 - 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/macosx/coreaudio/JackCoreAudioDriver.cpp b/macosx/coreaudio/JackCoreAudioDriver.cpp index 540ee374..d1a11a8b 100644 --- a/macosx/coreaudio/JackCoreAudioDriver.cpp +++ b/macosx/coreaudio/JackCoreAudioDriver.cpp @@ -374,7 +374,7 @@ OSStatus JackCoreAudioDriver::SRNotificationCallback(AudioDeviceID inDevice, jack_log("JackCoreAudioDriver::SRNotificationCallback kAudioDevicePropertyNominalSampleRate"); // Check new sample rate Float64 tmp_sample_rate; - UInt32 outSize = sizeof(Float64); + UInt32 outSize = sizeof(Float64); OSStatus err = AudioDeviceGetProperty(inDevice, 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyNominalSampleRate, &outSize, &tmp_sample_rate); if (err != noErr) { jack_error("Cannot get current sample rate"); @@ -392,7 +392,7 @@ OSStatus JackCoreAudioDriver::SRNotificationCallback(AudioDeviceID inDevice, OSStatus JackCoreAudioDriver::BSNotificationCallback(AudioDeviceID inDevice, UInt32 inChannel, - Boolean isInput, + Boolean isInput, AudioDevicePropertyID inPropertyID, void* inClientData) { @@ -404,7 +404,7 @@ OSStatus JackCoreAudioDriver::BSNotificationCallback(AudioDeviceID inDevice, jack_log("JackCoreAudioDriver::BSNotificationCallback kAudioDevicePropertyBufferFrameSize"); // Check new buffer size UInt32 tmp_buffer_size; - UInt32 outSize = sizeof(UInt32); + UInt32 outSize = sizeof(UInt32); OSStatus err = AudioDeviceGetProperty(inDevice, 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyBufferFrameSize, &outSize, &tmp_buffer_size); if (err != noErr) { jack_error("Cannot get current buffer size"); @@ -427,18 +427,17 @@ OSStatus JackCoreAudioDriver::AudioHardwareNotificationCallback(AudioHardwarePro switch (inPropertyID) { - case kAudioHardwarePropertyDevices: { - jack_log("JackCoreAudioDriver::AudioHardwareNotificationCallback kAudioHardwarePropertyDevices"); - DisplayDeviceNames(); - AudioDeviceID captureID, playbackID; - if (CheckAvailableDevice(driver->fDeviceID) || - (CheckAvailableDeviceName(driver->fCaptureUID, &captureID) - && CheckAvailableDeviceName(driver->fPlaybackUID, &playbackID))) { + case kAudioHardwarePropertyDevices: { + jack_log("JackCoreAudioDriver::AudioHardwareNotificationCallback kAudioHardwarePropertyDevices"); + DisplayDeviceNames(); + AudioDeviceID captureID, playbackID; + if (CheckAvailableDevice(driver->fDeviceID) || + (CheckAvailableDeviceName(driver->fCaptureUID, &captureID) + && CheckAvailableDeviceName(driver->fPlaybackUID, &playbackID))) { - } - break; } - + break; + } } return noErr; @@ -707,7 +706,6 @@ OSStatus JackCoreAudioDriver::GetStreamLatencies(AudioDeviceID device, bool isIn return err; } - bool JackCoreAudioDriver::IsDigitalDevice(AudioDeviceID device) { OSStatus err = noErr; @@ -773,12 +771,6 @@ bool JackCoreAudioDriver::IsDigitalDevice(AudioDeviceID device) return is_digital; } -bool JackCoreAudioDriver::IsDigitalDeviceStream(AudioDeviceID device, AudioStreamID streamID) -{ - // TODO - return true; -} - JackCoreAudioDriver::JackCoreAudioDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table) : JackAudioDriver(name, alias, engine, table), fAC3Encoder(NULL), @@ -1447,7 +1439,7 @@ int JackCoreAudioDriver::SetupBufferSize(jack_nframes_t buffer_size) } // Check new buffer size - outSize = sizeof(UInt32); + outSize = sizeof(UInt32); err = AudioDeviceGetProperty(fDeviceID, 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyBufferFrameSize, &outSize, &tmp_buffer_size); if (err != noErr) { jack_error("Cannot get current buffer size"); @@ -1464,7 +1456,7 @@ int JackCoreAudioDriver::SetupBufferSize(jack_nframes_t buffer_size) error: - // Remove SR change notification + // Remove BS change notification AudioDeviceRemovePropertyListener(fDeviceID, 0, true, kAudioDevicePropertyBufferFrameSize, BSNotificationCallback); return -1; @@ -1526,7 +1518,7 @@ int JackCoreAudioDriver::SetupSampleRateAux(AudioDeviceID inDevice, jack_nframes } // Check new sample rate - outSize = sizeof(Float64); + outSize = sizeof(Float64); err = AudioDeviceGetProperty(inDevice, 0, kAudioDeviceSectionGlobal, kAudioDevicePropertyNominalSampleRate, &outSize, &tmp_sample_rate); if (err != noErr) { jack_error("Cannot get current sample rate"); @@ -2024,7 +2016,7 @@ int JackCoreAudioDriver::Open(jack_nframes_t buffer_size, if (ac3_encoding) { - if (!IsDigitalDevice(fDeviceID)) { + if (!IsDigitalDevice(fDeviceID)) { jack_error("AC3 encoding can only be used with a digital device"); goto error; } @@ -2054,6 +2046,11 @@ int JackCoreAudioDriver::Open(jack_nframes_t buffer_size, fPlaybackChannels++; } + if (fPlaybackChannels < 2 || fPlaybackChannels > 6) { + jack_error("AC3 encoder channels must be between 2 and 6"); + goto error; + } + // Force real output channel number to 2 outchannels = out_nChannels = 2; diff --git a/macosx/coreaudio/JackCoreAudioDriver.h b/macosx/coreaudio/JackCoreAudioDriver.h index 10e1d50e..0c6e421c 100644 --- a/macosx/coreaudio/JackCoreAudioDriver.h +++ b/macosx/coreaudio/JackCoreAudioDriver.h @@ -164,7 +164,6 @@ class JackCoreAudioDriver : public JackAudioDriver void UpdateLatencies(); bool IsDigitalDevice(AudioDeviceID device); - bool IsDigitalDeviceStream(AudioDeviceID device, AudioStreamID streamID); public: