12-29-2010 05:19 PM
Sorry. Can't do much more help for you right now. Seems it made it further than last time!?, although all the times are longer than your tick duration so thats no good
12-29-2010 06:28 PM - edited 12-29-2010 06:28 PM
Well I tried a very skinny version of my (rather large) program, with only the sampling of wave-in
Guess what? the error is gone!
Thing is, in my whole program if I leave just the sampling part out, the error is gone too!
Someone can make any chocolate out of this??!?!
12-29-2010 07:14 PM
I slimmed the code down as small as possible, still having the error...
The (entire) c code is now:
#include <windows.h> #include <MMSystem.h> #include "laser.h" #define SAMPLE_RATE 44100 #define NUMPTS (int)(SAMPLE_RATE * 0.015) short int waveIn[NUMPTS]; // 'short int' is a 16-bit type; I request 16-bit samples below HWAVEIN hWaveIn; WAVEFORMATEX pFormat; UINT numDevs; WAVEINCAPS devCaps; WAVEHDR WaveInHdr; MMRESULT result; int panel; int WINAPI WinMain(HINSTANCE hInstance, // handle to current instance HINSTANCE hPrevInstance, // handle to previous instance LPSTR lpCmdLine, // pointer to command line int nCmdShow) // show state of window { // Specify recording parameters pFormat.wFormatTag=WAVE_FORMAT_PCM; // simple, uncompressed format pFormat.nChannels=1; // 1=mono, 2=stereo pFormat.nSamplesPerSec=SAMPLE_RATE; // 44100 pFormat.nAvgBytesPerSec=SAMPLE_RATE*2; // = nSamplesPerSec * n.Channels * wBitsPerSample/8 pFormat.nBlockAlign=2; // = n.Channels * wBitsPerSample/8 pFormat.wBitsPerSample=16; // 16 for high quality, 8 for telephone-grade pFormat.cbSize=0; waveInOpen(&hWaveIn, WAVE_MAPPER,&pFormat, 0L, 0L, WAVE_FORMAT_DIRECT); if (InitCVIRTE (hInstance, 0, 0) == 0) return -1; if ((panel = LoadPanel (0, "laser.uir", PANEL)) < 0) return -1; DisplayPanel (panel); RunUserInterface (); DiscardPanel (panel); waveInClose(hWaveIn); return 0; } int CVICALLBACK timer(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if (event==EVENT_TIMER_TICK) { WAVEHDR WaveInHdr; // Set up and prepare header for input WaveInHdr.lpData = (LPSTR)waveIn; WaveInHdr.dwBufferLength = NUMPTS*2; WaveInHdr.dwBytesRecorded=0; WaveInHdr.dwUser = 0L; WaveInHdr.dwFlags = 0L; WaveInHdr.dwLoops = 0L; waveInPrepareHeader(hWaveIn, &WaveInHdr, sizeof(WaveInHdr)); // Insert a wave input buffer waveInAddBuffer(hWaveIn, &WaveInHdr, sizeof(WaveInHdr)); // Commence sampling input waveInStart(hWaveIn); // Wait until finished recording do {} while (waveInUnprepareHeader(hWaveIn, &WaveInHdr, sizeof(WaveInHdr))==WAVERR_STILLPLAYING); } return(0); }
and the include file:
/**************************************************************************/ /* LabWindows/CVI User Interface Resource (UIR) Include File */ /* Copyright (c) National Instruments 2010. All Rights Reserved. */ /* */ /* WARNING: Do not add to, delete from, or otherwise modify the contents */ /* of this include file. */ /**************************************************************************/ #include <userint.h> #ifdef __cplusplus extern "C" { #endif /* Panels and Controls: */ #define PANEL 1 #define PANEL_TIMER 2 /* callback function: timer */ /* Menu Bars, Menus, and Menu Items: */ /* (no menu bars in the resource file) */ /* Callback Prototypes: */ int CVICALLBACK timer(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); #ifdef __cplusplus } #endif
I also attached the files, including the *.uir.
Maybe someone could check whether he/she is having the same problem?
01-03-2011 01:14 PM
i got the same error you did.
I tried debugging it and it seems the error occurs somewhere in the windows api code. what is weird is that all the values always returned MMSUCCESS. And looking at your test outputs, sometimes it error'ed in the middle of the printf, which leaves me to believe that it happened in a new thread created from the waveInStart;
The best info I found was at this link
Looking at the links - it seems the address of 7C90120E is in the ntdll.dll (ModLoad: 7c900000 7c9af000 ntdll.dll)
*** ERROR: Symbol file could not be found. Defaulted to export symbols for
ntdl
l.dll -
ntdll!DbgBreakPoint:
7c90120e cc int 3
0:000>
And maybe this link helps as it talks about full page heap?!
Seems you may need to debug the windows calls though.
Good Luck
01-04-2011 06:55 AM
Well this certainly helps to point in the right direction!
So it is ntdll that is causing the errors, but to be honest that is the only thing I understand form your previous post 😕
A google search on ntdll errors suggest debugging it with windbg, but I really wouldn't know how......
01-04-2011 08:40 AM
I found a similiar topic:
http://us.generation-nt.com/answer/unhandled-exception-wavein-functions-help-26121542.html?page=2
where the 'solution' is to ignore the exception, which isn't very satisfying...
I noticed the errors are written to the debug output which gives:
HEAP[laser_dbg.exe]: Invalid address specified to RtlGetUserInfoHeap(00080000 , 009A700)
HEAP[laser_dbg.exe]: Invalid address specified to RtlGetUserInfoHeap(00080000 , 009A700)
HEAP[laser_dbg.exe]: Invalid address specified to RtlGetUserInfoHeap(00080000 , 009D400)
HEAP[laser_dbg.exe]: Invalid address specified to RtlGetUserInfoHeap(00080000 , 009D400)
HEAP[laser_dbg.exe]: Invalid address specified to RtlGetUserInfoHeap(00080000 , 009D600)
HEAP[laser_dbg.exe]: Invalid address specified to RtlGetUserInfoHeap(00080000 , 009D600)
Every time the break occurs one line is added.
So as you suggested, it indeed is 'heap-related', still don't quite know what that means though 😕
01-04-2011 08:50 AM
Ya, as the problem gets lower and lower in the level of coding and OS, I know less
It doesn't help when some of the suggested solutions are to ignore it or to increase the heap. Unfortunately, I wouldn't know how to do either in CVI.
You may need to update the header/subject message of the thread.
01-04-2011 09:44 AM
IT WORKS!!!
First, by enabling 'full page heap', the exceptions miracelously disappear! So this was yet another dead end in some way.
Appearently, heap errors appear when trying to write to an unallocated piece of memory, so it appears the buffer is unprepared too early.
The workaround is preparing the buffer only once (instead of every sample), and in the loop only call waveAddBuffer() and waveInStart()(and not waveIn(un)PrepareBuffer).
This way it either starts recording, or, when already recording, does nothing (i.e. return an error-value) and leaves the buffer alone.
By not unpreparing the buffer, it can't be not there and therefore the exceptions are gone!
ngay528, thank you very much for your help!
Regards Dirk
01-04-2011 09:46 AM
Awesome! Congrats and Good Luck with the program.
05-12-2012 04:56 AM
I am also facing similar problem with RtlGetUserInfoHeap. In my program, waveInPrepareHeader and waveInUnprepareHeader are prepared once and waveInAddBuffer is kept in loop. Even though I am getting RtlGetUserInfoHeap problem. How to increase the heap size. Will it solve the problem without further deadend. Can you help.
y v subba rao