提交 3187baab 编写于 作者: S serb

8068412: [macosx] Initialization of Cocoa hangs if CoreAudio was initialized before

Reviewed-by: azvegint, prr
上级 e5d83a7f
/* /*
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
//#define USE_VERBOSE_TRACE //#define USE_VERBOSE_TRACE
#include <AudioUnit/AudioUnit.h> #include <AudioUnit/AudioUnit.h>
#include <CoreServices/CoreServices.h>
#include <AudioToolbox/AudioConverter.h> #include <AudioToolbox/AudioConverter.h>
#include <pthread.h> #include <pthread.h>
#include <math.h> #include <math.h>
...@@ -617,7 +616,7 @@ struct OSX_DirectAudioDevice { ...@@ -617,7 +616,7 @@ struct OSX_DirectAudioDevice {
~OSX_DirectAudioDevice() { ~OSX_DirectAudioDevice() {
if (audioUnit) { if (audioUnit) {
CloseComponent(audioUnit); AudioComponentInstanceDispose(audioUnit);
} }
if (resampler) { if (resampler) {
delete resampler; delete resampler;
...@@ -629,17 +628,16 @@ static AudioUnit CreateOutputUnit(AudioDeviceID deviceID, int isSource) ...@@ -629,17 +628,16 @@ static AudioUnit CreateOutputUnit(AudioDeviceID deviceID, int isSource)
{ {
OSStatus err; OSStatus err;
AudioUnit unit; AudioUnit unit;
UInt32 size;
ComponentDescription desc; AudioComponentDescription desc;
desc.componentType = kAudioUnitType_Output; desc.componentType = kAudioUnitType_Output;
desc.componentSubType = (deviceID == 0 && isSource) ? kAudioUnitSubType_DefaultOutput : kAudioUnitSubType_HALOutput; desc.componentSubType = (deviceID == 0 && isSource) ? kAudioUnitSubType_DefaultOutput : kAudioUnitSubType_HALOutput;
desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentManufacturer = kAudioUnitManufacturer_Apple;
desc.componentFlags = 0; desc.componentFlags = 0;
desc.componentFlagsMask = 0; desc.componentFlagsMask = 0;
Component comp = FindNextComponent(NULL, &desc); AudioComponent comp = AudioComponentFindNext(NULL, &desc);
err = OpenAComponent(comp, &unit); err = AudioComponentInstanceNew(comp, &unit);
if (err) { if (err) {
OS_ERROR0(err, "CreateOutputUnit:OpenAComponent"); OS_ERROR0(err, "CreateOutputUnit:OpenAComponent");
...@@ -664,7 +662,7 @@ static AudioUnit CreateOutputUnit(AudioDeviceID deviceID, int isSource) ...@@ -664,7 +662,7 @@ static AudioUnit CreateOutputUnit(AudioDeviceID deviceID, int isSource)
// get real AudioDeviceID for default input device (macosx current input device) // get real AudioDeviceID for default input device (macosx current input device)
deviceID = GetDefaultDevice(isSource); deviceID = GetDefaultDevice(isSource);
if (!deviceID) { if (!deviceID) {
CloseComponent(unit); AudioComponentInstanceDispose(unit);
return NULL; return NULL;
} }
} }
...@@ -675,7 +673,7 @@ static AudioUnit CreateOutputUnit(AudioDeviceID deviceID, int isSource) ...@@ -675,7 +673,7 @@ static AudioUnit CreateOutputUnit(AudioDeviceID deviceID, int isSource)
0, &deviceID, sizeof(deviceID)); 0, &deviceID, sizeof(deviceID));
if (err) { if (err) {
OS_ERROR0(err, "SetProperty (CurrentDevice)"); OS_ERROR0(err, "SetProperty (CurrentDevice)");
CloseComponent(unit); AudioComponentInstanceDispose(unit);
return NULL; return NULL;
} }
} }
......
/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import <JavaNativeFoundation/JavaNativeFoundation.h> #import <JavaNativeFoundation/JavaNativeFoundation.h>
#import <CoreServices/CoreServices.h>
#import <AudioToolbox/AudioToolbox.h>
#define DEBUG 1 #define DEBUG 1
......
/*
* Copyright (c) 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.awt.Toolkit;
import javax.sound.midi.MidiSystem;
/**
* @test
* @bug 8068412
* @author Sergey Bylokhov
*/
public final class InitializationHang {
public static void main(final String[] argv) throws Exception {
MidiSystem.getReceiver();
Toolkit.getDefaultToolkit();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册