jdk/src/share/classes/sun/audio/AudioData.java
changeset 19369 1b53b14758ee
parent 18215 b2afd66ce6db
--- a/jdk/src/share/classes/sun/audio/AudioData.java	Fri Aug 16 20:56:46 2013 +0400
+++ b/jdk/src/share/classes/sun/audio/AudioData.java	Fri Aug 16 21:18:21 2013 +0400
@@ -26,6 +26,8 @@
 package sun.audio;
 
 import java.io.*;
+import java.util.Arrays;
+
 import javax.sound.sampled.*;
 
 
@@ -65,12 +67,11 @@
     /**
      * Constructor
      */
-    public AudioData(byte buffer[]) {
-
-        this.buffer = buffer;
-        // if we cannot extract valid format information, we resort to assuming the data will be 8k mono u-law
-        // in order to provide maximal backwards compatibility....
-        this.format = DEFAULT_FORMAT;
+    public AudioData(final byte[] buffer) {
+        // if we cannot extract valid format information, we resort to assuming
+        // the data will be 8k mono u-law in order to provide maximal backwards
+        // compatibility....
+        this(DEFAULT_FORMAT, buffer);
 
         // okay, we need to extract the format and the byte buffer of data
         try {
@@ -90,9 +91,10 @@
      * Non-public constructor; this is the one we use in ADS and CADS
      * constructors.
      */
-    AudioData(AudioFormat format, byte[] buffer) {
-
+    AudioData(final AudioFormat format, final byte[] buffer) {
         this.format = format;
-        this.buffer = buffer;
+        if (buffer != null) {
+            this.buffer = Arrays.copyOf(buffer, buffer.length);
+        }
     }
 }