🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.multimedia
2 messages
2 total messages Started by Paul Thu, 14 Mar 2002 16:43
I need help on lineGetID() and waveInOpen()
#975
Author: Paul
Date: Thu, 14 Mar 2002 16:43
88 lines
3242 bytes
I am writing a program that will answer a call and record messages.
Everything works fine, my program is able to wait for incoming calls, answer
them and play a message but it could not record messages.  Below are the
functions used to get the line wave ID and record messages.  At the function
recordmsg(), waveInOpen() failed with the error codes MMSYSERR_BADDEVICEID,
MMSYSERR_NODRIVER and MMSYSERR_NOMEM, can someone tell me what is wrong with
my code?



somewhere in main();

dwWaveInID = GetWaveID(LINECALLSELECT_LINE, "wave/in");
recordmsg(dwWaveInID);



LONG GetWaveID(DWORD dwSelect, LPSTR waveDev)
{
 DWORD dwWaveDev;
 VARSTRING  *vs;
 DWORD dwTotalSize = sizeof(VARSTRING) + sizeof(DWORD);

 // allocate memory for structure
    vs = (VARSTRING *) calloc (1, dwTotalSize);
 ZeroMemory(vs, dwTotalSize);
 // set structure size

    vs->dwTotalSize = dwTotalSize;

    if (dwSelect == LINECALLSELECT_LINE)
  lasterror = lineGetID(mytapi.hLine, 0L, NULL, dwSelect, vs, waveDev);

 if (dwSelect == LINECALLSELECT_CALL)
  lasterror = lineGetID(mytapi.hLine, 0L, mytapi.hCall, dwSelect, vs,
waveDev);

 // bomb out if error
 if (lasterror)
 {
  free (vs);
  return -1;
 }

 CopyMemory(&dwWaveDev, (char*)vs + vs->dwStringOffset, vs->dwStringSize);
    free (vs);

 return dwWaveDev;

}

WAVEFORMATEX messageFormat = {WAVE_FORMAT_PCM, 1, 8000, 16000, 1, 16};

HWAVEIN recordmsg(DWORD devid)
{
 HWAVEIN h_wavein;

 /* check support for format */
 if (lasterror = waveInOpen(NULL, (WORD)devid, &msgformat, (DWORD)hWnd, 0,
WAVE_FORMAT_QUERY))
 {
  MessageBox (0, "Unsupported format.", 0, MB_OK);
  return 0;
 }

 /* open recorder. */
 if (lasterror = waveInOpen(&h_wavein, (WORD)devid, &msgformat, (DWORD)hWnd,
0, CALLBACK_WINDOW))
 {
  if (lasterror & MMSYSERR_ALLOCATED)
   MessageBox(0, "Specified resource is already allocated.", 0, 0);

  if (lasterror & MMSYSERR_BADDEVICEID)
   MessageBox(0, "Specified device identifier is out of range.", 0, 0);

  if (lasterror & MMSYSERR_NODRIVER)
   MessageBox(0, "No device driver is present.", 0, 0);

  if (lasterror & MMSYSERR_NOMEM)
   MessageBox(0, "Unable to allocate or lock memory.", 0, 0);

  if (lasterror & WAVERR_BADFORMAT)
   MessageBox(0, "Attempted to open with an unsupported waveform-audio
format.", 0, 0);

  return 0;
 }
}
Re: I need help on lineGetID() and waveInOpen()
#978
Author: Michael Warner
Date: Sat, 16 Mar 2002 15:31
13 lines
1762 bytes
On Fri, 15 Mar 2002 00:43:08 +0800, "Paul" <ytooi@usa.net> wrote:

>I am writing a program that will answer a call and record messages.
>Everything works fine, my program is able to wait for incoming calls, answer
>them and play a message but it could not record messages.  Below are the
>functions used to get the line wave ID and record messages.  At the function
>recordmsg(), waveInOpen() failed with the error codes MMSYSERR_BADDEVICEID,
>MMSYSERR_NODRIVER and MMSYSERR_NOMEM, can someone tell me what is wrong with
>my code?

I can't tell you directly whether or why you have the wrong wave
device ID, but you could call waveInGetNumDevs and waveInGetDevCaps()
to determine whether it's returning the expected device ID.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads