?
Solved

Change from 16 bit to 32 bit implementation of waveInAddBuffer()

Posted on 1997-02-12
1
Medium Priority
?
675 Views
Last Modified: 2013-12-04
Hello,

I've got a really strange problem porting a 16 bit wav record routine into a 32 bit application.

I'm using low level Wave functions to read from my soundblaster line input in order to store data into my program. Here is a sample of the code:

declarations:

 static HWAVEIN Wave = NULL;
 static HWAVEOUT WaveOut = NULL;
 PCMWAVEFORMAT Format;
 WAVEINCAPSA Caps;
 WAVEOUTCAPSA OutCaps;
 MMRESULT Error;
 unsigned int num;
 static WAVEHDR Header;
 static WAVEHDR Next;
 static HGLOBAL HBuffer;
 static HGLOBAL HNext_Buffer;
 static LPSTR Next_Buffer;
 static LPSTR Buffer;

code:

HNext_Buffer = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT,Granularity+10);
HBuffer = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, Granularity+10);
if ((HBuffer == NULL) | (HNext_Buffer == NULL))
      {
      MessageBox(hDlg,"Memory Allocation Error","Arghh",MB_OK);
      EndDialog(hDlg,FALSE);
      return FALSE;
      }
Buffer = (LPSTR) GlobalLock(HBuffer);
Next_Buffer = (LPSTR) GlobalLock(HNext_Buffer);

Error = waveInOpen(&Wave,0,&Format,hDlg,NULL,CALLBACK_WINDOW | WAVE_ALLOWSYNC);

Header.lpData = Buffer;
Header.dwBufferLength = Granularity;
Header.dwBytesRecorded = Granularity;
Header.dwUser = 0x42424242;
Header.dwFlags = WHDR_INQUEUE;
Header.dwLoops = 0;

Next.lpData = Next_Buffer;
Next.dwBufferLength = Granularity;
Next.dwBytesRecorded = Granularity;
Next.dwUser = 0x26011972;
Next.dwFlags = WHDR_INQUEUE;
Next.dwLoops = 0;

Error |= waveInPrepareHeader(Wave,&Header,sizeof(WAVEHDR));
Error |= waveInPrepareHeader(Wave,&Next,sizeof(WAVEHDR));

// everything works fine up to here

Error |= waveInAddBuffer(Wave,&Header,sizeof(WAVEHDR));

// Error returns 33 which is WAVE_ERR_BASE (32) + 1 <- device still playing !!!
//                                          I want it to be playing!!!!
// Wave has an incredible value of something like -20465865
// which seems odd for a simple handle

Error |= waveInAddBuffer(Wave,&Next,sizeof(WAVEHDR));
Error |= waveInStart(Wave);

This code worked perfectly fine in 16 bit mode (Borland C++ 4.0) and I'm trying to port it to 32 bit with EMX GNU C/C++ port and RSXNT WDK and also with BC4.0 32bit compilers for win32. They both failed.

for the EMX port, I've built a winmm.a library using 'makelib' from WINMM.DLL, and multimedia support seemed all right since function like sndPlaySoundA, waveInGetDevsCapsA and waveInOpen worked. Besides my callback window do receive the WIM_OPEN message, tending to prove that the wave device is working correctly.

That's fairly strange because everything else in my code works out just fine except this part!

Everything is done on a 486dx266 running win95 (08/95 release) 8 Mb ram + SoundBlaster 2.0 (8bit)

So if you've got a solution for that I'd be more than glad to hear from you.

Best regards,

Jean Yves
0
Comment
Question by:JYC
[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
1 Comment
 

Accepted Solution

by:
mannfai earned 200 total points
ID: 1298462
Hi Jean,

I got this problem b4.  I suspect u are using an old Win95 Soundblaster driver.  U can download the new drivers at Creative's site (www.creativelabs.com) and then try out your code again.
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

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 accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

719 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