Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

wavein-problems

Posted on 1997-04-24
6
Medium Priority
?
293 Views
Last Modified: 2013-12-04
I wrote the following Callback-Function in order to
add the filled buffer, which is returned by the driver, again to drivers queue. I don't know why it doesn't work.
The driver stopps recording when the buffer is filled.
I would be verry glad if you could help me.

stephan




void CALLBACK  __export  WaveProc(

       HWAVE  hWave,      // handle of waveform device
       UINT  uMsg,      // sent message
       DWORD  dwInstance,      // instance data
       DWORD  dwParam1,      // application-defined parameter
       DWORD  dwParam2      // application-defined parameter
       )
{

 LPWAVEHDR lpWaveHdrTemp = (LPWAVEHDR) dwParam1;

  if( uMsg == WIM_DATA)
       {

             waveInUnprepareHeader((HWAVEIN) hWave, lpWaveHdrTemp ,sizeof(WAVEHDR) ) ;
              waveInPrepareHeader((HWAVEIN)hWave, lpWaveHdrTemp, sizeof(WAVEHDR));
              waveInAddBuffer((HWAVEIN)hWave, lpWaveHdrTemp, sizeof(WAVEHDR));
             
       }
}


0
Comment
Question by:stephan papadakis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 15

Accepted Solution

by:
NickRepin earned 60 total points
ID: 1396904
API Reference for WaveProc says:Applications should not call any system-defined functions from inside a callback function, except for EnterCriticalSection, LeaveCriticalSection, midiOutLongMsg, midiOutShortMsg, OutputDebugString, PostMessage, PostThreadMessage, SetEvent, timeGetSystemTime, timeGetTime, timeKillEvent, and timeSetEvent. Calling other wave functions will cause deadlock.

0
 
LVL 15

Expert Comment

by:NickRepin
ID: 1396905
By the way, I said it before in answer to your question Q861187135 (4/16/97). But 'this question is locked until stephan papadakis evaluates the answer'  :(.
0
 

Author Comment

by:stephan papadakis
ID: 1396906
Thank's a lot for your answere.

The only problem is, how can i solve my problem?

What should i do know. Should i create a dummy Callback -Window?

If i do so the waveinopen-function returns errorcode 11h

wich means "function is called with wrong parameters".

0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 

Author Comment

by:stephan papadakis
ID: 1396907
Thank's a lot for your answere.

The only problem is, how can i solve my problem?

What should i do know. Should i create a dummy Callback -Window?

If i do so the waveinopen-function returns errorcode 11h

wich means "function is called with wrong parameters".

0
 
LVL 15

Expert Comment

by:NickRepin
ID: 1396908
To avoid crash, you can try to process buffers in your window procedure, not in the callback function. For example:// Define our notify message#define WMU_FINISHED   (WM_USER+1)// Fill it with handle of our windowHWND wnd;// Callback functionvoid CALLBACK WaveProc(HWAVE hWave, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)
{
  if( uMsg == WIM_DATA) {
      // Device driver is finished!      // Notify our window.      PostMessage(wnd,WMU_FINISHED,0,(LPARAM) dwParam1);   }}// Here is our window procedure... wndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam){   LPWAVEHDR lpWaveHdrTemp = (LPWAVEHDR) lParam;
  switch(uMsg) {      // ...      case WMU_FINISHED:
          waveInUnprepareHeader((HWAVEIN) hWave, lpWaveHdrTemp, sizeof(WAVEHDR));
          waveInPrepareHeader((HWAVEIN)hWave, lpWaveHdrTemp, sizeof(WAVEHDR));
          waveInAddBuffer((HWAVEIN)hWave, lpWaveHdrTemp, sizeof(WAVEHDR));
      // .....
}Also you can try to use callback window instead of callback function. May be there are no restrictions on calling wave* functions from inside of callback window.P.S. It will be nice if you can post me your source code to nick@rtzi.ru

0
 

Author Comment

by:stephan papadakis
ID: 1396909
Thank's a lot.

I got it.
The problem is solved.


stephan
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question