[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1833
  • Last Modified:

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.




0
Torus
Asked:
Torus
  • 3
  • 2
1 Solution
 
NickRepinCommented:
You have not to add buffers inside callback proc even under Win95.

Create the hidden window inside the DLL initialization proc and use this window as callback.

You can also create thread, and post message to that thread from the callback function.


0
 
TorusAuthor Commented:
Can you give me a example?
Thanks
0
 
NickRepinCommented:
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.
0
 
TorusAuthor Commented:
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
0
 
TorusAuthor Commented:
OK, I got it with using RegisterClass.
Thanks.
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now