Perhaps I am the only one with a sound input application, and so no
one responded when I reported a system hangup problem last week. So
here it is again, with some new info.
The problem is that when a sound input application exits in a
straightforward manner, it has a 2% chance of freezing the device. To
verify this, I constructed a minimal failure example, starting by
using the CW 9.2 New PalmOS C Application wizard to create a new
project. I used all the defaults (no special features). Then I made
these changes to the source code to implement the starting of a sound
input stream:
- - - - - - - - -
static Int32 Dummy;
static SndStreamRef soundStreamIn;
In AppStart, I do this:
Err error = SndStreamCreate(&soundStreamIn,
sndInput,
11025, //..sample rate
sndInt16Little,
sndMono,
&soundInCallback,
&Dummy, // Arg Ptr to callback, not used
1024, //..requested block size
0); //..0 = callback is NOT ARM..
if(!error)
error = SndStreamStart(soundStreamIn);
My callback for this example is trivial:
Err soundInCallback(void *userData,
SndStreamRef stream,
void *buffer,
UInt32 frameCount)
{
return errNone;
}
At AppStop I do this:
SndStreamDelete(soundStreamIn);
- - - - - - - - - - -
Making only these changes to the starter app, I compile and download
to the Tungsten T2. I then get an app that hangs the Tungsten T2
about 2% of the time when I exit from the app. (Assign the app to a
button to make it easy to start over and over again.)
I then began guessing that maybe the system sound driver does not
completely stop the sound input stream, causing the callback to be
called after the program has quit. To this end, I changed the cleanup
at AppStop to:
SndStreamStop(soundStreamIn);
SysTaskDelay(50); // .5 second delay
SndStreamDelete(soundStreamIn);
The delay is longer than one buffer (1024/11025 sec.), so you would
think that everything would have stopped before the app exits. But
still, the 2% hangup remains.
I tried testing the packaged Voice Memo application, but I could not
get it to hang. I did notice, though, that when you exit from Voice
Memo while a recording is in progress, Voice Memo does not exit
immediately. It makes a couple of funny beeps and then exits. I
wonder if it is doing any special sound input cleanup before it exits?
And how would one implement such an extended cleanup? I have even
tried setting a flag that the callback would see, and it would call
SndStreamStop(), and signal back that it had done it, and then my app
would exit. That also hangs up about 2% of the time. Is there anyone
else developing sound input applications that would care to comment on
this phenomenon?
Robert Scott, Ypsilanti, MI
(reply through this forum, not by e-mailing me directly)
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/