Re: callback function immediatly called with an empty buffer




"alanglloyd@xxxxxxx" wrote:

> 1. Stephane Sep 16, 1:15 pm show options
>
> Newsgroups: microsoft.public.win32.programmer.mmedia
> From: "Stephane" <Steph...@xxxxxxxxxxxxxxxxxxxxxxxxx> - Find messages
> by this author
> Date: Fri, 16 Sep 2005 05:15:06 -0700
> Local: Fri, Sep 16 2005 1:15 pm
> Subject: callback function immediatly called with an empty buffer
> Reply | Reply to Author | Forward | Print | Individual Message | Show
> original | Report Abuse
>
> Hi,
> I try to record a wavefile with wavein API.
> Waveinprepareheader and waveinAddbuffer work fine, with a waveheader
> data
> buffer large to hold a few seconds audio.
> Strangely, just after waveinstart, the callback function is executed,
> and
> the waveheader param does not match the initialised waveheader
> Here is a code snipset
>
>
> > mhd.dwBufferLength = m_BufferSize
> > mhd.dwFlags = 0
> > mhd.dwLoops = 0
> > mhd.dwUser = 0
> > rc = waveInPrepareHeader(m_WaveIn, mhd, Marshal.SizeOf(mhd))
>
> Have you set the pointer to the buffer into mhd.lpData(after allocating
> it - or don't you have to do that in VB).
>
> Alan Lloyd
>
>

Thank you for you answer, Alan.
Yes, I did, allocate memory and set the pointer, with code like that:

For i = 0 To NUM_BUFFERS - 1
GlobalFree(hmem(i))
hmem(i) = GlobalAlloc(&H40, m_BufferSize)
pmem(i) = GlobalLock(hmem(i))
m_hdr(i).lpData = pmem(i)
m_hdr(i).dwBufferLength = m_BufferSize
m_hdr(i).dwFlags = 0
m_hdr(i).dwLoops = 0


And when I debug the callback function, I see that all the fields of that
parameter are set to 0, except dwflags, set to 3. It is like the parameter
points to an incorrect memory area.
I realy do not know what to do with that.

Stephane
.



Relevant Pages

  • Re: callback function immediatly called with an empty buffer
    ... > I try to record a wavefile with wavein API. ... > Waveinprepareheader and waveinAddbuffer work fine, with a waveheader data ... > Strangely, just after waveinstart, the callback function is executed, and ... > Why does wavhdr not match mhd ...
    (microsoft.public.win32.programmer.mmedia)
  • gz compression rates with custom buffer callback
    ... what I want to do is a classic output-buffer callback function that gzencodethe buffer. ... There's a native function for that, I know, but I want a little more: compression stats. ... The flag is set, so I can now send the HTTP header to tell the browser we're gonna send some encoded stuff, and then actually encode it. ...
    (comp.lang.php)
  • Re: sending HTTP requests... newbie (continued)
    ... places, find the missing .dll files, rediscovering that a lot of file are missing from the different versions of the download libraries, ... constant and the pointer to your callback function. ... typedef struct CurlBuffer ... CurlBuffer buffer; ...
    (comp.programming)
  • Re: Mystic Playback stops problem with waveInPrepareHeader, waveInAddBuffer etc.
    ... > modern sound cards you are probably ok reusing accross AddBuffer ... > If you use a thread for wavein and another thread for waveout, ... > have a sufficiently deep record buffer pool, ... > into any performance issues when preparing/unpreparing with every use. ...
    (microsoft.public.win32.programmer.mmedia)
  • WaveIn Problem in XP
    ... This won't make much sense unless you have used waveIn functions to ... record wave files. ... When the buffer is filled with wave data it sends a MM_WIM_DATA message ...
    (comp.lang.pascal.delphi.misc)