Hi,
I am using SndStreamCreate function to paly .wav file.But it is not palying.In 
the specification of API it is said that it reqiures RAW data.PLease any body 
help me out how to create RAW data.
Do any body give me some working code for SndStreamCreate function.

I am also adding my code which i am using to paly the .wav file.

typedef struct oeCallbackDataType {
        MemHandle        resHand;
        SndStreamRef streamRef;
        Boolean      finished;
        UInt16           nCounter;
        UInt16       frameWidth; // number of bytes in each sample frame
        SndPtr           soundP;
        
} oeCallbackDataType;

static Err readCallbackFunc(void* UserDataP, SndStreamRef stream, void* 
bufferP, UInt32 frameCount)
{

        Err                result2;
        SysNotifyParamType notifyParams;

        Int16 *myBuffer=(Int16 *)bufferP; 
        Int16 *myBuffer2=(Int16 *)(((oeCallbackDataType*)UserDataP)->soundP); 

        
        UInt32 i; 
        for (i=0;i<frameCount;++i) 
        { 
                myBuffer[i]=myBuffer2[i]; 
        } 

        ErrNonFatalDisplayIf(
                (((oeCallbackDataType*)UserDataP)->finished == true),
                "Entered callback after stopping.");
        
        

        
        ((oeCallbackDataType*)UserDataP)->nCounter++;
        
        
        if ((((oeCallbackDataType*)UserDataP)->nCounter > 20))
                {
                        // stop the stream
                        result2 = SndStreamStop(stream);
                        ((oeCallbackDataType*)UserDataP)->finished = true;

                        MemSet(&notifyParams, sizeof(SysNotifyParamType), 0);
                        notifyParams.notifyType     = appFileCreator;
                        notifyParams.broadcaster    = appFileCreator;
                        notifyParams.notifyDetailsP = &UserDataP;

                        SysNotifyBroadcastDeferred(&notifyParams, 
sizeof(void*));
                        
                        return errNone;
                        ErrNonFatalDisplayIf( (result2 != errNone), "Can't 
close sound stream.");
                }
        return errNone;
}

static void
PlayRawVFSFile(char* filenameP, UInt32 sampleRate, SndStreamWidth sampleWidth)
{
        Err     result;
        oeCallbackDataType* callbackDataP;

        
        callbackDataP = MemPtrNew(sizeof(oeCallbackDataType));
        callbackDataP->resHand = DmGetResource ('bRaw',1100);
        callbackDataP->soundP = (SndPtr) 
MemHandleLock(((oeCallbackDataType*)(callbackDataP))->resHand);
        
        callbackDataP->nCounter = 0;
        result = SndStreamCreate(
                &(callbackDataP->streamRef),
                sndOutput,
                sampleRate,
                sndInt16Little,
                sndMono,
                readCallbackFunc,
                callbackDataP,
                REQUESTED_BUFFER_SIZE,
                false);
                
                
        ErrNonFatalDisplayIf( (result != errNone), "Can't create sound 
stream.");
        
        callbackDataP->finished = false;
        if (sampleWidth == sndMono)
                callbackDataP->frameWidth = 2;
        else
                callbackDataP->frameWidth = 4; // twice the samples for stereo

        result = SndStreamStart(callbackDataP->streamRef);
        ErrNonFatalDisplayIf( (result != errNone), "Can't start sound stream.");
}

Again i am adding the wav file in the RSRC wave file section.


Please help me out.........
Thakns in advance.

Amritanshu Agrawal

-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to