i am working on sending voice across the network using netlibreceive and
buffering. i initialize my buffer using this code:
//buffer initialization
if(!myPlayerInfoP->bufInit) {
myPlayerInfoP->buf = MemPtrNew(bufferSizeP);
//myPlayerInfoP->buf2 = MemPtrNew(bufferSizeP);
myPlayerInfoP->bufInit = true;
}
and then i use the function call below to receive the voice packets.
dataWritten = NetLibReceive(myPlayerInfoP->netLib.AppNetRefnum,
myPlayerInfoP->netLib.MasterSocket,
(void *)myPlayerInfoP->buf,
(UInt16)bufferSizeP,
0,
(NetSocketAddrINType*)&myPlayerInfoP->netLib.ClientAddr,
&myPlayerInfoP->netLib.ClientAddrSize,
myPlayerInfoP->netLib.AppNetTimeout,
&err);
bufferP = myPlayerInfoP->buf;
the netlibreceive function is called inside the sound call back function, so
that the voice received will be immediately played back. however, it didnt
play anything back.
i used the function below instead, also using the same buffer initialization:
dataWritten = NetLibReceive(myPlayerInfoP->netLib.AppNetRefnum,
myPlayerInfoP->netLib.MasterSocket,
(void *)myPlayerInfoP->buf,
(UInt16)bufferSizeP,
0,
(NetSocketAddrINType *)&myPlayerInfoP->netLib.ClientAddr,
&myPlayerInfoP->netLib.ClientAddrSize,
myPlayerInfoP->netLib.AppNetTimeout,
&err);
dataWritten = FileWrite(myPlayerInfoP->fileHandle, myPlayerInfoP->buf, 1,
bufferSizeP, &err);
FileRewind(myPlayerInfoP->fileHandle);
dataRead = FileRead(myPlayerInfoP->fileHandle, bufferP, 1, *bufferSizeP, &err);
using the code above, i save in a file whatever i receive, i point my
filepointer to the origin, then read what was written, and it was able to play
back something. however, the quality was really choppy.
how can i make the buffer work rather than writing it to a file? this is for
real-time playback.
thanks.
Lyka.
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/