deep-c-rsc/JCGO/examples/jdk13_JavaSound-src.diff
2021-07-16 17:12:20 -05:00

38 lines
1.7 KiB
Diff

diff -ruN original/CapturePlayback.java modified/CapturePlayback.java
--- original/CapturePlayback.java 2007-01-18 13:15:04.000000000 +0400
+++ modified/CapturePlayback.java 2009-07-12 00:19:56.000000000 +0400
@@ -138,6 +138,7 @@
samplingGraph.start();
captB.setEnabled(false);
pausB.setEnabled(true);
+ pausB.setText("Pause");
playB.setText("Stop");
} else {
playback.stop();
@@ -158,6 +159,7 @@
auB.setEnabled(false);
aiffB.setEnabled(false);
waveB.setEnabled(false);
+ pausB.setText("Pause");
captB.setText("Stop");
} else {
lines.removeAllElements();
@@ -229,7 +231,8 @@
try {
this.file = file;
errStr = null;
- audioInputStream = AudioSystem.getAudioInputStream(file);
+ audioInputStream = AudioSystem.getAudioInputStream(
+ new BufferedInputStream(new FileInputStream(file)));
playB.setEnabled(true);
fileName = file.getName();
long milliseconds = (long)((audioInputStream.getFrameLength() * 1000) / audioInputStream.getFormat().getFrameRate());
@@ -385,6 +388,7 @@
}
int numBytesRemaining = numBytesRead;
while (numBytesRemaining > 0 ) {
+ if (!line.isOpen()) break;
numBytesRemaining -= line.write(data, 0, numBytesRemaining);
}
} catch (Exception e) {