mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
8374727: Audio configuration Platform class - use nio for getting endianness of the underlying platform
Reviewed-by: prr, kizune
This commit is contained in:
parent
7f707ba8e7
commit
074038438f
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2026, 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
|
||||
@ -162,8 +162,7 @@ void DAUDIO_GetFormats(INT32 mixerIndex, INT32 deviceID, int isSource, void* cre
|
||||
sampleRate, // sample rate
|
||||
DAUDIO_PCM, // only accept PCM
|
||||
bits == 8 ? FALSE : TRUE, // signed
|
||||
bits == 8 ? FALSE // little-endian for 8bit
|
||||
: UTIL_IsBigEndianPlatform());
|
||||
FALSE); // all supported macOS versions run on LE
|
||||
}
|
||||
}
|
||||
// add default format
|
||||
@ -175,7 +174,7 @@ void DAUDIO_GetFormats(INT32 mixerIndex, INT32 deviceID, int isSource, void* cre
|
||||
defSampleRate, // sample rate
|
||||
DAUDIO_PCM, // PCM
|
||||
TRUE, // signed
|
||||
UTIL_IsBigEndianPlatform()); // native endianness
|
||||
FALSE); // native endianness; all supported macOS versions run on LE
|
||||
}
|
||||
|
||||
TRACE0("<<DAUDIO_GetFormats\n");
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2026, 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
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
package com.sun.media.sound;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
@ -40,12 +41,6 @@ final class Platform {
|
||||
|
||||
private static boolean isNativeLibLoaded;
|
||||
|
||||
// SYSTEM CHARACTERISTICS
|
||||
// vary according to hardware architecture
|
||||
|
||||
// intel is little-endian. sparc is big-endian.
|
||||
private static boolean bigEndian;
|
||||
|
||||
static {
|
||||
loadLibraries();
|
||||
}
|
||||
@ -66,7 +61,7 @@ final class Platform {
|
||||
* Determine whether the system is big-endian.
|
||||
*/
|
||||
static boolean isBigEndian() {
|
||||
return bigEndian;
|
||||
return ByteOrder.nativeOrder().equals(ByteOrder.BIG_ENDIAN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,9 +77,6 @@ final class Platform {
|
||||
if (Printer.err) Printer.err("Couldn't load library "+libName+": "+t.toString());
|
||||
isNativeLibLoaded = false;
|
||||
}
|
||||
if (isNativeLibLoaded) {
|
||||
bigEndian = nIsBigEndian();
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isMidiIOEnabled() {
|
||||
@ -98,7 +90,4 @@ final class Platform {
|
||||
static boolean isDirectAudioEnabled() {
|
||||
return isNativeLibLoaded;
|
||||
}
|
||||
|
||||
// the following native method is implemented in Platform.c
|
||||
private static native boolean nIsBigEndian();
|
||||
}
|
||||
|
||||
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2018, 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
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "Utilities.h"
|
||||
// Platform.java includes
|
||||
#include "com_sun_media_sound_Platform.h"
|
||||
|
||||
/*
|
||||
* Declare library specific JNI_Onload entry if static build
|
||||
*/
|
||||
DEF_STATIC_JNI_OnLoad
|
||||
|
||||
/*
|
||||
* Class: com_sun_media_sound_Platform
|
||||
* Method: nIsBigEndian
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_com_sun_media_sound_Platform_nIsBigEndian(JNIEnv *env, jclass clss) {
|
||||
return UTIL_IsBigEndianPlatform();
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2026, 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
|
||||
@ -26,15 +26,6 @@
|
||||
|
||||
#include "Utilities.h"
|
||||
|
||||
|
||||
int UTIL_IsBigEndianPlatform() {
|
||||
#ifdef _LITTLE_ENDIAN
|
||||
return 0;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ThrowJavaMessageException(JNIEnv *e, const char *exClass, const char *msg) {
|
||||
jclass newExcCls;
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2026, 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
|
||||
@ -28,10 +28,6 @@
|
||||
#include "SoundDefs.h"
|
||||
#include "Configure.h" // put flags for debug msgs etc. here
|
||||
|
||||
// return 1 if this platform is big endian, or 0 for little endian
|
||||
int UTIL_IsBigEndianPlatform();
|
||||
|
||||
|
||||
// ERROR PRINTS
|
||||
#ifdef USE_ERROR
|
||||
#define ERROR0(string) { fprintf(stdout, (string)); fflush(stdout); }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user