-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.3.0
-
generic, x86
-
generic, linux
Name: rlT66838 Date: 02/11/2000
java version "1.2.2"
Classic VM (build JDK-1.2.2-W, native threads, symcjit)
I believe that I found a bug in your CapturePlayback.java program.
(I am working with the version found in the demo/sound/src directory of jdk 1.3
release candidate 1; the source file says that this version is 1.11
The bug is in the run method, and the offending code block is
int numBytesRemaining = numBytesRead;
while (numBytesRemaining > 0) {
numBytesRemaining -= sourceDataLine.write(data, 0,
numBytesRemaining);
}
The bug is that the offset -- which you keep at a fixed value of 0 -- will
actually be changing should you have to execute the while loop more than once.
(The reason why you probably did not catch this bug is because the while loop
almost always needs to execute only once.)
Here is a code block which I believe will correct the problem:
int offset = 0;
int numBytesRemaining = numBytesRead;
while (numBytesRemaining > 0) {
int numBytesWrote = line.write(data, offset, numBytesRemaining);
numBytesRemaining -= numBytesWrote;
offset += numBytesWrote;
}
(Review ID: 101143)
======================================================================
Name: yyT116575 Date: 11/06/2000
[root@wlglap projects]# java -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)
run CapturePlayback and press the Record button.
The problem lies in the fact that getLine has a Line.Info argument;
Consequently, it cannot know if it needs a Source- or TargetDataLine.
It always returns the Source one first, so one cannot record.
This is also true for Mixer.getLine() .
It really needs a way to differentiate between Source and Target formats.
(Review ID: 111847)
======================================================================
java version "1.2.2"
Classic VM (build JDK-1.2.2-W, native threads, symcjit)
I believe that I found a bug in your CapturePlayback.java program.
(I am working with the version found in the demo/sound/src directory of jdk 1.3
release candidate 1; the source file says that this version is 1.11
The bug is in the run method, and the offending code block is
int numBytesRemaining = numBytesRead;
while (numBytesRemaining > 0) {
numBytesRemaining -= sourceDataLine.write(data, 0,
numBytesRemaining);
}
The bug is that the offset -- which you keep at a fixed value of 0 -- will
actually be changing should you have to execute the while loop more than once.
(The reason why you probably did not catch this bug is because the while loop
almost always needs to execute only once.)
Here is a code block which I believe will correct the problem:
int offset = 0;
int numBytesRemaining = numBytesRead;
while (numBytesRemaining > 0) {
int numBytesWrote = line.write(data, offset, numBytesRemaining);
numBytesRemaining -= numBytesWrote;
offset += numBytesWrote;
}
(Review ID: 101143)
======================================================================
Name: yyT116575 Date: 11/06/2000
[root@wlglap projects]# java -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)
run CapturePlayback and press the Record button.
The problem lies in the fact that getLine has a Line.Info argument;
Consequently, it cannot know if it needs a Source- or TargetDataLine.
It always returns the Source one first, so one cannot record.
This is also true for Mixer.getLine() .
It really needs a way to differentiate between Source and Target formats.
(Review ID: 111847)
======================================================================
- duplicates
-
JDK-6432318 JavaSoundDemo: make good examples to work with JavaSE 5.0+
-
- Open
-