@Test public void testPlaySound() throws UnsupportedAudioFileException, IOException, InterruptedException { Audio.playSound(Audio.getAudioStream("./etc/Bass-Drum-1.wav"), -10.0f); assertTrue(Audio.isServiceRunning()); Thread.sleep(5000); assertFalse(!Audio.isServiceRunning()); }
public static void playSound(AudioInputStream stream, float volume) { init(); for (int i = headIndex; i != tailIndex; i = (i + 1) % MAX_PENDING) { if (getPendingAudio()[i].getStream() == stream) { getPendingAudio()[i].setVolume(Math.max(volume, getPendingAudio()[i].getVolume())); return; } } getPendingAudio()[tailIndex] = new PlayMessage(stream, volume); tailIndex = (tailIndex + 1) % MAX_PENDING; }
Audio { public static void playSound(AudioInputStream stream, float volume) { init(); for (int i = headIndex; i != tailIndex; i = (i + 1) % MAX_PENDING) { if (getPendingAudio()[i].getStream() == stream) { getPendingAudio()[i].setVolume(Math.max(volume, getPendingAudio()[i].getVolume())); return; } } getPendingAudio()[tailIndex] = new PlayMessage(stream, volume); tailIndex = (tailIndex + 1) % MAX_PENDING; } }
Audio { public static void playSound(AudioInputStream stream, float volume) { init(); for (int i = headIndex; i != tailIndex; i = (i + 1) % MAX_PENDING) { if (getPendingAudio()[i].getStream() == stream) { getPendingAudio()[i].setVolume(Math.max(volume, getPendingAudio()[i].getVolume())); return; } } getPendingAudio()[tailIndex] = new PlayMessage(stream, volume); tailIndex = (tailIndex + 1) % MAX_PENDING; }  }
Audio { public static void playSound(AudioInputStream stream, float volume) { init(); for (int i = headIndex; i != tailIndex; i = (i + 1) % MAX_PENDING) { if (getPendingAudio()[i].getStream() == stream) { getPendingAudio()[i].setVolume(Math.max(volume, getPendingAudio()[i].getVolume())); return; } } getPendingAudio()[tailIndex] = new PlayMessage(stream, volume); tailIndex = (tailIndex + 1) % MAX_PENDING; }  static synchronized void stopService(); static synchronized boolean isServiceRunning(); static void init(); static synchronized void startThread(); static void playSound(AudioInputStream stream, float volume); static void update(); static AudioInputStream getAudioStream(String filePath); static PlayMessage[] getPendingAudio(); }
Audio { public static void playSound(AudioInputStream stream, float volume) { init(); for (int i = headIndex; i != tailIndex; i = (i + 1) % MAX_PENDING) { if (getPendingAudio()[i].getStream() == stream) { getPendingAudio()[i].setVolume(Math.max(volume, getPendingAudio()[i].getVolume())); return; } } getPendingAudio()[tailIndex] = new PlayMessage(stream, volume); tailIndex = (tailIndex + 1) % MAX_PENDING; }  static synchronized void stopService(); static synchronized boolean isServiceRunning(); static void init(); static synchronized void startThread(); static void playSound(AudioInputStream stream, float volume); static void update(); static AudioInputStream getAudioStream(String filePath); static PlayMessage[] getPendingAudio();  }