 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Shazz

Joined: 31 Aug 2004 Posts: 244 Location: Somewhere over the rainbow
|
Posted: Fri Oct 14, 2005 9:23 pm Post subject: audiolib changed... |
|
|
I saw that audiolib changed...
Now the callback registration process need one more arg :
| Code: |
void pspAudioSetChannelCallback(int channel, pspAudioCallback_t callback, void *pdata); |
What should we put into pdata ????
Can someone provide a short example ? _________________ - TiTAN Art Division -
http://www.titandemo.org |
|
| Back to top |
|
 |
Paco
Joined: 09 Oct 2005 Posts: 54
|
Posted: Fri Oct 14, 2005 10:30 pm Post subject: |
|
|
You just pass data that you want to receive in the callback. Notice the callback function prototype has changed too, it now receives an extra parameter.
Old code can simply pass 0 in pdata, and then ignore the new parameter in the callback.
Every callback system needs to support user-provided data for context.
Imagine you make a MP3 player based on audiolib, and want to play back four MP3 at the same time, one on each channel of the audiolib. Easy enough, you simply register your MP3 callback in each channel you're playing an MP3 on.
Now the problem: when your callback is called, which of the four MP3 you're playing is the one you're supposed to store on the buffer? That's the kind of info you provide in the pdata - stuff that your callback uses to identify what data it should work on; in this case, it would be a pointer to your "struct MP3PlayerData", and the first thing the MP3 callback would do is:
pMP3Data = (MP3PlayerData*)pdata; _________________ Paco |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|