diff --git a/src/org/jitsi/impl/neomedia/jmfext/media/renderer/audio/AbstractAudioRenderer.java b/src/org/jitsi/impl/neomedia/jmfext/media/renderer/audio/AbstractAudioRenderer.java index 245932a0da4b1d4890c4e82ba0ea46b13d853713..f37ba16eeafdecbaf24f9bf6576046f64dcbce45 100644 --- a/src/org/jitsi/impl/neomedia/jmfext/media/renderer/audio/AbstractAudioRenderer.java +++ b/src/org/jitsi/impl/neomedia/jmfext/media/renderer/audio/AbstractAudioRenderer.java @@ -105,10 +105,24 @@ public void open() } } + /** + * Notifies this instance that the value of the + * {@link AudioSystem#PROP_PLAYBACK_DEVICE} property of its associated + * <tt>AudioSystem</tt> has changed. The default implementation does nothing + * so extenders may safely not call back to their + * <tt>AbstractAudioRenderer</tt> super. + * + * @param event a <tt>PropertyChangeEvent</tt> which specifies details about + * the change such as the name of the property and its old and new values + */ + protected void playbackDevicePropertyChange(PropertyChangeEvent event) + { + } + private void propertyChange(PropertyChangeEvent event) { if (AudioSystem.PROP_PLAYBACK_DEVICE.equals(event.getPropertyName())) - reset(); + playbackDevicePropertyChange(event); } /** diff --git a/src/org/jitsi/impl/neomedia/jmfext/media/renderer/audio/PortAudioRenderer.java b/src/org/jitsi/impl/neomedia/jmfext/media/renderer/audio/PortAudioRenderer.java index 8b1042f13f9c2760b7fb90c0c1286667428904e3..25ae1c5efbbd4ddb7cb63ccc32902037c7b333a1 100644 --- a/src/org/jitsi/impl/neomedia/jmfext/media/renderer/audio/PortAudioRenderer.java +++ b/src/org/jitsi/impl/neomedia/jmfext/media/renderer/audio/PortAudioRenderer.java @@ -6,6 +6,7 @@ */ package org.jitsi.impl.neomedia.jmfext.media.renderer.audio; +import java.beans.*; import java.lang.reflect.*; import java.util.*; @@ -467,6 +468,52 @@ private void doOpen() } } + /** + * Notifies this instance that the value of the + * {@link AudioSystem#PROP_PLAYBACK_DEVICE} property of its associated + * <tt>AudioSystem</tt> has changed. + * + * @param event a <tt>PropertyChangeEvent</tt> which specifies details about + * the change such as the name of the property and its old and new values + */ + @Override + protected void playbackDevicePropertyChange(PropertyChangeEvent event) + { + /* + * Stop, close, re-open and re-start this Renderer (performing whichever + * of these in order to bring it into the same state) in order to + * reflect the change in the selection with respect to the playback + * device. + */ + + waitWhileStreamIsBusy(); + + boolean open = (this.stream != 0); + + if (open) + { + /* + * The close method will stop this Renderer if it is currently + * started. + */ + boolean start = this.started; + + close(); + + try + { + open(); + } + catch (ResourceUnavailableException rue) + { + throw new UndeclaredThrowableException(rue); + } + + if (start) + start(); + } + } + /** * Renders the audio data contained in a specific <tt>Buffer</tt> onto the * PortAudio device represented by this <tt>Renderer</tt>. @@ -577,39 +624,6 @@ private void process(byte[] buffer, int offset, int length) } } - /** - * Resets the state of this <tt>PlugIn</tt>. - */ - public synchronized void reset() - { - waitWhileStreamIsBusy(); - - boolean open = (this.stream != 0); - - if (open) - { - /* - * The close method will stop this Renderer if it is currently - * started. - */ - boolean start = this.started; - - close(); - - try - { - open(); - } - catch (ResourceUnavailableException rue) - { - throw new UndeclaredThrowableException(rue); - } - - if (start) - start(); - } - } - /** * Sets the <tt>MediaLocator</tt> which specifies the device index of the * PortAudio device to be used by this instance for rendering. diff --git a/src/org/jitsi/impl/neomedia/jmfext/media/renderer/audio/PulseAudioRenderer.java b/src/org/jitsi/impl/neomedia/jmfext/media/renderer/audio/PulseAudioRenderer.java index 9f6a47ee4b31b6d142a67e5f9140a9088f071d52..933f09d88018c3f8ec4c3c6b816e44e2de862d7c 100644 --- a/src/org/jitsi/impl/neomedia/jmfext/media/renderer/audio/PulseAudioRenderer.java +++ b/src/org/jitsi/impl/neomedia/jmfext/media/renderer/audio/PulseAudioRenderer.java @@ -6,6 +6,7 @@ */ package org.jitsi.impl.neomedia.jmfext.media.renderer.audio; +import java.beans.*; import java.io.*; import java.lang.reflect.*; @@ -374,6 +375,55 @@ public void run() } } + /** + * Notifies this instance that the value of the + * {@link AudioSystem#PROP_PLAYBACK_DEVICE} property of its associated + * <tt>AudioSystem</tt> has changed. + * + * @param event a <tt>PropertyChangeEvent</tt> which specifies details about + * the change such as the name of the property and its old and new values + */ + @Override + protected void playbackDevicePropertyChange(PropertyChangeEvent event) + { + /* + * FIXME Disabled due to freezes reported by Vincent Lucas and Kertesz + * Laszlo on the dev mailing list. + */ +// pulseAudioSystem.lockMainloop(); +// try +// { +// boolean open = (this.stream != 0); +// +// if (open) +// { +// /* +// * The close method will stop this Renderer if it is currently +// * started. +// */ +// boolean start = !this.corked; +// +// close(); +// +// try +// { +// open(); +// } +// catch (ResourceUnavailableException rue) +// { +// throw new UndeclaredThrowableException(rue); +// } +// +// if (start) +// start(); +// } +// } +// finally +// { +// pulseAudioSystem.unlockMainloop(); +// } + } + public int process(Buffer buffer) { if (buffer.isDiscard()) @@ -464,45 +514,6 @@ private int processWithMainloopLock(Buffer buffer) return ret; } - /** - * Resets the state of this <tt>PlugIn</tt>. - */ - public void reset() - { - pulseAudioSystem.lockMainloop(); - try - { - boolean open = (this.stream != 0); - - if (open) - { - /* - * The close method will stop this Renderer if it is currently - * started. - */ - boolean start = !this.corked; - - close(); - - try - { - open(); - } - catch (ResourceUnavailableException rue) - { - throw new UndeclaredThrowableException(rue); - } - - if (start) - start(); - } - } - finally - { - pulseAudioSystem.unlockMainloop(); - } - } - private void setStreamVolume(long stream, float level) { int volume