equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2016, 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. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
63 private final MidiDevice.Info info; |
63 private final MidiDevice.Info info; |
64 |
64 |
65 |
65 |
66 // DEVICE STATE |
66 // DEVICE STATE |
67 |
67 |
68 private boolean open = false; |
68 private volatile boolean open; |
69 private int openRefCount; |
69 private int openRefCount; |
70 |
70 |
71 /** List of Receivers and Transmitters that opened the device implicitely. |
71 /** List of Receivers and Transmitters that opened the device implicitely. |
72 */ |
72 */ |
73 private List<Object> openKeepingObjects; |
73 private List<Object> openKeepingObjects; |
74 |
74 |
75 /** |
75 /** |
76 * This is the device handle returned from native code |
76 * This is the device handle returned from native code |
77 */ |
77 */ |
78 protected long id = 0; |
78 protected volatile long id; |
79 |
79 |
80 |
80 |
81 |
81 |
82 // CONSTRUCTOR |
82 // CONSTRUCTOR |
83 |
83 |
477 contains magic necessary to manage implicit closing the device. |
477 contains magic necessary to manage implicit closing the device. |
478 This is necessary for Receivers retrieved via MidiSystem.getReceiver() |
478 This is necessary for Receivers retrieved via MidiSystem.getReceiver() |
479 (which opens the device implicitely). |
479 (which opens the device implicitely). |
480 */ |
480 */ |
481 abstract class AbstractReceiver implements MidiDeviceReceiver { |
481 abstract class AbstractReceiver implements MidiDeviceReceiver { |
482 private boolean open = true; |
482 private volatile boolean open = true; |
483 |
483 |
484 |
484 |
485 /** Deliver a MidiMessage. |
485 /** Deliver a MidiMessage. |
486 This method contains magic related to the closed state of a |
486 This method contains magic related to the closed state of a |
487 Receiver. Therefore, subclasses should not override this method. |
487 Receiver. Therefore, subclasses should not override this method. |