diff --git a/src/net/java/sip/communicator/impl/neomedia/portaudio/PortAudio.java b/src/net/java/sip/communicator/impl/neomedia/portaudio/PortAudio.java index 2f3212fc4fe37ca5c855e86068067504bddd4ced..145548eb01afc5da3d8c01e0bf43c3c908ac99fb 100644 --- a/src/net/java/sip/communicator/impl/neomedia/portaudio/PortAudio.java +++ b/src/net/java/sip/communicator/impl/neomedia/portaudio/PortAudio.java @@ -42,6 +42,8 @@ public final class PortAudio } catch (PortAudioException paex) { + printHostError(paex); + throw new UndeclaredThrowableException(paex); } } @@ -872,4 +874,22 @@ public static void setDevicesChangedCallback( private PortAudio() { } + + /** + * Prints host error info for an <tt>PortAudioException</tt> if any. + * @param e the exception to check for host error info. + */ + public static void printHostError(PortAudioException e) + { + PortAudioHostErrorInfo hostErrorInfo = e.getPortAudioHostErrorInfo(); + + if(hostErrorInfo != null) + { + logger.error(e.getMessage() + + ". Host error info - hostApiType:" + + hostErrorInfo.getHostApiType() + + ", native error code:" + hostErrorInfo.getErrorCode() + + ", native error text: " + hostErrorInfo.getErrorText()); + } + } } diff --git a/src/net/java/sip/communicator/impl/neomedia/portaudio/PortAudioException.java b/src/net/java/sip/communicator/impl/neomedia/portaudio/PortAudioException.java index e6828ab32cc7cf0d8f0b650a4df8c5532a69beda..95e27eae3227bd82f7e45673e93463825d4549b1 100644 --- a/src/net/java/sip/communicator/impl/neomedia/portaudio/PortAudioException.java +++ b/src/net/java/sip/communicator/impl/neomedia/portaudio/PortAudioException.java @@ -30,4 +30,18 @@ public PortAudioException(String message) { super(message); } + + /** + * Initializes a new <tt>PortAudioException</tt> instance with a specific + * detail message. + * + * @param message the detail message to initialize the new instance with + */ + public PortAudioException(String message, + int hostApiInfo, + long errorCode, + String errorText) + { + super(message, hostApiInfo, errorCode, errorText); + } } diff --git a/src/org/jitsi/impl/neomedia/jmfext/media/protocol/portaudio/PortAudioStream.java b/src/org/jitsi/impl/neomedia/jmfext/media/protocol/portaudio/PortAudioStream.java index c0bb159bf03ce70487e40b713dfe30582cfab3a7..280e1a08fc50f9a8ccbe522e8dde4d1719679394 100644 --- a/src/org/jitsi/impl/neomedia/jmfext/media/protocol/portaudio/PortAudioStream.java +++ b/src/org/jitsi/impl/neomedia/jmfext/media/protocol/portaudio/PortAudioStream.java @@ -190,6 +190,8 @@ public void read(Buffer buffer) } catch (PortAudioException paex) { + PortAudio.printHostError(paex); + IOException ioex = new IOException(paex.getLocalizedMessage()); ioex.initCause(paex); @@ -259,6 +261,7 @@ synchronized void setDeviceIndex(int deviceIndex) logger.error( "Failed to close " + getClass().getSimpleName(), paex); + PortAudio.printHostError(paex); IOException ioex = new IOException(paex.getLocalizedMessage()); @@ -320,6 +323,7 @@ synchronized void setDeviceIndex(int deviceIndex) logger.error( "Failed to open " + getClass().getSimpleName(), paex); + PortAudio.printHostError(paex); IOException ioex = new IOException(paex.getLocalizedMessage()); @@ -408,6 +412,7 @@ public synchronized void start() catch (PortAudioException paex) { logger.error("Failed to start " + getClass().getSimpleName(), paex); + PortAudio.printHostError(paex); IOException ioex = new IOException(paex.getLocalizedMessage()); @@ -435,6 +440,7 @@ public synchronized void stop() catch (PortAudioException paex) { logger.error("Failed to stop " + getClass().getSimpleName(), paex); + PortAudio.printHostError(paex); IOException ioex = new IOException(paex.getLocalizedMessage()); 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 8bf84ae381d98c7f4de68e832bf4f31df715edaf..63e694d04bcefff4c660432ce62f8f860e213737 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 @@ -199,6 +199,7 @@ public synchronized void close() catch (PortAudioException paex) { logger.error("Failed to close PortAudio stream.", paex); + PortAudio.printHostError(paex); } } if ((stream == 0) && (outputParameters != 0)) @@ -448,6 +449,7 @@ private void doOpen() } catch (PortAudioException paex) { + PortAudio.printHostError(paex); throw new ResourceUnavailableException(paex.getMessage()); } finally @@ -543,6 +545,7 @@ public int process(Buffer buffer) catch (PortAudioException paex) { logger.error("Failed to process Buffer.", paex); + PortAudio.printHostError(paex); } finally { @@ -657,6 +660,7 @@ public synchronized void start() catch (PortAudioException paex) { logger.error("Failed to start PortAudio stream.", paex); + PortAudio.printHostError(paex); } } } @@ -679,6 +683,7 @@ public synchronized void stop() catch (PortAudioException paex) { logger.error("Failed to close PortAudio stream.", paex); + PortAudio.printHostError(paex); } } } diff --git a/src/org/jitsi/impl/neomedia/portaudio/PortAudioException.java b/src/org/jitsi/impl/neomedia/portaudio/PortAudioException.java index 22a1cdaa6b67121a8d9153fa5ccff735e9c97377..3802b992b515a11b873e92eefe2bc376d074afc9 100644 --- a/src/org/jitsi/impl/neomedia/portaudio/PortAudioException.java +++ b/src/org/jitsi/impl/neomedia/portaudio/PortAudioException.java @@ -6,6 +6,8 @@ */ package org.jitsi.impl.neomedia.portaudio; +import net.java.sip.communicator.impl.neomedia.portaudio.*; + /** * Implements <tt>Exception</tt> for the PortAudio capture and playback system. * @@ -19,6 +21,11 @@ public class PortAudioException */ private static final long serialVersionUID = 0L; + /** + * The host error info if any. + */ + private final PortAudioHostErrorInfo portAudioHostErrorInfo; + /** * Initializes a new <tt>PortAudioException</tt> instance with a specific * detail message. @@ -28,5 +35,36 @@ public class PortAudioException public PortAudioException(String message) { super(message); + + this.portAudioHostErrorInfo = null; + } + + /** + * Initializes a new <tt>PortAudioException</tt> instance with a specific + * detail message. + * + * @param message the detail message to initialize the new instance with + */ + public PortAudioException(String message, + int hostApiInfo, + long errorCode, + String errorText) + { + super(message); + + this.portAudioHostErrorInfo = + new PortAudioHostErrorInfo( + PortAudio.PaHostApiTypeId.valueOf(hostApiInfo), + errorCode, + errorText); + } + + /** + * Returns any host specific error info if any. + * @return any host specific error info if any. + */ + public PortAudioHostErrorInfo getPortAudioHostErrorInfo() + { + return portAudioHostErrorInfo; } } diff --git a/src/org/jitsi/impl/neomedia/portaudio/PortAudioHostErrorInfo.java b/src/org/jitsi/impl/neomedia/portaudio/PortAudioHostErrorInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..129985993adad9882da161818e6ab183bab8bb20 --- /dev/null +++ b/src/org/jitsi/impl/neomedia/portaudio/PortAudioHostErrorInfo.java @@ -0,0 +1,75 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jitsi.impl.neomedia.portaudio; + +import net.java.sip.communicator.impl.neomedia.portaudio.*; + +/** + * Represents PaHostErrorInfo from PortAudio. + * Return information about a host error condition. + * + * @author Damian Minkov + */ +public class PortAudioHostErrorInfo +{ + /** + * The host API which returned the error code. + */ + PortAudio.PaHostApiTypeId hostApiType; + + /** + * The error code returned. + */ + long errorCode; + + /** + * A textual description of the error if available, + * otherwise a zero-length string. + */ + String errorText; + + /** + * Constructs <tt>PortAudioHostErrorInfo</tt>. + * + * @param hostApiType the host API which returned the error code. + * @param errorCode the error code returned. + * @param errorText a textual description of the error if available. + */ + public PortAudioHostErrorInfo(PortAudio.PaHostApiTypeId hostApiType, long errorCode, String errorText) + { + this.hostApiType = hostApiType; + this.errorCode = errorCode; + this.errorText = errorText; + } + + /** + * The host API which returned the error code. + * @return the host API which returned the error code. + */ + public PortAudio.PaHostApiTypeId getHostApiType() + { + return hostApiType; + } + + /** + * The error code returned. + * @return the error code returned. + */ + public long getErrorCode() + { + return errorCode; + } + + /** + * A textual description of the error if available. + * @return a textual description of the error if available. + */ + public String getErrorText() + { + return errorText; + } +}