From c55ebea3679a3fa87c353ad583e90abdd567dcd2 Mon Sep 17 00:00:00 2001 From: Lyubomir Marinov <lyubomir.marinov@jitsi.org> Date: Thu, 12 Jul 2012 21:49:50 +0000 Subject: [PATCH] Temporarily reverts to the PulseAudio Renderer implementation to a pre-r9718 state to fix freezes reported by Vincent Lucas and Kertesz Laszlo on the dev mailing list while further looking into the cause of the problem. --- .../renderer/audio/AbstractAudioRenderer.java | 16 +++- .../renderer/audio/PortAudioRenderer.java | 80 ++++++++++------- .../renderer/audio/PulseAudioRenderer.java | 89 +++++++++++-------- 3 files changed, 112 insertions(+), 73 deletions(-) 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 245932a0..f37ba16e 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 8b1042f1..25ae1c5e 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 9f6a47ee..933f09d8 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 -- GitLab