Re: waveIn fails after overrun on CE 5.0
- From: "vishal.g.shah@xxxxxxxxx" <vishal.g.shah@xxxxxxxxx>
- Date: Fri, 23 May 2008 01:44:42 -0700 (PDT)
Can you try once running sample/standard source codes provided by
microsoft for Recording and Playing Audio Files in
C:\WINCE600\PUBLIC\COMMON\SDK\SAMPLES\AUDIO....
On May 23, 3:14 am, Jack <jackb...@xxxxxxxxx> wrote:
I have some test code which runs properly on XP but fails on our
Diamond Research Hercules II board running CE. The code in question
starts reading wave input, re-queuing every buffer as it fills. The
code runs fine in either environment, as long as the buffers are not
overrun. When the code is run under XP, processing resumes as
expected after an overrun. But under CE, an overrun causes the
processing to stop after the next few buffers are handled.
As you can imagine, this makes debugging with breakpoints impossible.
I suspect the audio driver for the board, but thought I would ask the
group before starting in on any Platform Builder activity. The
portaudio source indicates some funny stuff in the VIA drivers, which
my CE device uses.
Could someone try this on another board/BSP and see if it works for
them?
Here is the display under CE. Note that it just stops after this
output, the event is no longer being signaled. As I mentioned, things
continue properly when run on my desktop XP system.
Beginning AudioTest
Processing waveHeader[0].
Exiting waveInThread iter=1.
Processing waveHeader[1].
Exiting waveInThread iter=2.
Processing waveHeader[2].
Exiting waveInThread iter=3.
Processing waveHeader[0].
Exiting waveInThread iter=4.
Processing waveHeader[1].
Exiting waveInThread iter=5.
Processing waveHeader[0].
Processing waveHeader[1].
Processing waveHeader[2].
Exiting waveInThread iter=6.
Processing waveHeader[0].
Exiting waveInThread iter=7.
Here is the source code. Sorry about the length, I tried to make this
as terse as possible.
// AudioTest.cpp : Help track this audio overrun anomaly.
#include <tchar.h>
#include <stdio.h>
#include <Windows.h>
#include <Mmsystem.h>
#define NUM_BUFFERS 3
WAVEHDR waveHeader[NUM_BUFFERS];
HWAVEIN inputHandle;
HANDLE doneEvent;
DWORD WINAPI waveInThread (LPVOID dummyArg)
{
static int iter = 0;
DWORD rc;
for (;;)
{
rc = WaitForSingleObject (doneEvent, INFINITE);
if (rc == WAIT_FAILED)
printf("Wait failed.\n");
for (int i=0; i<NUM_BUFFERS; i++)
{
// If buffer is ready, process and requeue it.
if (waveHeader[i].dwFlags & WHDR_DONE)
{
printf("Processing waveHeader[%d].\n", i);
// Requeue buffer
rc = waveInAddBuffer (inputHandle, &waveHeader[i], sizeof(WAVEHDR));
if (rc != MMSYSERR_NOERROR)
printf("waveInAddBuffer failed.\n");
}
}
iter++;
printf("Exiting waveInThread iter=%d.\n", iter);
// On iteration 5, insert delay to force overrun.
if (iter == 5)
Sleep (2000);
}
}
int _tmain(int argc, _TCHAR* argv[])
{
MMRESULT rc;
WAVEFORMATEX waveFormatEx;
const int bufferLength = 2048;
HANDLE thread;
printf ("Beginning AudioTest\n");
// Create an event to allow signaling result
doneEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
if (doneEvent == NULL) goto error;
// Create a thread to wait on the event
thread = CreateThread (NULL, NULL, waveInThread, 0, NULL, NULL);
if (thread == NULL) goto error;
// Set up formatting
waveFormatEx.wFormatTag = WAVE_FORMAT_PCM;
waveFormatEx.nChannels = 1;
waveFormatEx.nSamplesPerSec = 8000;
waveFormatEx.nAvgBytesPerSec = 8000;
waveFormatEx.nBlockAlign = 1;
waveFormatEx.wBitsPerSample = 8;
waveFormatEx.cbSize = 0;
// Open waveform device
rc = waveInOpen (&inputHandle, WAVE_MAPPER, &waveFormatEx,
(DWORD)doneEvent, 0, CALLBACK_EVENT);
if (rc != MMSYSERR_NOERROR) goto error;
// Set up all the buffers
for (int i=0; i<NUM_BUFFERS; i++)
{
// Initialize the wave header
waveHeader[i].lpData = (LPSTR)malloc(bufferLength);
waveHeader[i].dwBufferLength = bufferLength;
waveHeader[i].dwFlags = 0;
// Init the buffer
rc = waveInPrepareHeader (inputHandle, &waveHeader[i],
sizeof(WAVEHDR));
if (rc != MMSYSERR_NOERROR) goto error;
// Add them into the system
rc = waveInAddBuffer (inputHandle, &waveHeader[i], sizeof(WAVEHDR));
if (rc != MMSYSERR_NOERROR) goto error;
}
// Start reading
rc = waveInStart (inputHandle);
if (rc != MMSYSERR_NOERROR) goto error;
// Loop here forever
for(;;)
{
Sleep( 100 );
}
error:
printf ("Error in processing\n");
return 1;
}- Hide quoted text -
- Show quoted text -
.
- Follow-Ups:
- Re: waveIn fails after overrun on CE 5.0
- From: Jack
- Re: waveIn fails after overrun on CE 5.0
- References:
- waveIn fails after overrun on CE 5.0
- From: Jack
- waveIn fails after overrun on CE 5.0
- Prev by Date: waveIn fails after overrun on CE 5.0
- Next by Date: Create COnfiguration Service Provider (CSP) and WIndows Mobile Adaptation Kit
- Previous by thread: waveIn fails after overrun on CE 5.0
- Next by thread: Re: waveIn fails after overrun on CE 5.0
- Index(es):
Relevant Pages
|
|