Link to home
Start Free TrialLog in
Avatar of Torus
Torus

asked on

WaveInProc, WaveOutProc and Wave Functions

I have written a dll for playing and recording files. Because it has no window handle, I use CALLBACK_FUNCTION in the WaveOutOpen and WaveInOpen and declare the callback function WaveOutProc and WaveInProc. When getting WM_DONE or WIM_DATA, I will
add next buffer and call WaveOutWrite in playging or calling
waveinaddbuffer in recording. However, the functions are
hanged in NT SP5 if I call those wave functions inside the waveInProc or waveOutProc. I see the help saying that only some system function can be called inside the function. But I get worked
in win95.

My question is how to get around this problem in NT SP5?
Can I get any window handle and have a standard
WNDPROC callback to get window message inside the DLL?
if so, how can I do that?

Thanks.




ASKER CERTIFIED SOLUTION
Avatar of NickRepin
NickRepin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Torus
Torus

ASKER

Can you give me a example?
Thanks
What kind of example? How to create a window? It is simple enough.

Well, something like this:

#define WMDONE WM_USER+1

HWND hWin;
BOOL DllMain(hInstance...fdwReason...)
{
  if(fdwReason==DLL_PROCESS_ATTACH) {
     hWin=CreateWindow("YourWindowClass","",WS_POPUP,1,1,1,1,
 HWND(0),0,hInst,0);
  }
  return TRUE;
}

LRESULT YourWindowProc(HWND w,UINT uMsg,...)
{
   switch(uMsg) {
   case WMDONE:
       // Free old buffer here    
       // Add new buffer here.
       break;
   default:
      return DefWindowProc(...)
   }
   return 0;
}

void CALLBACK waveOutProc(
  HWAVEOUT hwo,      
  UINT uMsg,        
  DWORD dwInstance,  
  DWORD dwParam1,    
  DWORD dwParam2    
)
{
  if(uMsg==WOM_DONE) {
     PostMessage(WMDONE,hWin,dwParam1,dwparam2);
  }
}
 
Or specify hWin handle in the waveOutOpen (waveInOpen) call, so there will no need in waveOutProc.

The better way is to take any appropiate sample from the SDK.
Avatar of Torus

ASKER

Yup, I want to use the CALLBACK_WINDOW and get rid of the waveInProc. If so, why can I set up the "YourWindowProc" as a default
message handler? it is necessary to use registerClassEx to do that?

Thanks
Avatar of Torus

ASKER

OK, I got it with using RegisterClass.
Thanks.