changeset 13087:3e006ea10d21

8140620: Find and load default.sf2 as the default soundbank on Linux Reviewed-by: serb
author omajid
date Tue, 27 Oct 2015 15:19:15 -0400
parents dfeaf40df800
children 4280fce151e3
files src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java
diffstat 1 files changed, 34 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java	Tue Oct 27 14:16:24 2015 +0300
+++ b/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java	Tue Oct 27 15:19:15 2015 -0400
@@ -671,6 +671,40 @@
             actions.add(new PrivilegedAction<InputStream>() {
                 public InputStream run() {
                     if (System.getProperties().getProperty("os.name")
+                            .startsWith("Linux")) {
+
+                        File[] systemSoundFontsDir = new File[] {
+                            /* Arch, Fedora, Mageia */
+                            new File("/usr/share/soundfonts/"),
+                            new File("/usr/local/share/soundfonts/"),
+                            /* Debian, Gentoo, OpenSUSE, Ubuntu */
+                            new File("/usr/share/sounds/sf2/"),
+                            new File("/usr/local/share/sounds/sf2/"),
+                        };
+
+                        /*
+                         * Look for a default.sf2
+                         */
+                        for (File systemSoundFontDir : systemSoundFontsDir) {
+                            if (systemSoundFontDir.exists()) {
+                                File defaultSoundFont = new File(systemSoundFontDir, "default.sf2");
+                                if (defaultSoundFont.exists()) {
+                                    try {
+                                        return new FileInputStream(defaultSoundFont);
+                                    } catch (IOException e) {
+                                        // continue with lookup
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    return null;
+                }
+            });
+
+            actions.add(new PrivilegedAction<InputStream>() {
+                public InputStream run() {
+                    if (System.getProperties().getProperty("os.name")
                             .startsWith("Windows")) {
                         File gm_dls = new File(System.getenv("SystemRoot")
                                 + "\\system32\\drivers\\gm.dls");