Re: WaveIn notification methods

From: lawrence (las_at_cybees.com)
Date: 10/21/04


Date: Thu, 21 Oct 2004 14:23:22 +0900

Hi,

I've made a softphone using cisco tsp, cisco wavedriver, and tapi 2. The way
i did it was that the audio data coming from cisco waveIn was passed to the
speaker for playback and audio from the mic was passed to cisco waveout
device for transmission.Also both the audio were written to a file for
recording. I used 150ms latency for the buffers.

 The softphone genarally works fine and conversation can be done, but once
in a while conversation become "dead air" or there would be a one-way audio.
Grant mentioned something like the wavedrivers don't mark the waveheader
flag to done. Is it possible that ciscowavedriver or the wavedriver of my
headset (plantronics dsp500) sometimes dont change the flag to done?? And
also when i do a waveInreset( ) after a "dead-air" or a oneway, my program
hangs up. How can i work around with it?? thanks.

p.s. and also where can i find some example code on how to implement the
different callback modes?

Regards,
Lawrence

"Grant Schenck" <schenckg@optonline.net> wrote in message
news:ODNRRovsEHA.224@TK2MSFTNGP15.phx.gbl...
> Chris,
>
> As always, thanks for your advice and knowledge. This is good stuff
> and matches my understanding.
>
> Earlier I had issues with the wave in events getting stuck somewhere
> when I moved other windows on my desktop. I decided to revisit this
> and have a case working with MS on it. I'm not optimistic in terms of
> getting to the bottom of it.
>
> I agree on polling vs. other mechanisms. Specifically in my wait I
> tried using a 5 ms timeout and checking the buffers whether the event
> popped or I fell out of the wait due to the time out. That didn't
> help and based on that I can say the issue is that the event isn't
> popping because the driver is not marking the buffers done. Why the
> driver stops marking buffers done is beyond me.
>
> Thanks, Grant
>
> "Chris P. [MVP]" <msdn@chrisnet.net> wrote in message
> news:#IP7elrsEHA.3972@TK2MSFTNGP15.phx.gbl...
> > Grant Schenck wrote:
> >
> > > "Are you using waveInOpen( )? If so, have you tried with
> different
> > > callback modes, such as CALLBACK_FUNCTION, or CALLBACK_THREAD?"
> > >
> > > I looked at the docs and CALLBACK_THREAD seems to involve a
> windows
> > > message. Searching on goggle the opinions I saw seemed to
> recommend
> > > against using it. What to you folks think? Is there any point in
> > > replacing CALLBACK_EVENT with CALLBACK_THREAD if I'm trying to
> achieve
> > > high performance audio?
> > >
> > > What about CALLBACK_FUNCTION? I assume that is better then
> > > CALLBACK_THREAD but is there any reason to think it would be
> better
> > > then CALLBACK_EVENT?
> >
> > Many many many many years back I was having the same dilemma as you
> trying
> > to decide what to use. So many choices! I wrote a test program
> that
> > implemented all the different methods to see what would work best.
> Here
> > were my discoveries:
> >
> > CALLBACK_WINDOW - Seemed ok at first, but fell apart when there were
> many
> > window messages flying about. Perhaps the simplest method to
> implement.
> >
> > CALLBACK_FUNCTION - Essentially useless because you can't do any
> audio
> > handing in the callback. You're choices are to signal an event or
> post a
> > window message, why created this method beats the **** out of me.
> >
> > CALLBACK_THREAD - Didn't work much better than CALLBACK_WINDOW.
> Makes the
> > code a little cleaner and allows you to elevate the thread priority
> of the
> > worker thread for a slight performance improvement.
> >
> > CALLBACK_EVENT - Worked well on the NT systems. Requires a
> dedicated worker
> > thread to operate at full potential. The worker thread must be
> using
> > WaitOnSingleObject() or WaitOnMultipleObjects(), using any function
> call
> > that generated or processed messages such as
> MsgWaitForMultipleObjects()
> > seemed to have a negative impact on performance.
> >
> > Now the method you probably didn't think about - CALLBACK_NULL. Yes
> you
> > might be suprised to find out that the lowest latency solution in
> many cases
> > is not to use any callback method at all but rather to poll the
> buffer
> > flags. Polling at a rate of 100 to 200 times a second can get you
> latency
> > in the 20ms range at the expense of a little CPU power. It really
> doesn't
> > use much if you throw a Sleep(5) into the loop. Obviously this
> requires a
> > dedicated thread and ideally the thread should be set to
> > THREAD_PRIORITY_TIME_CRITICAL. Make sure there is absolutely no
> code in
> > this high priority thread that can block or you will bring the
> system to
> > it's knees. That means no disk I/O, network etc.
> >
> > Which one to use for lowest latency? CALLBACK_EVENT is typically
> the best,
> > and with special audio drivers can achieve latency down in the 5ms
> range.
> > Second best, if CALLBACK_EVENT doesn't work out is polling. It's
> not really
> > worth trying to get the latency too low with WaveIn/Out unless the
> > manufacturer of the audio device has supplied special drivers as
> your going
> > to be hit by the kmixer 30ms delay anyway.
> >
> > -Chris
> >
> >
>
>



Relevant Pages

  • Re: WaveIn notification methods
    ... While we've seen very rare issues where the Cisco wave drivers don't ... I actually use a polling model with the Cisco wave drivers rather then ... > i did it was that the audio data coming from cisco waveIn was passed ... I used 150ms latency for the buffers. ...
    (microsoft.public.win32.programmer.mmedia)
  • Re: How to disable Software Mixer?
    ... Apparently it's the audio ... flow from the application to the driver. ... buffers are passed 'just as' to the driver. ... Call waveOutUnprepareHeader on each header. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Copy wavein to waveout
    ... Audio hardware is Sound Blaster AWE 64. ... >> thread for reading a writing and I pass buffers from the reader to ... > 10ms buffers with WaveIn/Out. ... >> window that the wave driver stops playing but that isn't what is ...
    (microsoft.public.win32.programmer.mmedia)
  • Re: Copy wavein to waveout
    ... Regarding my initial goal of doing this with wave. ... thread for reading a writing and I pass buffers from the reader to the ... doing this I get crackle audio. ...
    (microsoft.public.win32.programmer.mmedia)
  • Re: waveInOpen() etc. and overrun detection...
    ... where the resultant wavfile is missing numerous random slices of audio. ... The first thing that comes to mind is: Do you have enough buffers ... When handling WaveInProc, send the used buffer back to the driver ... and then you could have an overrun situation because the message loop ...
    (microsoft.public.win32.programmer.mmedia)