Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows

      Description

      FULL PRODUCT VERSION :
      Java HotSpot(TM) Client VM (25.144-b01) for windows-x86 JRE (1.8.0_144-b01)

      FULL OS VERSION :
      Windows 10.0 , 64 bit Build 15063 (10.0.15063.296)

      A DESCRIPTION OF THE PROBLEM :
      Internal exceptions (2 events):
      Event: 0.111 Thread 0x008ec000 Exception <a 'java/lang/NoSuchMethodError': Method sun.misc.Unsafe.defineClass(Ljava/lang/String;[BII)Ljava/lang/Class; name or signature does not match> (0x04406e98) thrown at [C:\workspace\8-2-build-windows-i586-cygwin\jdk8u144\9417\hotspot\src\share\vm
      Event: 0.111 Thread 0x008ec000 Exception <a 'java/lang/NoSuchMethodError': Method sun.misc.Unsafe.prefetchRead(Ljava/lang/Object;J)V name or signature does not match> (0x04407168) thrown at [C:\workspace\8-2-build-windows-i586-cygwin\jdk8u144\9417\hotspot\src\share\vm\prims\jni.cpp, li


      THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Did not try

      THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Did not try

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      #
      # A fatal error has been detected by the Java Runtime Environment:
      #
      # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x5e3add46, pid=5012, tid=0x000022d4
      #
      # JRE version: Java(TM) SE Runtime Environment (8.0_144-b01) (build 1.8.0_144-b01)
      # Java VM: Java HotSpot(TM) Client VM (25.144-b01 mixed mode windows-x86 )
      # Problematic frame:
      # V [jvm.dll+0xcdd46]
      #
      # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
      #
      # If you would like to submit a bug report, please visit:
      # http://bugreport.java.com/bugreport/crash.jsp
      #

      --------------- T H R E A D ---------------

      Current thread is native thread

      siginfo: ExceptionCode=0xc0000005, reading address 0x000000c8

      Registers:
      EAX=0x00000000, EBX=0x449b0278, ECX=0x003f9000, EDX=0x449b0448
      ESP=0x457cf6d8, EBP=0x457cf6f0, ESI=0x008ec000, EDI=0x449b0278
      EIP=0x5e3add46, EFLAGS=0x00010287

      Top of Stack: (sp=0x457cf6d8)
      0x457cf6d8: 008ec000 008ec000 449b0278 449b0278
      0x457cf6e8: 00000000 00000000 457cf704 5e35daab
      0x457cf6f8: 449b0278 008ec000 449b0250 457cf738
      0x457cf708: 0233ae2c 008ec000 449b0278 0233ae02
      0x457cf718: 457cf718 449b0250 457cf740 449b0448
      0x457cf728: 00000000 449b0278 00000000 457cf740
      0x457cf738: 457cf760 02330697 00000004 457cf76c
      0x457cf748: 5e43aa12 008ec000 00001f80 457cf954

      Instructions: (pc=0x5e3add46)
      0x5e3add26: 53 56 57 8b 7d 08 89 7d f4 c7 45 f8 00 00 00 00
      0x5e3add36: 85 ff 74 31 a1 d8 fe 63 5e 50 ff 15 fc 31 5a 5e
      0x5e3add46: 8b b0 c8 00 00 00 89 45 f8 8b 06 3b 46 04 75 08
      0x5e3add56: 50 8b ce e8 42 1b 08 00 8b 06 8b 56 10 8d 48 01


      Register to memory mapping:

      EAX=0x00000000 is an unknown value
      EBX={method} {0x449b027c} 'test' '(I)V' in 'com/all/sndandlgjni/SndanDlgCpp'
      ECX=0x003f9000 is an unknown value
      EDX=0x449b0448 is pointing into metadata
      ESP=0x457cf6d8 is an unknown value
      EBP=0x457cf6f0 is an unknown value
      ESI=0x008ec000 is a thread
      EDI={method} {0x449b027c} 'test' '(I)V' in 'com/all/sndandlgjni/SndanDlgCpp'


      Stack: [0x45780000,0x457d0000], sp=0x457cf6d8, free space=317k
      Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
      V [jvm.dll+0xcdd46]
      V [jvm.dll+0x7daab]
      j com.all.sndandlgjni.SndanDlgCpp.test(I)V+0
      v ~StubRoutines::call_stub
      V [jvm.dll+0x15af45]
      V [jvm.dll+0x2213ae]
      V [jvm.dll+0x15afde]
      V [jvm.dll+0xdcb97]
      V [jvm.dll+0xe5283]
      C [WaveRecorderToJava.dll+0x1a1a] JNIEnv_::CallStaticVoidMethod+0x1a
      C [WaveRecorderToJava.dll+0x26fe] waveInProc+0x61e
      C [winmmbase.dll+0xd877]
      C [msacm32.drv+0x18fa]
      C [msacm32.drv+0x1c40]
      C [winmmbase.dll+0xd877]
      C [wdmaud.drv+0xb59b]
      C [wdmaud.drv+0x7b7e]
      C [wdmaud.drv+0x781c]
      C [KERNEL32.DLL+0x18744]
      C [ntdll.dll+0x6582d]
      C [ntdll.dll+0x657fd]


      --------------- P R O C E S S ---------------

      VM state:not at safepoint (normal execution)

      VM Mutex/Monitor currently owned by a thread: None

      Heap:
       def new generation total 4928K, used 1113K [0x04400000, 0x04950000, 0x19950000)
        eden space 4416K, 25% used [0x04400000, 0x045165d0, 0x04850000)
        from space 512K, 0% used [0x04850000, 0x04850000, 0x048d0000)
        to space 512K, 0% used [0x048d0000, 0x048d0000, 0x04950000)
       tenured generation total 10944K, used 0K [0x19950000, 0x1a400000, 0x44400000)
         the space 10944K, 0% used [0x19950000, 0x19950000, 0x19950200, 0x1a400000)
       Metaspace used 2054K, capacity 2312K, committed 2368K, reserved 4480K

      Card table byte_map: [0x44400000,0x44610000] byte_map_base: 0x443de000

      Polling page: 0x00930000

      CodeCache: size=32768Kb used=705Kb max_used=705Kb free=32062Kb
       bounds [0x02330000, 0x023e8000, 0x04330000]
       total_blobs=168 nmethods=27 adapters=73
       compilation: enabled

      Compilation events (10 events):
      Event: 0.227 Thread 0x44c09000 23 java.lang.String::replace (127 bytes)
      Event: 0.227 Thread 0x44c09000 nmethod 23 0x023de288 code [0x023de3a0, 0x023de620]
      Event: 0.337 Thread 0x44c09000 24 java.lang.Math::min (11 bytes)
      Event: 0.337 Thread 0x44c09000 nmethod 24 0x023de888 code [0x023de980, 0x023de9f0]
      Event: 0.342 Thread 0x44c09000 25 java.lang.String::startsWith (72 bytes)
      Event: 0.343 Thread 0x44c09000 nmethod 25 0x023dea48 code [0x023deb50, 0x023dec80]
      Event: 0.343 Thread 0x44c09000 26 sun.nio.cs.UTF_8$Encoder::encode (359 bytes)
      Event: 0.343 Thread 0x44c09000 nmethod 26 0x023dedc8 code [0x023def10, 0x023df358]
      Event: 0.343 Thread 0x44c09000 27 sun.net.www.ParseUtil::encodePath (336 bytes)
      Event: 0.344 Thread 0x44c09000 nmethod 27 0x023df848 code [0x023df9f0, 0x023e00b8]

      GC Heap History (0 events):
      No events

      Deoptimization events (0 events):
      No events

      Internal exceptions (2 events):
      Event: 0.111 Thread 0x008ec000 Exception <a 'java/lang/NoSuchMethodError': Method sun.misc.Unsafe.defineClass(Ljava/lang/String;[BII)Ljava/lang/Class; name or signature does not match> (0x04406e98) thrown at [C:\workspace\8-2-build-windows-i586-cygwin\jdk8u144\9417\hotspot\src\share\vm
      Event: 0.111 Thread 0x008ec000 Exception <a 'java/lang/NoSuchMethodError': Method sun.misc.Unsafe.prefetchRead(Ljava/lang/Object;J)V name or signature does not match> (0x04407168) thrown at [C:\workspace\8-2-build-windows-i586-cygwin\jdk8u144\9417\hotspot\src\share\vm\prims\jni.cpp, li

      Events (10 events):
      Event: 0.344 loading class com/all/sndsepa/annot/impl/IdImpl
      Event: 0.344 loading class com/all/sndsepa/annot/impl/IdImpl done
      Event: 0.345 loading class java/util/TreeSet
      Event: 0.345 loading class java/util/NavigableSet
      Event: 0.345 loading class java/util/NavigableSet done
      Event: 0.345 loading class java/util/TreeSet done
      Event: 0.345 loading class com/all/sndandlgjni/SndanDlgCpp
      Event: 0.345 loading class com/all/sndandlgjni/SndanDlgCpp done
      Event: 4.195 Executing VM operation: EnableBiasedLocking
      Event: 4.195 Executing VM operation: EnableBiasedLocking done


      Dynamic libraries:
      0x008f0000 - 0x00923000 C:\Program Files (x86)\Java\jdk1.8.0_144\bin\java.exe
      0x77460000 - 0x775ee000 C:\WINDOWS\SYSTEM32\ntdll.dll
      0x75770000 - 0x75840000 C:\WINDOWS\System32\KERNEL32.DLL
      0x74f00000 - 0x750c2000 C:\WINDOWS\System32\KERNELBASE.dll
      0x73220000 - 0x732b3000 C:\WINDOWS\SYSTEM32\apphelp.dll
      0x756f0000 - 0x75767000 C:\WINDOWS\System32\ADVAPI32.dll
      0x74150000 - 0x7420d000 C:\WINDOWS\System32\msvcrt.dll
      0x74450000 - 0x74491000 C:\WINDOWS\System32\sechost.dll
      0x77160000 - 0x77220000 C:\WINDOWS\System32\RPCRT4.dll
      0x73f30000 - 0x73f50000 C:\WINDOWS\System32\SspiCli.dll
      0x73f20000 - 0x73f2a000 C:\WINDOWS\System32\CRYPTBASE.dll
      0x74ce0000 - 0x74d37000 C:\WINDOWS\System32\bcryptPrimitives.dll
      0x742f0000 - 0x7442c000 C:\WINDOWS\System32\USER32.dll
      0x75840000 - 0x75856000 C:\WINDOWS\System32\win32u.dll
      0x745c0000 - 0x745e1000 C:\WINDOWS\System32\GDI32.dll
      0x750d0000 - 0x75228000 C:\WINDOWS\System32\gdi32full.dll
      0x75230000 - 0x752a9000 C:\WINDOWS\System32\msvcp_win.dll
      0x75300000 - 0x75418000 C:\WINDOWS\System32\ucrtbase.dll
      0x73bc0000 - 0x73dce000 C:\WINDOWS\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.15063.483_none_6dad63fefc436da8\COMCTL32.dll
      0x77220000 - 0x77458000 C:\WINDOWS\System32\combase.dll
      0x75430000 - 0x75455000 C:\WINDOWS\System32\IMM32.DLL
      0x697f0000 - 0x698af000 C:\Program Files (x86)\Java\jdk1.8.0_144\jre\bin\msvcr100.dll
      0x5e2e0000 - 0x5e6ae000 C:\Program Files (x86)\Java\jdk1.8.0_144\jre\bin\client\jvm.dll
      0x74500000 - 0x74506000 C:\WINDOWS\System32\PSAPI.DLL
      0x73990000 - 0x73998000 C:\WINDOWS\SYSTEM32\VERSION.dll
      0x72c40000 - 0x72c48000 C:\WINDOWS\SYSTEM32\WSOCK32.dll
      0x73650000 - 0x73674000 C:\WINDOWS\SYSTEM32\WINMM.dll
      0x74d40000 - 0x74da7000 C:\WINDOWS\System32\WS2_32.dll
      0x73580000 - 0x735a3000 C:\WINDOWS\SYSTEM32\winmmbase.dll
      0x74220000 - 0x74259000 C:\WINDOWS\System32\cfgmgr32.dll
      0x6b010000 - 0x6b01c000 C:\Program Files (x86)\Java\jdk1.8.0_144\jre\bin\verify.dll
      0x6aaa0000 - 0x6aac1000 C:\Program Files (x86)\Java\jdk1.8.0_144\jre\bin\java.dll
      0x6a630000 - 0x6a643000 C:\Program Files (x86)\Java\jdk1.8.0_144\jre\bin\zip.dll
      0x75860000 - 0x76ba8000 C:\WINDOWS\System32\SHELL32.dll
      0x75460000 - 0x754ec000 C:\WINDOWS\System32\shcore.dll
      0x746e0000 - 0x74c64000 C:\WINDOWS\System32\windows.storage.dll
      0x73f50000 - 0x73f95000 C:\WINDOWS\System32\shlwapi.dll
      0x75420000 - 0x7542e000 C:\WINDOWS\System32\kernel.appcore.dll
      0x74570000 - 0x745b5000 C:\WINDOWS\System32\powrprof.dll
      0x74040000 - 0x74050000 C:\WINDOWS\System32\profapi.dll
      0x69f00000 - 0x69f2d000 I:\kgy\CNTAN\gyozo_sndan_dialog_jni\Release\soundAn\Jars\WaveRecorderToJava.dll
      0x69f70000 - 0x69fc9000 C:\WINDOWS\SYSTEM32\MMDevAPI.DLL
      0x6fa40000 - 0x6fa62000 C:\WINDOWS\SYSTEM32\DEVOBJ.dll
      0x72980000 - 0x72ae4000 C:\WINDOWS\SYSTEM32\PROPSYS.dll
      0x73fa0000 - 0x74036000 C:\WINDOWS\System32\OLEAUT32.dll
      0x69c40000 - 0x69c79000 C:\WINDOWS\SYSTEM32\wdmaud.drv
      0x72bc0000 - 0x72bc9000 C:\WINDOWS\SYSTEM32\AVRT.dll
      0x6ac50000 - 0x6ac57000 C:\WINDOWS\SYSTEM32\ksuser.dll
      0x69710000 - 0x697e7000 C:\WINDOWS\SYSTEM32\AUDIOSES.DLL
      0x6e250000 - 0x6e321000 C:\WINDOWS\SYSTEM32\wintypes.dll
      0x6a990000 - 0x6a99a000 C:\WINDOWS\SYSTEM32\msacm32.drv
      0x73b20000 - 0x73b38000 C:\WINDOWS\SYSTEM32\MSACM32.dll
      0x69ef0000 - 0x69ef8000 C:\WINDOWS\SYSTEM32\midimap.dll
      0x74260000 - 0x742e3000 C:\WINDOWS\System32\clbcatq.dll
      0x6fed0000 - 0x7002d000 C:\WINDOWS\SYSTEM32\dbghelp.dll

      VM Arguments:
      jvm_args: -Xmx1g
      java_command: com.all.sndandlgjni.SndanDlgApp
      java_class_path (initial): ..\soundAn\Jars\sndan_dlg_jni.jar;Jars\alldioutil.jar;..\ASR\Jars\m_asr_2.jar;..\ASR\Jars\meet2txt_asr.jar
      Launcher Type: SUN_STANDARD

      Environment Variables:
      CLASSPATH=.;.;C:\PROGRA~2\JMF21~1.1E\lib\sound.jar;C:\PROGRA~2\JMF21~1.1E\lib\jmf.jar;C:\PROGRA~2\JMF21~1.1E\lib;
      PATH=C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;I:\Program Files\MATLAB\R2016b\runtime\win64;I:\Program Files\MATLAB\R2016b\bin;I:\Program Files\MATLAB\R2016b\polyspace\bin;C:\Program Files\PuTTY\;C:\Program Files (x86)\Java\jdk1.8.0_144\jre\bin\client;C:\Users\b\AppData\Local\Microsoft\WindowsApps;
      USERNAME=b
      OS=Windows_NT
      PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 60 Stepping 3, GenuineIntel



      --------------- S Y S T E M ---------------

      OS: Windows 10.0 , 64 bit Build 15063 (10.0.15063.296)

      CPU:total 8 (initial active 8) (4 cores per cpu, 2 threads per core) family 6 model 60 stepping 3, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, avx2, aes, clmul, erms, lzcnt, ht, tsc, tscinvbit, bmi1, bmi2

      Memory: 4k page, physical 8294184k(5198136k free), swap 9604904k(6611484k free)

      vm_info: Java HotSpot(TM) Client VM (25.144-b01) for windows-x86 JRE (1.8.0_144-b01), built on Jul 21 2017 21:58:05 by "java_re" with MS VC++ 10.0 (VS2010)

      time: Thu Aug 17 12:26:28 2017
      elapsed time: 5 seconds (0d 0h 0m 5s)



      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      JAVA source code:

      package com.all.sndandlgjni;

      import static com.all.sndsepa.com.SndSepUtils.*;

      public class SndanDlgCpp {

      private long sliceLen;

        static {
         try {
      //Path source = new File(wrkDir + "..\\soundAn\\Jars\\WaveRecorderToJava.dll").toPath();
      //Path target = new File("C:\\ProgramData\\Oracle\\Java\\javapath\\WaveRecorderToJava.dll").toPath();
      //Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
      //System.loadLibrary("WaveRecorderToJava");
        
      System.load(wrkDir + "\\..\\soundAn\\Jars\\WaveRecorderToJava.dll");
         } catch(Exception sec) {
         sec.printStackTrace();
         }
        }

        SndanDlgCpp(long auLen) {
         sliceLen = auLen;
        }
        
        public native void initCppSide(int audioLen);
        
        //public void addWavSzelet(byte[] wavSzelet) {
        public static void test(int vmi) {
         printLog("test - arrived any sound slice in length is: " + vmi);
        }

        
        //public void addWavSzelet(byte[] wavSzelet) {
        public void addWavSzelet() {
        
         //printLog("addWavSzelet - arrived any sound slice in length " + wavSzelethosz + " byte!");
         printLog("addWavSzelet - arrived any sound slice in length ");
        
        } //addWavSlice()

      } // class SndanDlgCpp



      ************************************************************************
      VSC++ source code:
      // WaveRecorderToStream.cpp : Defines the entry point for the DLL.
      //

      #include <Windows.h>
      #include <stdlib.h>
      #include <mmsystem.h>
      #include <cstdlib>
      #include <commdlg.h>
      #include <stdio.h>
      #include <string>
      #include <iostream>
      #include <fstream>
      #include <sys/types.h>
      #include <sys/timeb.h>

      #include<jni.h>
      #include "com_all_sndandlgjni_SndanDlgCpp.h"

      #pragma comment(lib, "winmm.lib")

      using namespace std;

      MMCKINFO ckRIFF, ckFMT, ckDATA;
      //wchar_t outF1[70], outFp[70] = L"./";
      wchar_t outF1[370], outFp[370] = L"./";

      struct _timeb timebuffer;

      HWAVEIN hWaveIn;
      MMRESULT result;
      WAVEHDR WaveInHdr1, WaveInHdr2, *WaveInHdr;
      boolean fordito = 1;
      wchar_t s[82];
      //char p[15], q[5], hx[5];
      int fileIdx = 1;
      short *waveIn1, *waveIn2;
      WAVEFORMATEX pFormat;

      //for java communications
      JNIEnv *currentJVMenv;
      jobject currJavaObj;
      DWORD sliceLen = 5;
      jmethodID currMethID;
      jclass currClas;

      //void SaveWAVFile(LPWSTR lpszPathName, HPSTR pSound, LONG cbSound, WAVEFORMATEX pWfx, LONG cbWfx);

      void CALLBACK waveInProc(HWAVEIN hWaveIn, UINT message, DWORD dwInstance, DWORD wParam, DWORD lParam);

      //tcpipClient tcpipc;


      //int main() { //for DLL
      //int main(int argc, char *argv[], char *envp[]) {
      int wmain(int argc, wchar_t *argv[], wchar_t *envp[]) {

        /*JavaVM *jvm = new JavaVM(); // denotes a Java VM
        JNIEnv *env = new JNIEnv(); // pointer to native method interface
        JavaVMInitArgs vm_args; // JDK/JRE 6 VM initialization arguments
        JavaVMOption options[3];

        options[0].optionString = "-Djava.compiler=NONE"; // disable JIT
        options[0].extraInfo = nullptr;
        //options[1].optionString = "-Djava.class.path=I:\\kgy\\CNTAN\\gyozo_sndan_dialog_jni\\Release\\soundAn\\Jars\\sndan_dlg_jni.jar"; // user classes
        options[1].optionString = "-Djava.class.path=I:/kgy/CNTAN/gyozo_sndan_dialog_jni/Release/soundAn/Jars/sndan_dlg_jni.jar;I:/kgy/CNTAN/gyozo_sndan_dialog_jni/Release/ASR/Jars/m_asr_2.jar;I:/kgy/CNTAN/gyozo_sndan_dialog_jni/Release/ASR/Jars/meet2txt_asr.jar"; // user classes
        options[1].extraInfo = nullptr;
        //options[2].optionString = "-Djava.library.path=\\usr\\lib\\java"; // set native library path
        options[2].optionString = "-verbose:jni"; // print JNI-related messages
        options[2].extraInfo = nullptr;

        vm_args.version = JNI_VERSION_1_8;
        vm_args.nOptions = 3;
        vm_args.options = options;
        vm_args.ignoreUnrecognized = JNI_TRUE; // remove unrecognized options

        // load and initialize a Java VM, return a JNI interface pointer in env
        int ret = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
        // invoke the Main.test method using the JNI
        jclass clsa = env->FindClass("com/all/sndandlgjni/SndanDlgCpp");
        jclass clsb = env->FindClass("com/all/sndandlgjni/SndanDlgApp");
        jclass clsc = env->FindClass("com/all/sndandlgjni/SndanDlg");
        jclass clsd = env->FindClass("com/all/sndandlgjni/Kivetito");
        jmethodID mid = env->GetStaticMethodID(clsa, "test", "(I)V");
        env->CallStaticVoidMethod(clsa, mid, 100);
        // We are done.
        jvm->DestroyJavaVM();
        delete options; */




        //DWORD sliceLen = 5;

        /*if(argc == 2) { sliceLen = _wtoi(argv[1]); }
        if(argc == 3) {
          sliceLen = _wtoi(argv[1]);
          fileIdx = _wtoi(argv[2]);
        }
        if (argc < 4) {
          wcerr << "WavRec - WaveRecorderToStream <length in sec> <start file index> <path toresult file> !" << endl;
        } else {
          sliceLen = _wtoi(argv[1]);
          fileIdx = _wtoi(argv[2]);
          wcscpy_s(outFp, argv[3]);
        }*/
        
        /*int ret = tcpipc.init_tcpipClient(); //set the server
        if(ret == 0) { ret = tcpipc.start_tcpipClient(); } //connect to server
        if(ret != 0) {
          wcerr << "WavRec - We can't connects to server" << endl;
          return 1957;
        }*/

      wcerr << L"WaveRecorderToJava - in wmain(0)!" << endl;

        // Creating 'RIFF' and 'WAVE' chunks
      ckRIFF.fccType = mmioFOURCC('W', 'A', 'V', 'E');
      ckRIFF.cksize = 0L;
      ckRIFF.dwFlags = MMIO_DIRTY;

      // Creating 'fmt ' chunk
      ckFMT.ckid = mmioFOURCC('f', 'm', 't', ' ');
      ckFMT.cksize = 0L;
      ckFMT.dwFlags = MMIO_DIRTY;

      // Creating 'data' chunk
      ckDATA.ckid = mmioFOURCC('d', 'a', 't', 'a');
      ckDATA.cksize = 0L;
      ckDATA.dwFlags = MMIO_DIRTY;

      int sampleRate = 16000;
      const int NUMPTS = sampleRate * sliceLen;
      waveIn1 = new short[NUMPTS];
      waveIn2 = new short[NUMPTS];

      pFormat.wFormatTag = WAVE_FORMAT_PCM;
      pFormat.nChannels = 1;
      pFormat.nSamplesPerSec = sampleRate;
      pFormat.nAvgBytesPerSec = 2 * sampleRate;
      pFormat.nBlockAlign = 2;
      pFormat.wBitsPerSample = 16;
      pFormat.cbSize = 0;

      wcerr << L"WaveRecorderToJava - in wmain(1)!" << endl;
        
        result = waveInOpen(&hWaveIn, WAVE_MAPPER, &pFormat, (DWORD)&waveInProc, 0, WAVE_FORMAT_DIRECT + CALLBACK_FUNCTION);

        
      wcerr << L"WaveRecorderToJava - in wmain(2)!" << endl;
        
        if(result) {
      wcerr << L"WaveRecorderToJava - in wmain(3)!" << endl;
          char fault[256];
      waveInGetErrorTextA(result, fault, 256);
      wcerr << "WavRec - Failed to open the sound adapter : " << fault << endl;
      return 1;
      }

      wcerr << L"WaveRecorderToJava - in wmain(4)!" << endl;

      WaveInHdr1.lpData = (LPSTR)waveIn1;
      WaveInHdr1.dwBufferLength = 2 * NUMPTS;
      WaveInHdr1.dwBytesRecorded = 0;
      WaveInHdr1.dwUser = 0;
      WaveInHdr1.dwFlags = 0;
      WaveInHdr1.dwLoops = 0;
      waveInPrepareHeader(hWaveIn, &WaveInHdr1, sizeof(WAVEHDR));

      wcerr << L"WaveRecorderToJava - in wmain(5)!" << endl;


      WaveInHdr2.lpData = (LPSTR)waveIn2;
      WaveInHdr2.dwBufferLength = 2 * NUMPTS;
      WaveInHdr2.dwBytesRecorded = 0;
      WaveInHdr2.dwUser = 0;
      WaveInHdr2.dwFlags = 0;
      WaveInHdr2.dwLoops = 0;
      waveInPrepareHeader(hWaveIn, &WaveInHdr2, sizeof(WAVEHDR));

      wcerr << L"WaveRecorderToJava - in wmain(6)!" << endl;

      //recording of 1st slice
      result = waveInAddBuffer(hWaveIn, &WaveInHdr1, sizeof(WAVEHDR));
      result = waveInStart(hWaveIn);
      if(result) { wcerr << L"WavRec - Failed to start recording!" << endl; return 1; }

      wcerr << L"WaveRecorderToJava - in wmain(7)!" << endl;

      _ftime_s(&timebuffer);
      swprintf_s(s, (size_t)82, L"WavRec - %d. record start time stamp : %I64d sec, %hu millisec", fileIdx, timebuffer.time, timebuffer.millitm);
      wcerr << s << endl;

      wcerr << L"WaveRecorderToJava - in wmain(8)!" << endl;

      while(true) { Sleep(sampleRate); }

      waveInUnprepareHeader(hWaveIn, &WaveInHdr1, sizeof(WAVEHDR));
      waveInUnprepareHeader(hWaveIn, &WaveInHdr2, sizeof(WAVEHDR));
      waveInClose(hWaveIn);
      delete waveIn1;
      delete waveIn2;

      return 0;
      } // wmain()

      /*****************************************
       * lpszPathName - Pathname of file
       * pSound - Pointer to sound buffer
       * cbSound - size in bytes of sound buffer
       * pWfx - pointer to WAVEFORMATEX structure
       * cbWfx - size of this structure
       */
      void SaveWAVFile(LPWSTR lpszPathName, HPSTR pSound, LONG cbSound, WAVEFORMATEX pWfx, LONG cbWfx)
      {
      MMIOINFO mmioinfo;
      HMMIO hmmio;

      ::ZeroMemory(&mmioinfo, sizeof(mmioinfo));

      hmmio = mmioOpen((LPWSTR)lpszPathName, &mmioinfo, MMIO_WRITE | MMIO_CREATE);

      if (hmmio == NULL) { wcerr << L"WavRec - mmioOpen returns NULL (" << (lpszPathName) << L")" << endl; }

      // Creating 'RIFF' and 'WAVE' chunks
      mmioCreateChunk(hmmio, &ckRIFF, MMIO_CREATERIFF);

      // Creating 'fmt ' chunk
      mmioCreateChunk(hmmio, &ckFMT, 0);
      mmioWrite(hmmio, (HPSTR)&pWfx, cbWfx);

      // Goto to 'WAVE' chunk and update 'fmt ' chunk size
      mmioAscend(hmmio, &ckFMT, 0);

      mmioCreateChunk(hmmio, &ckDATA, 0);
      mmioWrite(hmmio, (HPSTR)pSound, cbSound);

      // Goto to 'WAVE' chunk and update 'data' chunk size
      mmioAscend(hmmio, &ckDATA, 0);

      // Goto to 'RIFF' chunk and update 'WAVE' chunk size
      mmioAscend(hmmio, &ckRIFF, 0);
      mmioClose(hmmio, 0);
      } //SaveWAVFile()

      void CALLBACK waveInProc(HWAVEIN hWaveIn, UINT message, DWORD dwInstance, DWORD wParam, DWORD lParam) {
      if(message == WIM_DATA) {
      wcerr << L"WaveRecorderToJava - in waveInProc(0)!" << endl;

          //int csak_teszt;
          //byte b, d;
      _ftime_s(&timebuffer);
      swprintf_s(s, (size_t)82, L"WavRec - %d. record end time stamp : %I64d sec, %hu millisec", fileIdx++, timebuffer.time, timebuffer.millitm);
          wcerr << s << endl;
          
      wcerr << L"WaveRecorderToJava - in waveInProc(1)!" << endl;

      if(fordito) {
      result = waveInAddBuffer(hWaveIn, &WaveInHdr2, sizeof(WAVEHDR));
      result = waveInStart(hWaveIn);
      WaveInHdr = &WaveInHdr1;
      } else {
      result = waveInAddBuffer(hWaveIn, &WaveInHdr1, sizeof(WAVEHDR));
      result = waveInStart(hWaveIn);
      WaveInHdr = &WaveInHdr2;
      }
      if (result) { wcerr << L"WavRec - Failed to start recording!" << endl; return; }

      wcerr << L"WaveRecorderToJava - in waveInProc(2)!" << endl;


      fordito = !fordito;

      _ftime_s(&timebuffer);
      swprintf_s(s, (size_t)82, L"WavRec - %d. record start time stamp : %I64d sec, %hu millisec", fileIdx, timebuffer.time, timebuffer.millitm);
      wcerr << s << endl;

      wcerr << L"WaveRecorderToJava - in waveInProc(3)!" << endl;

      if (WaveInHdr->dwBytesRecorded > 0) {
            //send name of made sound file as message to the investigation
            swprintf_s(s, (size_t)82, L"Readed sound slice in byte length:%lu", WaveInHdr->dwBytesRecorded);
            //swprintf_s(s, (size_t)82, L"OnlineInputStream length:%lu", 32*1000);
            wcerr << s << endl;

      wcerr << L"WaveRecorderToJava - in waveInProc(4a)! (currentJVMenv != null): " << (currentJVMenv != NULL) << endl;
      wcerr << L"WaveRecorderToJava - in waveInProc(4b)! (currJavaObj != null): " << (currJavaObj != NULL) << endl;
      wcerr << L"WaveRecorderToJava - in waveInProc(4c)! (currMethID != null): " << (currMethID != NULL) << endl;

            //currentJVMenv->CallVoidMethod(currJavaObj, currMethID, WaveInHdr->lpData);
            try {
              wcerr << L"WaveRecorderToJava - in waveInProc(4d) in try{}!" << endl;
              currentJVMenv->CallStaticVoidMethod(currClas, currMethID, 4);
            } catch(exception *e) {
              wcerr << L"WaveRecorderToJava - in waveInProc(4e) Exception in try{}!" << endl;
              string excm(e->what());
              wcerr << L"Exception: " + wstring(excm.begin(), excm.end()) << endl;
            }

      wcerr << L"WaveRecorderToJava - in waveInProc(5)!" << endl;

       
            WaveInHdr->dwBytesRecorded = 0;
      }
      }
      } //waveInProc()


      JNIEXPORT void JNICALL Java_com_all_sndandlgjni_SndanDlgCpp_initCppSide(JNIEnv *cJVM, jobject jObj, jint auLn) {
        currentJVMenv = cJVM;
        currJavaObj = jObj;
        sliceLen = auLn;

        /*/readed sound sending to the java side
        JNI megvalosítas
        http://www.developer.com/java/data/getting-started-with-jni.html
        http://docs.oracle.com/javase/6/docs/technotes/guides/jni/spec/invocation.html#wp9502
        http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/functions.html

        https://stackoverflow.com/questions/1086596/how-to-access-arrays-within-an-object-with-jni
        */
        currClas = currentJVMenv->GetObjectClass(currJavaObj);
        //currMethID = currentJVMenv->GetMethodID(currClas, "addWavSzelet", "([B)V");
        //currMethID = currentJVMenv->GetMethodID(currClas, "addWavSzelet", "()V");
        currMethID = currentJVMenv->GetStaticMethodID(currClas, "test", "(I)V");

        wcerr << L"WaveRecorderToJava - in Java_com_all_sndandlgjni_SndanDlgCpp_initCppSide! (currMethID != null): " << (currMethID != NULL) << endl;

        wmain(0, nullptr, nullptr);
       
      }

      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            • Assignee:
              fmatte Fairoz Matte
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: