| View previous topic :: View next topic |
| Author |
Message |
homemister
Joined: 24 Mar 2008 Posts: 25
|
Posted: Sun Oct 26, 2008 5:01 pm Post subject: Async Functions in SDK HELP |
|
|
Hey all,
would some one be able to give an example of the sceIoReadAsync() function from the sdk. I have been looking all over the forums and even in PPA source code. But i can't seem to get it to work.
Regards
Homemister |
|
| Back to top |
|
 |
Onii
Joined: 05 Oct 2008 Posts: 40
|
Posted: Sun Oct 26, 2008 5:30 pm Post subject: |
|
|
First, a disclaimer, I haven't played with async io, just relaying what I found in the docs with the hope that it'll help.
If I understand the docs correctly, first you register a callback with sceIoSetAsyncCallback(), then you call sceIoReadAsync() which will return immediately, and when it has done its work will fire your callback.
OR
Call sceIoReadAsync() and at a later time you can call sceIoPollAsync() to see if it's done and/or call sceIoWaitAsync() to wait for it to complete. |
|
| Back to top |
|
 |
homemister
Joined: 24 Mar 2008 Posts: 25
|
Posted: Sun Oct 26, 2008 6:49 pm Post subject: |
|
|
Thx,
Got it working now.
| Code: | int main(void)
{
SetupCallbacks();
pspDebugScreenInit();
printf("ms0:/test.txt\n");
SceUID fd = sceIoOpen("ms0:/test.txt", PSP_O_RDONLY, 0777);
char data[256];
sceIoChangeAsyncPriority(fd, 0x10);
sceIoReadAsync(fd, data, 100);
SceInt64 res;
sceIoWaitAsync(fd, &res);
sceIoClose(fd);
printf(data);
printf("\nDONE");
return 0;
} |
|
|
| Back to top |
|
 |
Onii
Joined: 05 Oct 2008 Posts: 40
|
Posted: Mon Oct 27, 2008 2:18 am Post subject: |
|
|
I know this is just an example, but I think its worth mentioning (for other readers of the thread) that if you're using it that directly in your actual code you gain no benefit from using the async calls. I'd use the non async equivalents, they're much more direct in usage:
Just sceIoRead(fd, data, 100); and you've got 100 bytes, right away. |
|
| Back to top |
|
 |
homemister
Joined: 24 Mar 2008 Posts: 25
|
Posted: Mon Oct 27, 2008 5:45 pm Post subject: |
|
|
but if you are doing lots of reading from the memorystick use the Async.
I am using it for my Mp3 decoder and **Video Loader**. Because i am constantly streaming data from the memory stick. |
|
| Back to top |
|
 |
|