I wrote a call back with VFSManager,
Here's the call back routine.
Err StreamFillerVFS(void *userdata,
SndStreamRef channel, void *buffer, UInt32 numberofframes)
{
Int16 i;
UInt8 *sampleP = (UInt8 *)buffer;
DmOpenRef db;
StreamFileDescType *streamFile = (StreamFileDescType *) userdata ;
UInt32 size, pos;
UInt32 readBytes;
Err err;
err= VFSFileSize( streamFile->file_ref, &size);
err = VFSFileTell ( streamFile->file_ref, &pos);
if ( ( pos + numberofframes * 4) > size){ // End of file? Very poor
implementation.
VFSFileSeek( streamFile->file_ref, 0, vfsOriginBeginning );
}
err = VFSFileRead( streamFile->file_ref, numberofframes * 4, sampleP,
&readBytes);
// For debugging.
{
RectangleType rect;
RctSetRectangle( &rect,0,10,10,10);
WinInvertRectangle(&rect,0);
}
}
Here's stream creation code.
gStreamFileVFSP = MemPtrNew( sizeof( StreamFileDescType));
MemPtrSetOwner( gStreamFileVFSP, 0);
err = SndStreamCreate(&streams[1], /* channel-ID is stored here */
sndOutput, /* input/output, enum */
44100, /* in frames/second, e.g. 44100, 48000
*/
sndInt16Little, /* enum, e.g. sndInt16 */
sndStereo, /* enum, e.g. sndMono */
StreamFillerVFS, /* function that gets called to fill a buffer
*/
(UInt32*)gStreamFileVFSP, /* gets passed in to the above
function */
8192, /* preferred buffersize in frames, not
guaranteed, use 0 for default
*/
false);
err = SndStreamSetVolume (streams[1], sndGameVolume) ;
Stream starting code.
UInt16 volRefNum;
Err err;
volRefNum = MSGetVolumeRefNum(0);
err = VFSFileOpen ( volRefNum, "/hanahana.wav",vfsModeRead | vfsModeLeaveOpen
, &(gStreamFileVFSP->file_ref ) );
SndStreamStart( streams[1]);
From: "Tatsuo Nagamatsu" <[EMAIL PROTECTED]>
>
> > I tried using Data Manager in the call back and it seems working
> > well on Palm OS Simulator.
> > I spsect sampled sound manager creates a thread for each channel
> > and call back is called in normal loop.
>
> > Are you testing in Palm OS 5 Simulator?
>
> I wrote an application that playbacks WAV file on a virtual file
> system and tested it on PalmSim DR12.
>
> API for VFS Mgr has a problem from callback. So I just broadcast
> a notification from callback for sampled sound. Callback for
> deferred notification broadcast is executed at event loop - UI task -
> and API for VFS Mgr has no problem from this callback.
>
> I hope this notification callback allows you to use any kind of Palm
> OS APIs.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/