AudioFormat audioFormat = new AudioFormat(8000, 16, 1, true, false);
private TargetDataLine targetDataLine;
private SourceDataLine sourceDataLine;
private Object sourceDataLineMutex;
private DataLine.Info targetInfo;
private DataLine.Info sourceInfo;
...
AccessController.doPrivileged(
new PrivilegedAction<Void>() {
@Override
public Void run() {
try {
targetDataLine = (TargetDataLine) AudioSystem.getLine(targetInfo);
targetDataLine.open(audioFormat);
} catch (LineUnavailableException e) {
logger.error("target line unavailable", e);
return null;
} catch (SecurityException e) {
logger.error("security exception", e);
return null;
} catch (Throwable t) {
logger.error("throwable " + t.getMessage());
return null;
}
targetDataLine.start();
synchronized (sourceDataLineMutex) {
try {
sourceDataLine = (SourceDataLine) AudioSystem.getLine(sourceInfo);
sourceDataLine.open(audioFormat);
} catch (LineUnavailableException e) {
logger.error("source line unavailable", e);
return null;
}
sourceDataLine.start();
}
return null;
}
});
Воспроизведение аудио работает нормально, но при попытке воспроизвести еще один файл получаю ексепшн ( targetDataLine.open(audioFormat); - в этом месте):
javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 8000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian not supported.
at com.sun.media.sound.DirectAudioDevice$DirectDL.implOpen(DirectAudioDevice.java:513)
at com.sun.media.sound.AbstractDataLine.open(AbstractDataLine.java:124)
at com.sun.media.sound.AbstractDataLine.open(AbstractDataLine.java:156)
at net.sourceforge.peers.javaxsound.JavaxSoundManager$1.run(JavaxSoundManager.java:106)
at net.sourceforge.peers.javaxsound.JavaxSoundManager$1.run(JavaxSoundManager.java:98)
at java.security.AccessController.doPrivileged(Native Method)
at net.sourceforge.peers.javaxsound.JavaxSoundManager.init(JavaxSoundManager.java:97)
at net.sourceforge.peers.media.MediaManager.successResponseReceived(MediaManager.java:98)
at net.sourceforge.peers.sip.core.useragent.handlers.InviteHandler.successResponseReceived(InviteHandler.java:547)
at net.sourceforge.peers.sip.transaction.InviteClientTransactionStateProceeding.received2xx(InviteClientTransactionStateProceeding.java:44)
at net.sourceforge.peers.sip.transaction.InviteClientTransaction.receivedResponse(InviteClientTransaction.java:154)
at net.sourceforge.peers.sip.transport.MessageReceiver.processMessage(MessageReceiver.java:184)
at net.sourceforge.peers.sip.transport.UdpMessageReceiver.listen(UdpMessageReceiver.java:85)
at net.sourceforge.peers.sip.transport.MessageReceiver.run(MessageReceiver.java:69)
at java.lang.Thread.run(Thread.java:722)
как обойти?