OPL (Open PS2 Loader)

PS2 Open PS2 Loader v1.1.0

The problem is somewhere in these functions (or any of the functions they call):
Code:
void sysExecExit(void)
{
if (gEnableSFX) {
//wait 70ms for confirm sound to finish playing before exit
guiDelay(0070);
}
//Deinitialize without shutting down active devices.
deinit(NO_EXCEPTION, IO_MODE_SELECTED_ALL);
Exit(0);
}

...

void deinit(int exception, int modeSelected)
{
// block all io ops, wait for the ones still running to finish
ioBlockOps(1);
guiExecDeferredOps();

if (gEnableSFX) {
gEnableSFX = 0;
}
audsrv_quit();

#ifdef PADEMU
ds34usb_reset();
ds34bt_reset();
#endif
unloadPads();

deinitAllSupport(exception, modeSelected);

ioEnd();
guiEnd();
menuEnd();
lngEnd();
thmEnd();
rmEnd();
configEnd();
}
Removing the sfx delay time fixes the issue. Removing audsrv_quit, deinitAllSupport or guiEnd may also solve the issue. Increasing the delay time also increases the chance of failure.
I'm just doing trial and error, but have not found the root-cause yet.
 
  • Like
Reactions: TnA
is it due to guiDelay() being written a bit...wanky? I just tested with
Code:
void guiDelay(int milliSeconds)
{
    clock_t timeEnd = clock() + milliSeconds * (CLOCKS_PER_SEC / 1000);
    while (clock() < timeEnd) {}
    toggleSfx = 0;
}
and successfully exited to browser 4x with SFX enabled, USB Auto, 1080i & the delay remaining in sysExecExit
 
is it due to guiDelay() being written a bit...wanky? I just tested with
Code:
void guiDelay(int milliSeconds)
{
    clock_t timeEnd = clock() + milliSeconds * (CLOCKS_PER_SEC / 1000);
    while (clock() < timeEnd) {}
    toggleSfx = 0;
}
There's a lot of things wanky about this small function:
  1. If it's a common "gui" function, then the "toggleSfx = 0;" does not belong in the that function. It's name would be, sfxMDelayAndUnblock() or something. That would describe what the purpose of the function is. Calling this function for other delay tasks would be dangerous, becouse it unblocks the sfx.
  2. The same with "toggleSfx". What sfx does it toggle? What does a value of 0 or 1 mean? It looks to me like it's used to temporarily block sound effects, for instance when in the "about" page. Naming it "blockSfx" would make more sense. Then 1=sfx-blocked, 0=sfx-not-blocked. Aside from the name, it should not even exist. The SFX_CURSOR should sound always (and only) "on-change", and we know when the cursor position changes.
  3. guiDelay is being called 2x with values of 70ms, to let sounds "finish" playing. I cannot immagine any sounds playing that short. The 1200ms for the gFadeDelay does make sense, timewise, but:
  4. We should not delay/sleep in the gui thread. Sleeping 1200ms in the gui thread, means freezing the gui for 1.2seconds * 60fps = 72frames. Also the guiHandleDeferredOps is not called 72 times. So background tasks can stall.
Perhaps guiDelay should be a deferred op, and just like gInitComplete we can wait for it's completion? But other than that, I don't see why OPL would freeze on guiDelay on exit. Unless the clock function (introduced in the newlib port) has a bug.
 
I've cleaned up "some" of the wank there lol.. but I spent most of my time in dia.c trying to find this...
The SFX_CURSOR should sound always (and only) "on-change", and we know when the cursor position changes.
since the dialog windows are the only ones with scrolling hacks.. all I could find was this group of functions.. which all work fine other than diaGetFirstControl() because even when there are no other options to scroll to.. this is called.. ie About Page.. maybe I'm missing something obvious?

guiDelay is being called 2x with values of 70ms, to let sounds "finish" playing. I cannot immagine any sounds playing that short. The 1200ms for the gFadeDelay does make sense, timewise, but:
Confirm sfx is roughly 60ms and recommend to be so.. I made the delay 70ms to give a small amount of leeway for custom sfx..

gFadeDelay is for Boot Sound, probably already know that.. by the time the logo is ready to fade out there is still 1.2s of the boot sound to go for the default internal that was the original purpose of the function; to extend the amount of time the logo is on the screen before starting to fade so it can sync up with the end of the boot sound... somewhere along the way the function got reused as well as the toggleSfx variable (which is why it's so vague since it was reused multiple times for different purposes).. down to nothing more than.. not really knowing any better at the time and just being a bit lazy after 3 months of working on the same thing and wanting it to just Work! Lol. Hence hacks..

I've tried to go back since and clean some of it up as I've learnt a little bit more.. hopefully this'll be the last time it's needed.
 
I haven't been on GitHub for the past few months.
Are we close to a new stable release? ;)

The newlib-support along with all the glorious new features and updates since 0.9.3 make it worth it IMO and I think BDM-Merge is not going to happen too soon, so a stable release-build would be very much preferred!
 
After the merge of the newlib appeared some serious problems, specially the exit freeze of
the program, which looks hard to fix.

Best regards.
 
  • Like
Reactions: TnA
Can also someone try this version of an OPL.
It has these fixes:
  • Simplify diaExecuteDialog sfx
  • Cleanup sfx code
    - Remove guiDelay
    - Fix guiIntroLoop
    - move all audsrv* code into sound driver
  • Cleanup guiDrawBusy and guiRenderGreeting
  • sound: check interface functions if initialized or not
  • Calculate sound delays, init sound in init, control sound from introloop
  • sound: allow sfxInit to continue if audio lib is init
  • Improve sound duration calculation
  • Add fadeDuration calculation
  • sound: update default sfx to include number of samples in header & update duration calculation function
  • fix notifications timer
  • sound: remove unneeded code, restore deferred calls to audio init
But mainly it do not hangs\freeze when I want to exit from OPL.
Maybe anyone else can confirm it...

Source\feedback:
https://github.com/ps2homebrew/Open-PS2-Loader/pull/275.
 

Attachments

Can also someone try this version of an OPL.
It has these fixes:
  • Simplify diaExecuteDialog sfx
  • Cleanup sfx code
    - Remove guiDelay
    - Fix guiIntroLoop
    - move all audsrv* code into sound driver
  • Cleanup guiDrawBusy and guiRenderGreeting
  • sound: check interface functions if initialized or not
  • Calculate sound delays, init sound in init, control sound from introloop
  • sound: allow sfxInit to continue if audio lib is init
  • Improve sound duration calculation
  • Add fadeDuration calculation
  • sound: update default sfx to include number of samples in header & update duration calculation function
  • fix notifications timer
  • sound: remove unneeded code, restore deferred calls to audio init
But mainly it do not hangs\freeze when I want to exit from OPL.
Maybe anyone else can confirm it...

Source\feedback:
https://github.com/ps2homebrew/Open-PS2-Loader/pull/275.

I'll do some tests tomorrow. Btw just starting it before, I noticed a couple things:

- it seems a little slower to start compared to rev.1440 (not a problem anyway, if it is for making it working better is ok)

- Have to be restored at least a second of lag to the auto-launch function. Or the possibility to move the cursor as soon as Game-list appears. As it is now, Auto-launch set to 1 is useless, since you can't do nothing but autostart the game (You have to boot a previous OPL version for being able to access the settings menu and change the auto-launch timer).

EDIT: I'm not 100% sure it's slower on booting, maybe is just 'cause the OPL screen appears sooner, so it seems that loading is longer, I'll time it :)
 
Last edited:
Can also someone try this version of an OPL.
It has these fixes:
  • Simplify diaExecuteDialog sfx
  • Cleanup sfx code
    - Remove guiDelay
    - Fix guiIntroLoop
    - move all audsrv* code into sound driver
  • Cleanup guiDrawBusy and guiRenderGreeting
  • sound: check interface functions if initialized or not
  • Calculate sound delays, init sound in init, control sound from introloop
  • sound: allow sfxInit to continue if audio lib is init
  • Improve sound duration calculation
  • Add fadeDuration calculation
  • sound: update default sfx to include number of samples in header & update duration calculation function
  • fix notifications timer
  • sound: remove unneeded code, restore deferred calls to audio init
But mainly it do not hangs\freeze when I want to exit from OPL.
Maybe anyone else can confirm it...

Source\feedback:
https://github.com/ps2homebrew/Open-PS2-Loader/pull/275.
@jolek, thank you very much.

I have done several tests with the internal hard drive.

Using 720p Hires, notifications, and all activated devices at the same time, (HDD, ETH, USB).

I have quit the program and restarted 10 times in a row and i have not received any hangs when exiting.
While in the last beta 1502 after leaving 6 or 7 times in a row i had a freeze when leaving.
So it seems that the freeze exit problem has been fixed with these changes.

But something strange or a new bug occurs with the loading icon with these changes.

Without these changes, while the initial screen with the OPL logo lasts the loading, icon does not appear, it
only appears 1 or 2 seconds when the initial screen makes the transition to the games menu and the
startup sfx sounds.

With these changes, the loading icon appears from the beginning with the logo loading all the time.

If a custom theme is used, the loading icon of the custom theme itself is joined with the end of the default loading icon, when the default icon should never appear with a custom theme.

These problems are more evident when ETH is activated, since it causes it to take longer to load everything.

In the case of using the classic plasma custom theme and having ETH activated, the default icon in addition
to being shown all the time, in the end it makes a jump moving down to the screen, which looks like a failure
and ugly.

All these problems with the loading icon do not occur without these new changes, although the most
important thing is that it seems to solve the hang of the exit of the program, i think this should be to
take a look for see what happens with the load icon.

It seems that the startup sound takes a long time to activate, it would be better if it were heard synchronized
when the logo appears, but this is already a personal taste.

Best regards.
 
But something strange or a new bug occurs with the loading icon with these changes.

Without these changes, while the initial screen with the OPL logo lasts the loading, icon does not appear, it
only appears 1 or 2 seconds when the initial screen makes the transition to the games menu and the
startup sfx sounds.

With these changes, the loading icon appears from the beginning with the logo loading all the time.

If a custom theme is used, the loading icon of the custom theme itself is joined with the end of the default loading icon, when the default icon should never appear with a custom theme.

These problems are more evident when ETH is activated, since it causes it to take longer to load everything.

In the case of using the classic plasma custom theme and having ETH activated, the default icon in addition
to being shown all the time, in the end it makes a jump moving down to the screen, which looks like a failure
and ugly.

All these problems with the loading icon do not occur without these new changes, although the most
important thing is that it seems to solve the hang of the exit of the program, i think this should be to
take a look for see what happens with the load icon.
All these issues with the loading icon are technically not issues but actually the way the program was originally meant to be, when I added SFX I put a hack in so that the loading icon doesn't appear due to it being stalled (not moving) because of the way I was freezing the GUI in order to sync up the logo fade with the end of the boot sound.. in this build the hack is removed and the sync is done more correctly.. the loading icon 'jumping' is simply a result of the x/y pos being different from the default theme since it is then showing the icon for the custom theme..

If you boot up 0.9.3 or any build before SFX you will see these things are present and are simply being reverted by removing hackish code.


It seems that the startup sound takes a long time to activate, it would be better if it were heard synchronized
when the logo appears, but this is already a personal taste.
If the sound is played as soon as the logo is visible you could be staring at the logo still long after the sound has finished which looks sounds and feels weird imo.. the way it currently works is the sound is played at a point when it is able to sync up so when the logo finishes fading out the boot sound also finishes playing.

Current changes are 'as is' as I don't have time for anything further. Cheers guys
 
All these issues with the loading icon are technically not issues but actually the way the program was originally meant to be, when I added SFX I put a hack in so that the loading icon doesn't appear due to it being stalled (not moving) because of the way I was freezing the GUI in order to sync up the logo fade with the end of the boot sound.. in this build the hack is removed and the sync is done more correctly.. the loading icon 'jumping' is simply a result of the x/y pos being different from the default theme since it is then showing the icon for the custom theme..

If you boot up 0.9.3 or any build before SFX you will see these things are present and are simply being reverted by removing hackish code.
Aha, i see, yes i tried 0.9.3 and you are right, i understand now, thank you for the detailed explanation.

If the sound is played as soon as the logo is visible you could be staring at the logo still long after the sound has finished which looks sounds and feels weird imo.. the way it currently works is the sound is played at a point when it is able to sync up so when the logo finishes fading out the boot sound also finishes playing.

Current changes are 'as is' as I don't have time for anything further. Cheers guys
I see and understand this also, but this is because the duration of the sound is very short, it would be better
to start a sound that lasted from the beginning of the logo until it fades.
I have some startup sounds with a longer duration and i would like to test and experiment with them, i would like
to be able to place a sound that I have from the beginning that the logo appears.
The fact of sound duration is due to some technical limitation? Is there a limit in seconds, or length of the sound
file, or memory limitation that the OPL cannot address?
Well, if you don't have time, i understand it, thank you very much for your work @Kra.

I will wait a little longer to see if anyone else will report that there is no freeze with the program exit, and then i
will merge the changes to the repository.

Best regards.
 
- Have to be restored at least a second of lag to the auto-launch function. Or the possibility to move the cursor as soon as Game-list appears. As it is now, Auto-launch set to 1 is useless, since you can't do nothing but autostart the game (You have to boot a previous OPL version for being able to access the settings menu and change the auto-launch timer).

I edited my previous messagge, obviously I meant Auto-launch set to 1 (not zero). I like how fast this version (1505) boot the game, but it should be restored the possibility to move the cursor as soon as the list appears.
 
@El_Patas
The problem with that is, every user has a different length of time the logo will be displayed based on which devices are being initialised and how many games they have on each device etc..

In terms of limitations for SFX, file size would be roughly 400-500KiB which I'll say is roughly 10seconds, I haven't fully tested to see the limit.. but at a certain point it will be too much for the SPU and the console will just freeze.

My console with iHDD for example with HDD list cache 'On' takes about 50 seconds to boot up so it's not really possible with ADPCM to have sound the whole time.. but that's just specific to my console anyway, everyone will have varying boot up times.

@Peppe90
Last play auto start was altered by @Maximus32 in this PR perhaps he will be able to add another second delay later on.
 
@El_Patas
My console with iHDD for example with HDD list cache 'On' takes about 50 seconds to boot up

What? It should take 50 secs. to boot a full 2tb HDD with cache list Off. Enabling it should take a few seconds (it takes 4 seconds for 450 games).
Maybe it depends on other things, where OPL partition is placed (I've created it right away after formatting and never enlarged it), cover arts (I don't use them).

What if you disable the cache list, how much it takes for loading your list?
 
The OPL-Partition SHOULD BE created RIGHT AT THE BEGINNING (of the HDD-Setup-process), right after a wLE HDD-Format (and likely an FHDB install)!

This definetly makes a difference!
 
What? It should take 50 secs. to boot a full 2tb HDD with cache list Off. Enabling it should take a few seconds (it takes 4 seconds for 450 games).
I must've been thinking of the boot time before game list cache, tbh I haven't turned the ps2 on for a while.. still though, point is everyone will have different boot times.
 
The OPL-Partition SHOULD BE created RIGHT AT THE BEGINNING (of the HDD-Setup-process), right after a wLE HDD-Format (and likely an FHDB install)!

This definetly makes a difference!

That has been tested?? I seems to remember @Tupakaveli checked it, not sure though.

Anyway I think it is so, since he has a longer loading time than me. OPL has just to read the text file, so it shouldn't make a difference how much games you have installed. So the loading time difference is probably due to the +OPL partition different position (as i said I have it right at the beginning, 4 seconds loading).

I must've been thinking of the boot time before game list cache, tbh I haven't turned the ps2 on for a while.. still though, point is everyone will have different boot times.

Enabling it I think you'll have a much shorter loading time. Even if you have the OPL partition in the middle of the HDD you'll get less than 15 secs. for sure.
 
That has been tested?? I seems to remember @Tupakaveli checked it, not sure though.

Anyway I think it is so, since he has a longer loading time than me. OPL has just to read the text file, so it shouldn't make a difference how much games you have installed. So the loading time difference is probably due to the +OPL partition different position (as i said I have it right at the beginning, 4 seconds loading).



Enabling it I think you'll have a much shorter loading time. Even if you have the OPL partition in the middle of the HDD you'll get less than 15 secs. for sure.

I did test it and it definitely does make a difference.

Krah and I have identical HDDs, full 2Tbs. He is thinking of the boot time without HDD Games List Cache enabled, which is ~50 seconds. It's ~20 seconds enabled and we have the +OPL partition directly after the system partitions.
 
I did test it and it definitely does make a difference.

Krah and I have identical HDDs, full 2Tbs. He is thinking of the boot time without HDD Games List Cache enabled, which is ~50 seconds. It's ~20 seconds enabled and we have the +OPL partition directly after the system partitions.

I don't have system partitions (mbr aside, I created HDLoader Settings partition first, then +OPL one, both 128MB).

I know the APA partition makes the searching quite slow, so it could be that not having system partitions plus having a only 128MB +OPL partition makes some difference. But 20 secs. it's a huge difference, so probably number of installed games matters even using the game cache file (I don't know why).
 

Similar threads

Back
Top