sceIoOpen and sceIoOpenAsync

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

Moderators: cheriff, TyRaNiD

Post Reply
Noko
Posts: 23
Joined: Sat Sep 06, 2008 8:35 pm

sceIoOpen and sceIoOpenAsync

Post by Noko »

sceIoOpen and sceIoOpenAsync
Are there real differences? Or can this whole async stuff be emulated using non-async functions?
I'm asking this because apparently psp kernel is not reentrant, and when I call sceIoRead with a lot of bytes to read, syscalls from other threads (like reading psp joystick state) seem to block until reading from file is done. I though that maybe async i/o might be a solution for this.
[wl]
Posts: 13
Joined: Fri May 05, 2006 2:16 am

Post by [wl] »

sceIoOpenAsync should help, because commercial games uses it while decoding/playing audio and video
Noko
Posts: 23
Joined: Sat Sep 06, 2008 8:35 pm

Post by Noko »

Did someone here use async file io?

I'm doing something like this:

Code: Select all

	SceUID f;
	SceInt64 asyncres;

	if&#40;&#40;f=sceIoOpenAsync&#40;path,PSP_O_RDONLY,0777&#41;&#41;<0&#41;
		return NULL;

	sceIoReadAsync&#40;f,buffer,bufsize&#41;;
	sceIoWaitAsync&#40;f,&asyncres&#41;;
Where to get the amount of bytes read after that? You'd think it would be in asyncres, but asyncres has the same values as f for some reason.
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

Noko wrote:Did someone here use async file io?

I'm doing something like this:

Code: Select all

	SceUID f;
	SceInt64 asyncres;

	if&#40;&#40;f=sceIoOpenAsync&#40;path,PSP_O_RDONLY,0777&#41;&#41;<0&#41;
		return NULL;

	sceIoReadAsync&#40;f,buffer,bufsize&#41;;
       sceIoWaitAsync&#40;f,&asyncres&#41;;
Where to get the amount of bytes read after that? You'd think it would be in asyncres, but asyncres has the same values as f for some reason.
Shouldn't you wait also for sceIoOpenAsync completion?
Even if openasync returns success and a valid fd, that doesn't mean it completed the opening.

Code: Select all

	SceUID f;
	SceInt64 asyncres;

	if&#40;&#40;f=sceIoOpenAsync&#40;path,PSP_O_RDONLY,0777&#41;&#41;<0&#41;
		return NULL;

       sceIoWaitAsync&#40;f, &asyncres&#41;;
        if &#40;asyncres < 0&#41;
            return NULL;

        sceIoReadAsync&#40;f,buffer,bufsize&#41;;
      sceIoWaitAsync&#40;f,&asyncres&#41;;
Post Reply