Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
G

groston

@groston
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Audio program works under Win2k but not Win98
    G groston

    The source code shown below is a simple, working wav file player application. The program work perfectly under Windows 2000, but fails in a repeatable fashion under Windows 98. Let me briefly describe the functionality, then describe a mode of operation that works properly under both OS'es, then a mode of operation that fails only under Windows 98. When the program is started, the wav memory structures are initialized (WM_CREATE calls CreatePlayer). When a file is to be played, Play() is called. This routine opens the file "test.wav" (a 44.1 kHz sampled, stereo file), prepares the headers and fills the first set of buffers. As the wav device renders each buffer, it send a MM_WOM_DONE message to its callback routine. This routine sends a WM_COMMAND message to the main program, which then calls ReadBuffer() to refill the just-emptied buffer. When there is no more data to be read from the file, ReadBuffer() returns a 1, signaling the main program that the file has been completely rendered. The main program then sends a Stop(), which closes the wav device. Note that Stop() does not free any memory as Play() can be called again. Under both OS'es, if the a file is Play()'ed then Stop()'ed, it can be Play()'ed again without any problems. This is as expected. Under Win2k, if a file is allowed to Play() to completion, clicking Play() again causes the file to be Play()'ed. This is as expected. However, under Win98, when a file is allowed to Play() to completion, clicking Play() results in waveOutPrepareHeader() returning with an error, MMSYSERR_NOMEM, and the file does not Play(). I have tried a number of ways to solve this problem, including using memory locking, freeing and reallocating memory each time the player Stop()'s, etc. I haven't a clue as to why this is failing in this manner. Your thoughts and suggestions are gratefully accepted! === source code === #include #include #include #include #define NBUFS_OUT 4L #define OUTBUFSIZE 0x4000L #define ID_DONEBUFFER 40000 #define ID_CLOSED 40001 #define ID_PLAY_BUT 40002 #define ID_STOP_BUT 40003 #define WAVE_PLAYING 1 #define WAVE_READY 2 long doneBufCnt = 0; FILE *fp = NULL; HWND hWnd = NULL; HWAVEOUT hWaveOutDevice; WAVEFORMATEX waveOutFormatEx; WAVEHDR waveOutHdrs[NBUFS_OUT]; HINSTANCE myhInstance; /////////////////////////////////////////////////////////////////////////////// void CALLBACK WaveOutCallback (HWAVEOUT hwo, UINT uMsg, DWORD dwInst

    C / C++ / MFC
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups