audiolib changed...

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
Shazz
Posts: 244
Joined: Tue Aug 31, 2004 11:42 pm
Location: Somewhere over the rainbow
Contact:

audiolib changed...

Post by Shazz »

I saw that audiolib changed...

Now the callback registration process need one more arg :

Code: Select all

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
Paco
Posts: 54
Joined: Sun Oct 09, 2005 6:53 pm

Post by Paco »

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
Post Reply