src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_PCM.cpp
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 26,36 ****
//#define USE_ERROR
//#define USE_TRACE
//#define USE_VERBOSE_TRACE
#include <AudioUnit/AudioUnit.h>
- #include <CoreServices/CoreServices.h>
#include <AudioToolbox/AudioConverter.h>
#include <pthread.h>
#include <math.h>
/*
#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
--- 26,35 ----
*** 615,625 ****
OSX_DirectAudioDevice() : audioUnit(NULL), asbd(), resampler(NULL), lastWrittenSampleTime(0) {
}
~OSX_DirectAudioDevice() {
if (audioUnit) {
! CloseComponent(audioUnit);
}
if (resampler) {
delete resampler;
}
}
--- 614,624 ----
OSX_DirectAudioDevice() : audioUnit(NULL), asbd(), resampler(NULL), lastWrittenSampleTime(0) {
}
~OSX_DirectAudioDevice() {
if (audioUnit) {
! AudioComponentInstanceDispose(audioUnit);
}
if (resampler) {
delete resampler;
}
}
*** 627,647 ****
static AudioUnit CreateOutputUnit(AudioDeviceID deviceID, int isSource)
{
OSStatus err;
AudioUnit unit;
- UInt32 size;
! ComponentDescription desc;
desc.componentType = kAudioUnitType_Output;
desc.componentSubType = (deviceID == 0 && isSource) ? kAudioUnitSubType_DefaultOutput : kAudioUnitSubType_HALOutput;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
! Component comp = FindNextComponent(NULL, &desc);
! err = OpenAComponent(comp, &unit);
if (err) {
OS_ERROR0(err, "CreateOutputUnit:OpenAComponent");
return NULL;
}
--- 626,645 ----
static AudioUnit CreateOutputUnit(AudioDeviceID deviceID, int isSource)
{
OSStatus err;
AudioUnit unit;
! AudioComponentDescription desc;
desc.componentType = kAudioUnitType_Output;
desc.componentSubType = (deviceID == 0 && isSource) ? kAudioUnitSubType_DefaultOutput : kAudioUnitSubType_HALOutput;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
! AudioComponent comp = AudioComponentFindNext(NULL, &desc);
! err = AudioComponentInstanceNew(comp, &unit);
if (err) {
OS_ERROR0(err, "CreateOutputUnit:OpenAComponent");
return NULL;
}
*** 662,683 ****
if (!deviceID) {
// get real AudioDeviceID for default input device (macosx current input device)
deviceID = GetDefaultDevice(isSource);
if (!deviceID) {
! CloseComponent(unit);
return NULL;
}
}
}
if (deviceID) {
err = AudioUnitSetProperty(unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global,
0, &deviceID, sizeof(deviceID));
if (err) {
OS_ERROR0(err, "SetProperty (CurrentDevice)");
! CloseComponent(unit);
return NULL;
}
}
return unit;
--- 660,681 ----
if (!deviceID) {
// get real AudioDeviceID for default input device (macosx current input device)
deviceID = GetDefaultDevice(isSource);
if (!deviceID) {
! AudioComponentInstanceDispose(unit);
return NULL;
}
}
}
if (deviceID) {
err = AudioUnitSetProperty(unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global,
0, &deviceID, sizeof(deviceID));
if (err) {
OS_ERROR0(err, "SetProperty (CurrentDevice)");
! AudioComponentInstanceDispose(unit);
return NULL;
}
}
return unit;