Re: waveIn fails after overrun on CE 5.0



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 -

.



Relevant Pages

  • Re: A Crusoe mystery !!!
    ...   Not that that's germaine to my point, ... like the main audio track wasn't broadcasting. ... Friday apparently hallucinating and Crusoe and the cute girl pirate (Who ...
    (rec.arts.tv)
  • Re: Need CLIPS for pairs of audio faders: Scott, Mike, others?
    ...    >Wow, ... Most of my Directors are just average townies: ... Even though I'm out-of-the-loop on certain current audio ... trying to please Board, towns, viewers, volunteers and myself. ...
    (rec.audio.pro)
  • Re: Reading Time Code off of an audio track?
    ... the TC audio signal into a numeric readout? ... Failing an FCP answer, is there a MAC program that reads TC? ...
    (rec.arts.movies.production.sound)
  • Re: Scottie critiques schools
    ... Did you subscribe to The Audio Critic? ...    Morphing the question again? ... In an era when audio magazine after audio magazine has ... Should they change their business based upon the whims of one ...
    (rec.audio.opinion)
  • Re: Speaker deterioration?
    ... variation on the 'How high is up?' ... I'm hoping it's the speaker and not the audio section, ...    I block all postings with a Gmail, Google Mail, ... Give us some more details Mike :-) How long have you ...
    (rec.radio.shortwave)