-
Bug
-
Resolution: Unresolved
-
P4
-
8u60
-
x86
-
os_x
FULL PRODUCT VERSION :
$ java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Darwin fugalh-mbp1 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64 i386 MacBookPro11,2 Darwin
EXTRA RELEVANT SYSTEM CONFIGURATION :
Macbook Pro
The MIDI device I'm testing with is a Novation Launchpad Mini (USB), but I have also observed it with 3 other USB MIDI devices and virtual MIDI devices like that created by the Midi Keys app.
A DESCRIPTION OF THE PROBLEM :
MidiSystem.getMidiDeviceInfo() should return the device info objects for each midi device in the system (or maybe two, for devices that support both input and output). It does this, but it only scans the system once per JVM instance, and devices added or removed after the first call to getMidiDeviceInfo() are not reflected in the results.
The first call takes a few seconds, and subsequent calls return quickly. All of these behaviors are consistent with a caching strategy.
This question arises on Stack Overflow, where it is suggested to call com.sun.media.sound.JDK13Services.setCachingPeriod, however that function no longer exists and the API docs for JDK13Services say it is only for testing anyway. Also, it seems that the default value for that caching parameter should be 60 seconds, but waiting for many minutes does not change the caching behavior.
http://stackoverflow.com/questions/3752352/java-sound-api-scanning-for-midi-devices
I have tested the same code on Windows 10 and Ubuntu, where it works fine. I observe the same initial delay and subsequent speedup, however new devices do show up when plugged in. So this seems to be an OSX-specific bug.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The test program included in this bug report will illustrate the problem.
While this program is running, add and/or remove midi devices and observe that the list does not change. Kill it and run it afresh and notice that the currently-correct list of devices is now shown.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When I plug in a new MIDI device, it should show up in the results the next time (or after a reasonable caching delay). When I remove a MIDI device it should not show up in the results.
ACTUAL -
The same results with each call, irrelevant of actual MIDI configuration.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.sound.midi.*;
class Foo {
public static void main(String[] args) throws InterruptedException {
while (true) {
MidiDevice.Info[] a = MidiSystem.getMidiDeviceInfo();
for (MidiDevice.Info i : a) {
System.out.println(i.getName());
}
System.out.println();
Thread.sleep(2000);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
I am not aware of a workaround.
$ java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Darwin fugalh-mbp1 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64 i386 MacBookPro11,2 Darwin
EXTRA RELEVANT SYSTEM CONFIGURATION :
Macbook Pro
The MIDI device I'm testing with is a Novation Launchpad Mini (USB), but I have also observed it with 3 other USB MIDI devices and virtual MIDI devices like that created by the Midi Keys app.
A DESCRIPTION OF THE PROBLEM :
MidiSystem.getMidiDeviceInfo() should return the device info objects for each midi device in the system (or maybe two, for devices that support both input and output). It does this, but it only scans the system once per JVM instance, and devices added or removed after the first call to getMidiDeviceInfo() are not reflected in the results.
The first call takes a few seconds, and subsequent calls return quickly. All of these behaviors are consistent with a caching strategy.
This question arises on Stack Overflow, where it is suggested to call com.sun.media.sound.JDK13Services.setCachingPeriod, however that function no longer exists and the API docs for JDK13Services say it is only for testing anyway. Also, it seems that the default value for that caching parameter should be 60 seconds, but waiting for many minutes does not change the caching behavior.
http://stackoverflow.com/questions/3752352/java-sound-api-scanning-for-midi-devices
I have tested the same code on Windows 10 and Ubuntu, where it works fine. I observe the same initial delay and subsequent speedup, however new devices do show up when plugged in. So this seems to be an OSX-specific bug.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The test program included in this bug report will illustrate the problem.
While this program is running, add and/or remove midi devices and observe that the list does not change. Kill it and run it afresh and notice that the currently-correct list of devices is now shown.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When I plug in a new MIDI device, it should show up in the results the next time (or after a reasonable caching delay). When I remove a MIDI device it should not show up in the results.
ACTUAL -
The same results with each call, irrelevant of actual MIDI configuration.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.sound.midi.*;
class Foo {
public static void main(String[] args) throws InterruptedException {
while (true) {
MidiDevice.Info[] a = MidiSystem.getMidiDeviceInfo();
for (MidiDevice.Info i : a) {
System.out.println(i.getName());
}
System.out.println();
Thread.sleep(2000);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
I am not aware of a workaround.