1 /* |
1 /* |
2 * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
22 */ |
22 */ |
23 |
23 |
24 import javax.sound.midi.MidiEvent; |
24 import javax.sound.midi.MidiEvent; |
25 import javax.sound.midi.MidiMessage; |
25 import javax.sound.midi.MidiMessage; |
26 import javax.sound.midi.MidiSystem; |
26 import javax.sound.midi.MidiSystem; |
|
27 import javax.sound.midi.MidiUnavailableException; |
27 import javax.sound.midi.Receiver; |
28 import javax.sound.midi.Receiver; |
28 import javax.sound.midi.Sequence; |
29 import javax.sound.midi.Sequence; |
29 import javax.sound.midi.Sequencer; |
30 import javax.sound.midi.Sequencer; |
30 import javax.sound.midi.ShortMessage; |
31 import javax.sound.midi.ShortMessage; |
31 import javax.sound.midi.Track; |
32 import javax.sound.midi.Track; |
32 |
33 |
33 /** |
34 /** |
34 * @test |
35 * @test |
35 * @bug 5048381 |
36 * @bug 5048381 |
36 * @summary Sequencer doesn't create distinct messages when recording events. |
37 * @summary Sequencer doesn't create distinct messages when recording events. |
37 * @key headful |
|
38 */ |
38 */ |
39 public class SeqRecordDoesNotCopy { |
39 public class SeqRecordDoesNotCopy { |
40 public static void main(String argv[]) throws Exception { |
40 |
41 Sequencer s = MidiSystem.getSequencer(); |
41 public static void main(String argv[]) { |
42 s.open(); |
42 Sequencer s = null; |
|
43 try { |
|
44 s = MidiSystem.getSequencer(); |
|
45 s.open(); |
|
46 } catch (final MidiUnavailableException ignored) { |
|
47 // the test is not applicable |
|
48 return; |
|
49 } |
43 try { |
50 try { |
44 Sequence seq = new Sequence(Sequence.PPQ, 384, 2); |
51 Sequence seq = new Sequence(Sequence.PPQ, 384, 2); |
45 s.setSequence(seq); |
52 s.setSequence(seq); |
46 Track t = seq.getTracks()[0]; |
53 Track t = seq.getTracks()[0]; |
47 ShortMessage msg = new ShortMessage(); |
54 ShortMessage msg = new ShortMessage(); |
84 System.out.println("Did not detect any duplicate messages."); |
91 System.out.println("Did not detect any duplicate messages."); |
85 System.out.println("Test passed."); |
92 System.out.println("Test passed."); |
86 } catch (Exception e) { |
93 } catch (Exception e) { |
87 System.out.println("Unexpected Exception: "+e); |
94 System.out.println("Unexpected Exception: "+e); |
88 //e.printStackTrace(); |
95 //e.printStackTrace(); |
89 throw new Exception("Test FAILED!"); |
96 throw new RuntimeException("Test FAILED!"); |
90 } finally { |
97 } finally { |
91 s.close(); |
98 s.close(); |
92 } |
99 } |
93 } |
100 } |
94 public static void printEvent(MidiEvent event) |
101 public static void printEvent(MidiEvent event) |