🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.multimedia
Article #975

I need help on lineGetID() and waveInOpen()

#975
From: 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;
 }
}
Technical Details
Message-ID: <3c90ce92_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!supernews.com!news.cs.utwente.nl!newshunter!cosy.sbg.ac.at!fu-berlin.de!news.boerde.de!nntp.cs.uni-magdeburg.de!PeerFeed.KWeb.on.ca!KWeb!dnews

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d0fc,cb8f511ac0187541,start
X-Google-Attributes: gid10d0fc,public
X-Google-ArrivalTime: 2002-03-14 08:29:04 PST
From: "Paul" <ytooi@usa.net>
Newsgroups: borland.public.cppbuilder.multimedia
Subject: I need help on lineGetID() and waveInOpen()
Date: Fri, 15 Mar 2002 00:43:08 +0800
Lines: 91
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
NNTP-Posting-Host: 161.142.208.64
Message-ID: <3c90ce92_1@dnews>
X-Trace: dnews 1016123026 161.142.208.64 (14 Mar 2002 08:23:46 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!supernews.com!news.cs.utwente.nl!newshunter!cosy.sbg.ac.at!fu-berlin.de!news.boerde.de!nntp.cs.uni-magdeburg.de!PeerFeed.KWeb.on.ca!KWeb!dnews