From: <aba...@fr...> - 2005-02-03 15:18:02
|
Hello, here is my suggestion about sound handling in gplflash say we have a new struct declared in flash.h named FlashSound this struct= will drives the way gplflash will manage sound (something similar to the FlashDisplay for graphics operation). Ideally this structure should conta= ins at least the following information : - rate at which the sound will be played back, - information about supporting stereo or not, - the size of the sample expected, - a sound buffer where gplflash should output the sound data, - the size of this sound buffer - optionnaly something to support multiple buffering (supported by adding= other sound buffers) All those fields will be filled by the caller in order to setup GplFlash. Other fileds will be there and will be filled by the library itself to no= tify the caller data are ready to play : - boolean to tell to start playing the sound buffer - amount of data copied in the sound buffer - optionnaly if we support multiple buffering repeat the two previous fie= lds as many buffers we support. I think we must at least support double buffering else we could have prob= lems when we are playing one sound and the library is decoding another to the = same buffer ! This could be something like that : typedef struct FlashSound { // user filled fields unsigned long fs_Rate; // the sound rate short fs_SampleSize; // size of the sample in bytes short fs_Stereo; // support stereo if non zero unsigned short fs_xBuffering; // number of buffering we support unsigned long fs_BufferSize; // buffer size in bytes void * fs_SoundBuffer; // pointer to the first buffer // other follow, to access buffer z do // (fs_SoundBuffer + (z*fs_BufferSize)) // library filled fields short * fs_PlayBuffer; // array of fs_xBuffering short which // indicates to play corresp. buffer unsigned long * fs_SoundSize; // array of fs_xBuffering long contains // how much sound data GPLFlash has // written in the corresp. buffer } FlashSound; Then the caller call FlashSoundInit passing this (filled) FlashSound stru= cture. All FlashSoundInit does is to do a "new SoundMixer(flashSound);". Then when the library wants to output sound it just uses write the data t= o the supplied buffers accordingg to the supplied datas. What do you think about that ? |