RE: [GD-Windows] Streaming WAVE audio
Brought to you by:
vexxed72
From: Brian H. <bri...@py...> - 2002-04-28 17:03:58
|
At 09:36 AM 4/28/2002 -0700, Jon Watte wrote: >Yeah, that'd do it. If you count it, you're running with only a single >buffer, if this is what you're doing. Yeah, that was part of me being lazy and tired -- I didn't run through simulation steps. > > Changing it to this fixed it: > > > > waveOutWrite( nextBuffer ); > > fillBuffer( completedBuffer ); > > waveOutWrite( completedBuffer ); //keep the chain going > >This can't possibly work right, as you enqueue two buffers for each >buffer played. I think you actually mean something else, such as >just calling fillBuffer() and waveOutWrite(). Actually, using your nomenclature, where "nextBuffer" indicates the "nextBuffer to be filled", I was doing this: waveOutWrite( ( nextBuffer + 1 ) % 3 ); fillBuffer( nextBuffer ); waveOutWrite( nextBuffer ); nextBuffer = ( nextBuffer + 1 ) % 3; And you're right, it didn't make sense -- it WORKED, but only because waveOutWrite is friendly when you send it a buffer it can't use. In the case of the first completion, nextBuffer+1 would have pointed to a previously INQUEUED buffer, generating an error (which would be silent if the return values weren't checked...fwiw, the return value was '33', which isn't an MMSYSERR_xxxx). So basically that first waveOutWrite() wasn't doing anything -- in fact, it was a legacy of my initial implementation where I always tried to have a premixed buffer waiting to go next. That is, the completion routine was expecting to dispatch _immediately_ to avoid any hiccups, it originally didn't have any other buffers queued waiting to go. That's the problem with long debugging sessions -- you start getting old code interfering with new code, but you're so tired and pissed you're scared to change stuff that seemingly works =) >setup: > memset( buffers[0], QUIET, SIZE ); > memset( buffers[1], QUIET, SIZE ); > memset( buffers[2], QUIET, SIZE ); > prepareBuffer( 0 ); > prepareBuffer( 1 ); > prepareBuffer( 2 ); > nextBuffer = 0; That's exactly what I was doing. >start: > queueBuffer( 0 ); > queueBuffer( 1 ); > queueBuffer( 2 ); Ayup. >completion: > fillBuffer( nextBuffer ); > queueBuffer( nextBuffer ); > nextBuffer = (nextBuffer + 1) % 3; Yup. The above is pretty much identical to the code I have now, but with my last e-mail I had a spurious queueBuffer((nextBuffer+1)%3) before I did the fill buffer. Brian |