waveOutOpen callback event 
Author Message
 waveOutOpen callback event

Hi there,

I'm using the waveOut* functions to play out some audio using double
buffering and I'm using a callback event to tell me when each buffer
is done.

However, I am unable to call waveOutWrite as I get and
MMSYSERR_INVALHANDLE error each time. Any idea what the problem could
be?

Here's the relevant code:

    /* declarations */
WAVEHDR             wh1, wh2;
HWAVEOUT            hwaveout;
WAVEFORMATEX        wfx;

    eventHandle = CreateEvent(NULL, FALSE, FALSE, NULL);

    if (eventHandle == NULL)
    {
        mexErrMsgTxt("failed to create event");
    }              

    if (eventHandle == NULL)
    {
        mexErrMsgTxt("failed to create event");
    }              

        /* initialise the wave player */

        /* I fill in the WAVEFORMATEX (wfx) structure here */

        errors = waveOutOpen ( &hwaveout,
                          WAVE_MAPPER,
                          &wfx,
                          eventHandle,
                          0,
                          CALLBACK_EVENT | WAVE_ALLOWSYNC );                              

    if (errors != MMSYSERR_NOERROR)
        {
            mxFree (&wh1);
            mxFree (&wh2);

            switch (errors)
            {
            case MMSYSERR_ALLOCATED: mexWarnMsgTxt("MMSYSERR_ALLOCATED");
break;
            case MMSYSERR_BADDEVICEID: mexWarnMsgTxt("MMSYSERR_BADDEVICEID");
break;
        case MMSYSERR_NODRIVER: mexWarnMsgTxt("MMSYSERR_NODRIVER");
break;
        case MMSYSERR_NOMEM: mexWarnMsgTxt("MMSYSERR_NOMEM"); break;
        case WAVERR_BADFORMAT: mexWarnMsgTxt("WAVERR_BADFORMAT");
break;
        case WAVERR_SYNC: mexWarnMsgTxt("WAVERR_SYNC"); break;
        default: mexWarnMsgTxt("default with waveoutopen"); break;
        }

        CloseHandle(eventHandle);

        mexErrMsgTxt("error in opening wave device");

            return 1;
        }

and then the call to waveOutWrite:

                        errors = waveOutWrite (hwaveout, &wh1,
sizeof(WAVEHDR));
                        if (errors != 0)
                        {
                            switch (errors)
                            {
                            case MMSYSERR_INVALHANDLE:
mexErrMsgTxt("MMSYSERR_INVALHANDLE");
                        case MMSYSERR_NODRIVER:
mexErrMsgTxt("MMSYSERR_NODRIVER");
                        case MMSYSERR_NOMEM:
mexErrMsgTxt("MMSYSERR_NOMEM");
                        case WAVERR_UNPREPARED:
mexErrMsgTxt("WAVERR_UNPREPARED");
                        default: mexErrMsgTxt("default error with
waveOutWrite");
                            }

                            mexErrMsgTxt("error in using waveoutwrite");
                        }

and I receive the MMSYSERR_INVALHANDLE error.

It worked when I used a callback thread but I've been forced to change
from that to a callback event.

Thanks in advance!

Su-Lin Lee

remove nospam to email



Fri, 26 Nov 2004 20:49:43 GMT  
 waveOutOpen callback event

Quote:

> I'm using the waveOut* functions to play out some audio using double
> buffering and I'm using a callback event to tell me when each buffer
> is done.

There are no waveOut*() functions in Standard C, and neither are the
other system-specific features you use. You'll need to ask about this
problem in a newsgroup that deals with your compiler, OS, sound library,
or whatever does define those features.

Richard



Fri, 26 Nov 2004 21:44:52 GMT  
 waveOutOpen callback event
Quote:

> I'm using the waveOut* functions to play out some audio using double
> buffering and I'm using a callback event to tell me when each buffer
> is done.

> However, I am unable to call waveOutWrite as I get and
> MMSYSERR_INVALHANDLE error each time. Any idea what the problem could
> be?

> Here's the relevant code:

>     /* declarations */
> WAVEHDR             wh1, wh2;
> HWAVEOUT            hwaveout;
> WAVEFORMATEX        wfx;

>     eventHandle = CreateEvent(NULL, FALSE, FALSE, NULL);

... snip and so forth ...

Nothing relevant about it.  Get thee to an appropriate newsgroup.

--

   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!



Sat, 27 Nov 2004 02:02:36 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. callback address to waveOutOpen

2. CALLBACK, CALLBACK, CALLBACK?

3. Interface callback implementation (vs Delegates & Events)

4. About Event,callback and thread

5. event callback using XML Web Service

6. Callback Event lost

7. Firing Events From Callback Function

8. Problem with COM Event Callback

9. I′m trying to do callback events in a different way

10. event vs callback?

11. events and callbacks!

12. Delegates, Events and static callbacks

 

 
Powered by phpBB® Forum Software