|
From: <ls...@us...> - 2011-08-21 19:59:06
|
Revision: 5855
http://jnode.svn.sourceforge.net/jnode/?rev=5855&view=rev
Author: lsantha
Date: 2011-08-21 19:59:00 +0000 (Sun, 21 Aug 2011)
Log Message:
-----------
Fixed playing beep with the play command.
Modified Paths:
--------------
trunk/gui/src/driver/org/jnode/driver/sound/speaker/SpeakerUtils.java
Modified: trunk/gui/src/driver/org/jnode/driver/sound/speaker/SpeakerUtils.java
===================================================================
--- trunk/gui/src/driver/org/jnode/driver/sound/speaker/SpeakerUtils.java 2011-08-21 15:30:55 UTC (rev 5854)
+++ trunk/gui/src/driver/org/jnode/driver/sound/speaker/SpeakerUtils.java 2011-08-21 19:59:00 UTC (rev 5855)
@@ -38,8 +38,6 @@
/** My logger */
private static final Logger log = Logger.getLogger(SpeakerUtils.class);
- /** What to play as the standard beep (null = a simple beep) * */
- public static Note[] stdBeep = null;
/** The length of a standard interval * */
public static final int INTERVAL = 500;
@@ -58,30 +56,23 @@
/** Sounds a beep on the system speaker * */
public static void beep() {
- if (stdBeep == null) {
- try {
- DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME);
- Device dev = dm.getDevice("speaker0");
- SpeakerAPI s = dev.getAPI(SpeakerAPI.class);
- s.beep();
- } catch (ApiNotFoundException anfex) {
- log.error("Unable to beep: ", anfex);
- } catch (DeviceNotFoundException dnfex) {
- log.error("Unable to beep: ", dnfex);
- } catch (NameNotFoundException nnfex) {
- log.debug("Unable to beep: ", nnfex);
- }
- } else
- play(stdBeep);
+ play(stdBeep);
}
- /** Plays a series of notes through the default speaker * */
+ /**
+ * Plays a series of notes through the default speaker.
+ * Null argument or zero length array plays the standard beep.
+ */
public static void play(Note[] n) {
try {
DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME);
Device dev = dm.getDevice("speaker0");
SpeakerAPI s = dev.getAPI(SpeakerAPI.class);
- s.playNote(n);
+ if (n == null || n.length == 0) {
+ s.beep();
+ } else {
+ s.playNote(n);
+ }
} catch (ApiNotFoundException anfex) {
log.error("Unable to beep: ", anfex);
} catch (DeviceNotFoundException dnfex) {
@@ -92,6 +83,9 @@
}
+ /** What to play as the standard beep (null = a simple beep) * */
+ public static Note[] stdBeep = new Note[0];
+
/** Defines a scale * */
public static final Note[] SCALE =
new Note[] {new Note(Note.NOTE_C4, HALF), new Note(Note.NOTE_D4, HALF),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|