8157753: Audio replay enhancement
authorserb
Tue, 28 Jun 2016 19:48:05 +0300
changeset 41566 f52207d194bf
parent 41565 31d2aac15a77
child 41567 10ed0e790b06
8157753: Audio replay enhancement Reviewed-by: amenkov, prr, mschoene
jdk/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_PCM.cpp
jdk/src/java.desktop/unix/native/libjsound/PLATFORM_API_BsdOS_ALSA_PCM.c
jdk/src/java.desktop/unix/native/libjsound/PLATFORM_API_LinuxOS_ALSA_PCM.c
jdk/src/java.desktop/unix/native/libjsound/PLATFORM_API_SolarisOS_PCM.c
jdk/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_DirectSound.cpp
--- a/jdk/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_PCM.cpp	Tue Jun 28 09:43:21 2016 -0700
+++ b/jdk/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_PCM.cpp	Tue Jun 28 19:48:05 2016 +0300
@@ -817,6 +817,10 @@
         ERROR1("<<DAUDIO_Open: ERROR: unsupported encoding (%d)\n", encoding);
         return NULL;
     }
+    if (channels <= 0) {
+        ERROR1("<<DAUDIO_Open: ERROR: Invalid number of channels=%d!\n", channels);
+        return NULL;
+    }
 
     OSX_DirectAudioDevice *device = new OSX_DirectAudioDevice();
 
--- a/jdk/src/java.desktop/unix/native/libjsound/PLATFORM_API_BsdOS_ALSA_PCM.c	Tue Jun 28 09:43:21 2016 -0700
+++ b/jdk/src/java.desktop/unix/native/libjsound/PLATFORM_API_BsdOS_ALSA_PCM.c	Tue Jun 28 19:48:05 2016 +0300
@@ -434,7 +434,10 @@
         snd_output_stdio_attach(&ALSA_OUTPUT, stdout, 0);
     }
 #endif
-
+    if (channels <= 0) {
+        ERROR1("ERROR: Invalid number of channels=%d!\n", channels);
+        return NULL;
+    }
     info = (AlsaPcmInfo*) malloc(sizeof(AlsaPcmInfo));
     if (!info) {
         ERROR0("Out of memory\n");
--- a/jdk/src/java.desktop/unix/native/libjsound/PLATFORM_API_LinuxOS_ALSA_PCM.c	Tue Jun 28 09:43:21 2016 -0700
+++ b/jdk/src/java.desktop/unix/native/libjsound/PLATFORM_API_LinuxOS_ALSA_PCM.c	Tue Jun 28 19:48:05 2016 +0300
@@ -434,7 +434,10 @@
         snd_output_stdio_attach(&ALSA_OUTPUT, stdout, 0);
     }
 #endif
-
+    if (channels <= 0) {
+        ERROR1("ERROR: Invalid number of channels=%d!\n", channels);
+        return NULL;
+    }
     info = (AlsaPcmInfo*) malloc(sizeof(AlsaPcmInfo));
     if (!info) {
         ERROR0("Out of memory\n");
--- a/jdk/src/java.desktop/unix/native/libjsound/PLATFORM_API_SolarisOS_PCM.c	Tue Jun 28 09:43:21 2016 -0700
+++ b/jdk/src/java.desktop/unix/native/libjsound/PLATFORM_API_SolarisOS_PCM.c	Tue Jun 28 19:48:05 2016 +0300
@@ -182,6 +182,10 @@
         ERROR1(" DAUDIO_Open: invalid encoding %d\n", (int) encoding);
         return NULL;
     }
+    if (channels <= 0) {
+        ERROR1(" DAUDIO_Open: Invalid number of channels=%d!\n", channels);
+        return NULL;
+    }
 
     info = (SolPcmInfo*) malloc(sizeof(SolPcmInfo));
     if (!info) {
--- a/jdk/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_DirectSound.cpp	Tue Jun 28 09:43:21 2016 -0700
+++ b/jdk/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_DirectSound.cpp	Tue Jun 28 19:48:05 2016 +0300
@@ -859,6 +859,10 @@
         ERROR1("DAUDIO_Open: ERROR: cannot open the device with encoding=%d!\n", encoding);
         return NULL;
     }
+    if (channels <= 0) {
+        ERROR1("DAUDIO_Open: ERROR: Invalid number of channels=%d!\n", channels);
+        return NULL;
+    }
     if (sampleSizeInBits > 8 &&
 #ifdef _LITTLE_ENDIAN
         isBigEndian