Program: 75868
Project: 75868
Buggy source:
/** 
 * Play an array of audio samples. There will be a delay before the audio data is actually heard, since the audio data in <i>samplesArray</i> is queued to an internal audio buffer. The size of the internal buffer is set by the setTransferSize() method. A lower bound on the latency is given by (<i>bufferSize</i> / <i>sampleRate</i>) seconds. This method should be invoked often enough to prevent underflow of the internal audio buffer. Underflow is undesirable since it will cause audible gaps in audio playback, but no exception or error condition will occur. If the caller attempts to write more data than can be written, this method blocks until the data can be written to the internal audio buffer. <p> The samples should be in the range (-1,1). Samples that are outside ths range will be hard-clipped so that they fall within this range. <p> The first index of the specified array represents the channel number (0 for first channel, 1 for second channel, etc.). The number of channels is set by the setChannels() method. The second index represents the sample index within a channel. For example, putSamplesArray[n][m] contains the (m+1)th sample of the (n+1)th channel. samplesArray should be a rectangular array such that samplesArray.length() gives the number of channels and samplesArray[n].length() is equal to <i>samplesArray</i>, for all channels n. This is not actually checked, however. <p> Note that only the object with the exclusive lock on the playback audio resources is allowed to invoked this method. An exception will occur if the specifed object does not have the lock on the playback audio resources.
 * @param producer The object that has an exclusive lock onthe playback audio resources.
 * @param samplesArray A two dimensional array containingthe samples to play or write to a file.
 * @exception IOException If there is a problem playing audio.
 * @exception IllegalStateException If audio playback is currentlyinactive. That is, If startPlayback() has not yet been called or if stopPlayback() has already been called.
 */
public static void putSamples(Object producer,double[][] samplesArray) throws IOException, IllegalStateException {
  _data=_doubleArrayToByteArray(samplesArray,_bytesPerSample,_channels);
  _sourceLine.write(_data,0,_transferSize * _frameSizeInBytes);
}

Fixed version (ground truth):
/** 
 * Play an array of audio samples. There will be a delay before the audio data is actually heard, since the audio data in <i>samplesArray</i> is queued to an internal audio buffer. The size of the internal buffer is set by the setTransferSize() method. A lower bound on the latency is given by (<i>bufferSize</i> / <i>sampleRate</i>) seconds. This method should be invoked often enough to prevent underflow of the internal audio buffer. Underflow is undesirable since it will cause audible gaps in audio playback, but no exception or error condition will occur. If the caller attempts to write more data than can be written, this method blocks until the data can be written to the internal audio buffer. <p> The samples should be in the range (-1,1). Samples that are outside ths range will be hard-clipped so that they fall within this range. <p> The first index of the specified array represents the channel number (0 for first channel, 1 for second channel, etc.). The number of channels is set by the setChannels() method. The second index represents the sample index within a channel. For example, putSamplesArray[n][m] contains the (m+1)th sample of the (n+1)th channel. samplesArray should be a rectangular array such that samplesArray.length() gives the number of channels and samplesArray[n].length() is equal to <i>samplesArray</i>, for all channels n. This is not actually checked, however. <p> Note that only the object with the exclusive lock on the playback audio resources is allowed to invoked this method. An exception will occur if the specifed object does not have the lock on the playback audio resources.
 * @param producer The object that has an exclusive lock onthe playback audio resources.
 * @param samplesArray A two dimensional array containingthe samples to play or write to a file.
 * @exception IOException If there is a problem playing audio.
 * @exception IllegalStateException If audio playback is currentlyinactive. That is, If startPlayback() has not yet been called or if stopPlayback() has already been called.
 */
public static void putSamples(Object producer,double[][] samplesArray) throws IOException, IllegalStateException {
  if (_debug) {
    System.out.println("String_Node_Str");
    System.out.println("String_Node_Str" + "String_Node_Str" + _transferSize);
    System.out.println("String_Node_Str" + "String_Node_Str" + _bytesPerSample);
    System.out.println("String_Node_Str" + "String_Node_Str" + _channels);
  }
  _data=_doubleArrayToByteArray(samplesArray,_bytesPerSample,_channels);
  if (_debug) {
    System.out.println("String_Node_Str" + "String_Node_Str");
    System.out.println("String_Node_Str" + "String_Node_Str" + _data.length);
    System.out.println("String_Node_Str" + "String_Node_Str" + _transferSize);
    System.out.println("String_Node_Str" + "String_Node_Str" + _frameSizeInBytes);
  }
  _sourceLine.write(_data,0,_transferSize * _frameSizeInBytes);
  if (_debug) {
    System.out.println("String_Node_Str");
  }
}