Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

waveInOpen / Close problems

259 views
Skip to first unread message

Dimitris Tripakis

unread,
Aug 31, 1999, 3:00:00 AM8/31/99
to
Hello,

WaveInClose fails, then when I run my program again waveInOpen( )
might fail too ( error code is 32 = WAVERR_BADFORMAT,
but this is definitely not the case because usually it works ok )
I read the WAVEFORMATEX struct from the same file always, so
the error is not in the format I give ...

Believe me you dont want to know the error code from
waveInClose ( ) it is -83948274982 or something like that :o)

To shut down the in stream, I call waveInStop() waveInReset()
and waveInClose( ), with this order. I dont unprepare the headers
that waveInReset() returns, since I wont use them again...
This should not cause any problems, right ?

I call waveInOpen( ) in a different thread than waveInClose( )
could this be the reason of the problem ? The threads are
correctly synchronized, this is sure ... This is the only difference
from the perfectly respective output stream, which works ok and
waveOutOpen()s and Close()s from a window procedure....

Any hints would be great,
thanx
Dimitris

Dimitris Tripakis

unread,
Aug 31, 1999, 3:00:00 AM8/31/99
to
Sorry, this was a wrong message, please ignore it....

The problem is that waveInClose( ) succeeds always, but
the next time I run the program, waveInOpen( ) might fail....

The next next time waveInOpen( ) will succeed again,
The next next next time it will fail

...and so on. One failure, one success....
Also, I can get two consecutive successes, if I ran, eg Sound Recorder
between them... I leave a wrong situation on the sound system, but dont
exactly know what Im doing wrong...

I have tried CloseHandle(hWaveIn) and also I have skipped it, it doesnt
change anything....

Dimitris

Moe

unread,
Aug 31, 1999, 3:00:00 AM8/31/99
to
"Dimitris Tripakis" <dt...@csd.uch.gr> wrote:

>Hello,

>WaveInClose fails, then when I run my program again waveInOpen( )
>might fail too ( error code is 32 = WAVERR_BADFORMAT,
>but this is definitely not the case because usually it works ok )
>I read the WAVEFORMATEX struct from the same file always, so
>the error is not in the format I give ...

>Believe me you dont want to know the error code from
>waveInClose ( ) it is -83948274982 or something like that :o)

Display in hex since is probably bit error flags.

waveInClose() return values from the MSDN doc's:
"MMSYSERR_INVALHANDLE Specified device handle is invalid.
MMSYSERR_NODRIVER No device driver is present.
MMSYSERR_NOMEM Unable to allocate or lock memory.
WAVERR_STILLPLAYING There are still buffers in the queue. "

>To shut down the in stream, I call waveInStop() waveInReset()
>and waveInClose( ), with this order. I dont unprepare the headers
>that waveInReset() returns, since I wont use them again...
>This should not cause any problems, right ?

You have to call unprepare headers before closing.

Quote from MSDN doc's--
"The waveInUnprepareHeader function cleans up the preparation
performed by the waveInPrepareHeader function. This function must be
called after the device driver fills a buffer and returns it to the
application. You must call this function before freeing the buffer."

The order i've used is
waveInReset()
waveInUnprepareHeader()
delete buffer memory
waveInClose()

>I call waveInOpen( ) in a different thread than waveInClose( )
>could this be the reason of the problem ? The threads are
>correctly synchronized, this is sure ... This is the only difference
>from the perfectly respective output stream, which works ok and
>waveOutOpen()s and Close()s from a window procedure....

Not sure. Maybe someone else has tried this. I would think as
long as only one thread acceses the resources at a time it should
work.

Hope this helps. Good luck

moe

Dimitris Tripakis

unread,
Aug 31, 1999, 3:00:00 AM8/31/99
to
Thanx for replying Moe,

I finally found out what was wrong :

I was calling acmStreamConvert( ) without the BLOCKALIGN
flag set, it was stupid to do this since MSDN says it clearly
that all apps should set this ...

This caused various errors, depending on the computer I
ran my program on ...Sometimes it crashed, sometimes
waveInOpen( ) would go wrong, etc etc...It was hard to
find since the symptoms were not standard...phew !

>
> waveInClose() return values from the MSDN doc's:
> "MMSYSERR_INVALHANDLE Specified device handle is invalid.
> MMSYSERR_NODRIVER No device driver is present.
> MMSYSERR_NOMEM Unable to allocate or lock memory.
> WAVERR_STILLPLAYING There are still buffers in the queue. "
>

the wave and the acm functions may return other error codes too...
MSDN only reports the most interesting ones....

Thanx again,
Dimitris

0 new messages