Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add some config options #35

Merged
merged 6 commits into from Aug 23, 2023
Merged

Conversation

ITotalJustice
Copy link
Collaborator

@ITotalJustice ITotalJustice commented Jun 12, 2023

  • fix sdmc::FileExists not using path buffer
  • fix workflow
  • add per title pause/play support
  • save shuffle/ repeat mode to config file
  • save volume to config file
  • update libtesla

Not sure if you want to merge this, i didn't really follow your coding style. i can update it so that it does, if this is something you would like merged.

more config options can be added at a later date, such as button combo to change songs without having to use the overlay, change default music path, auto load music path on load, option to save playlists, option to load playlists.


the config options aren't checked for validity btw, i forgot to do that. this could be especially bad for volume. i'll have some more time again in a few days


i have noticed a fatal happens when closing sys-tune using the overlay. this doesn't happen in your latest release, but does if i build 512e274 from source. have you noticed this on your end? i am using latest everything in dkp.

- fix sdmc::FileExists not using path buffer
- fix workflow
- add per title pause/play support
- save shuffle/ repeat mode to config file
- save volume to config file
- update libtesla
@ITotalJustice
Copy link
Collaborator Author

this would also fix #22, #19 and #33.

@HookedBehemoth
Copy link
Owner

Thanks for this all.
The code style is fine, especially because my own taste refined since I wrote this.

Did you have issues with -O3 or did you not find any improvements? Also I don't believe this needs a reboot. Getting killed by another process might suck though.

I'll try to look at it more closely and merge this either this evening or tomorrow.

@ITotalJustice
Copy link
Collaborator Author

i changed O3 to O2 because the binary size was slightly smaller 396.1 KiB (405,560) vs 416.1 KiB (426,040).

sys-tune fails to be started again after being forcefully closed. haven't checked as to why yet.


do you know how to manage a process volume output? I see audout:a had SetProcessMasterVolume but it was removed in 11.0.0.

… wakeup

changed section for config title control from config to title to make the config.ini look nicer
also removed "overlay" from the display name.
@HookedBehemoth
Copy link
Owner

might need to call svcManageNamedPort with max_sessions = 0 to force the kernel to close the old port.

@HookedBehemoth
Copy link
Owner

I remember wasting a lot of time on trying to get audio controls for other processes working before. I sadly don't remember a lot and I haven't noted anything down either. audout:a moved to aud:a. Maybe that's off use? https://switchbrew.org/wiki/Audio_services#aud:a

Mary from Ryujinx knows a lot about the Audio. Could bug him about it.

@ITotalJustice
Copy link
Collaborator Author

I remember wasting a lot of time on trying to get audio controls for other processes working before. I sadly don't remember a lot and I haven't noted anything down either. audout:a moved to aud:a. Maybe that's off use? https://switchbrew.org/wiki/Audio_services#aud:a

Mary from Ryujinx knows a lot about the Audio. Could bug him about it.

aud:a looks good, thank you. i'll mess around after work or tomorrow. Otherwise yeah i'll ping Mary.

@ITotalJustice
Copy link
Collaborator Author

instead of displaying the tid of the current application, do you think it should display it's name instead?
i added some code for this:

    auto control_data = std::make_unique<NsApplicationControlData>();
    u64 control_data_size{};
    std::string tid_name;

    if (tid == 0x0100000000001000ULL) {
        tid_name = "qlaunch";
    } else if (R_SUCCEEDED(nsGetApplicationControlData(NsApplicationControlSource_Storage, tid, control_data.get(), sizeof(NsApplicationControlData), &control_data_size))) {
        tid_name = control_data->nacp.lang[0].name;
    } else {
        char id_buf[21]{};
        std::sprintf(id_buf, "%016lx", tid);
        tid_name = id_buf;
    }

this works fine. then i thought about displaying the game icon, seeing as i already fetch the entire nacp

    auto control_data = std::make_unique<NsApplicationControlData>();
    u64 control_data_size{};
    std::string tid_name;

    if (tid == 0x0100000000001000ULL) {
        tid_name = "qlaunch";
    } else if (R_SUCCEEDED(nsGetApplicationControlData(NsApplicationControlSource_Storage, tid, control_data.get(), sizeof(NsApplicationControlData), &control_data_size))) {
        tid_name = control_data->nacp.lang[0].name;
        const CapsScreenShotDecodeOption option{};
        std::vector<u8> image_bitmap(256*256*4);
        tsl::hlp::doWithSmSession(capsdcInitialize);
        if (R_SUCCEEDED(capsdcDecodeJpeg(256, 256, &option, control_data->icon, control_data_size - sizeof(NacpStruct), image_bitmap.data(), image_bitmap.size()))) {
            list->addItem(new ElmIcon(std::move(image_bitmap)));
        }
        capsdcExit();
    } else {
        char id_buf[21]{};
        std::sprintf(id_buf, "%016lx", tid);
        tid_name = id_buf;
    }

i don't yet scale down the icon, and i'm not sure its worth displaying tbh. if you did want this, would you want it to be the left side of the title_name?

2023061311220600-57B4628D2267231D57E0FC1078C0596D
2023061312161600-DECD6107E5477CFA2919C447E5B68FF0
2023061312220700-DECD6107E5477CFA2919C447E5B68FF0
2023061312222800-57B4628D2267231D57E0FC1078C0596D

@HookedBehemoth
Copy link
Owner

lol I forgot that you could use jpegdec for that too

@HookedBehemoth
Copy link
Owner

This used to have the boot2.flag but I decided to remove it because of the aborts with some games. See #10
Currently I expect users to start and stop it with the overlay.

Maybe the pmdmnt loop could be used to check against these titles and shut down the audio thread. Otherwise I fear a lot of issues will rain in again.

@ITotalJustice
Copy link
Collaborator Author

Ah okay. Well the stopping the sys-mod using the overlay fatals for me (only if built from source...), not sure how to fix that tbh.

I'll try force closing sys-tune when a title in a blacklist is launched. Hopefully that title is detected before the title opens the audio services that causes the fatal.

@HookedBehemoth
Copy link
Owner

Did you try to diagnose the issue? Is sys-tune itself crashing? Does it happen on master?
Maybe using pgl instead of pmdmnt helps but that requires 10.0.0+ (not sure how low it currently goes)

@ITotalJustice
Copy link
Collaborator Author

ITotalJustice commented Jun 16, 2023

No I didn't try and diagnose it. It does happen on master and also tried 512e274 which I believe is what you built your last release from. This doesn't happen using your latest release however so who knows, could be libnx or gcc change :/

And yes its sys_tune that causes the fatal

@monstrosities
Copy link

No I didn't try and diagnose it. It does happen on master and also tried 512e274 which I believe is what you built your last release from. This doesn't happen using your latest release however so who knows, could be libnx or gcc change :/

And yes its sys_tune that causes the fatal

I have the exact same issue with TriPlayer which is another audio player sysmodule: stopping the sysmodule from the overlay works fine with an older version I compiled but when I recompiled it last month it will now crash atmosphere when stopping the sysmodule from its overlay. My older version that doesn't crash is only a few months old so this has to be down to a recent compiler/library change.

…ing tune using overlay, fix crash with certian titles

changes:
- fix crash when closing sys-tune using the overlay
- add per title volume control
- add blacklist which closes sys-tune when a title is launched that would cause a fatal
- added aud:a, aud:d, audout:a, audout:d (someone submit to libnx pls thanks)
- reduced max tune volume from 2x down to 1x
- made heap static, reduces a couple of bytes in binary size
- added category headers to each section in gui
- added float support to minGlue (uses stdio and stdlib, sorry. replace it with something else to save 30kb binary size)
- pm helper now returns pid and tid
- addeds text and step blocks to volume slider
- only exit pmShell if it was actually init (was a nop before anyway so mainly style change)
- minor style changes (removed virtual, made classes final, made globals static (asside from symbol.hpp))
- reduce num voices to 2 (minimum)
- reduce mp3 chunk size from 96kb to 32kb
- increased heap from (1024 * 384) to (1024 * 460)
- return a unique ptr instead of raw ptr and then making a unique ptr from it
- fix Select() with shuffle enabled always selecting the first song.
- reduced shuffle_playlist memory usage by a lot
- remove boot2.flag

---

the heap increase is to stop a fatal when opening a blacklisted game, which closes audren and driver. when reopening audren and driver, sys-tune will fatal.

to reproduce this:
- set heap to 1024 * 459 or less
- add songs to playlist
- launch NES NSO
- close NES NSO
- enjoy the fatal (takes about 2-3 sec)

increasing by 1kb fixes the crash. opening and closing NES NSO multiple times doesn't cause the fatal with that extra 1kb. so idk. i just know it works now.
@ITotalJustice
Copy link
Collaborator Author

i think i'm finished with everything now.

somewhat fixes #10 and #31 as well

todo: search gbatemp for other titles users found
Copy link
Owner

@HookedBehemoth HookedBehemoth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly nit-pics

common/pm/pm.cpp Show resolved Hide resolved
sys-tune/Makefile Outdated Show resolved Hide resolved
sys-tune/source/impl/source.cpp Show resolved Hide resolved
{
"name" : "sys-tune",
"tid" : "4200000000000000",
"requires_reboot": true
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still true now? As discussed, if the IPC init fails, you should be able to get it to work again by calling svcManageNamedPort with session count 0.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to try this sorry

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in main.cpp i added:

// not found can happen if the service isn't started
// connection refused can happen is the service was terminated by pmshell
if (R_VALUE(rc) == KERNELRESULT(NotFound) || KERNELRESULT(ConnectionRefused)) {

and in ipc_server.c

Result ipcServerInit(IpcServer* server, const char* name, u32 max_sessions)
{
    if(max_sessions < 1 || max_sessions > (MAX_WAIT_OBJECTS - 1))
    {
        return MAKERESULT(Module_Libnx, LibnxError_BadInput);
    }

    server->srvName = smEncodeName(name);
    server->max = max_sessions + 1;
    server->count = 0;

    Result rc = svcManageNamedPort(&server->handles[0], server->srvName.name, max_sessions);
    if (R_FAILED(rc))
    {
        rc = svcManageNamedPort(&server->handles[0], server->srvName.name, 0);
        if(R_SUCCEEDED(rc))
        {
            svcCloseHandle(server->handles[0]);
            rc = svcManageNamedPort(&server->handles[0], server->srvName.name, max_sessions);
        }
    }

    if(R_SUCCEEDED(rc))
    {
        server->count = 1;
    }
    return rc;
}

this works for me. is this acceptable?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure the closehandle isn't needed.
Check atmosphere source to be sure.

Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
common/config/config.cpp Outdated Show resolved Hide resolved
common/pm/pm.cpp Outdated Show resolved Hide resolved
overlay/source/elm_overlayframe.hpp Show resolved Hide resolved
overlay/source/main.cpp Show resolved Hide resolved
@amitkulk123
Copy link

Any update to this PR and if it's getting merged? I've been running it on my Switch and it works great and autoplays the music whenever I close an app/game or wake it from sleep. I noticed it doesn't pause the music when I resume the app/game though so I have to manually pause it through the menu. But it works well aside from that.

@ITotalJustice
Copy link
Collaborator Author

Any update to this PR and if it's getting merged? I've been running it on my Switch and it works great and autoplays the music whenever I close an app/game or wake it from sleep. I noticed it doesn't pause the music when I resume the app/game though so I have to manually pause it through the menu. But it works well aside from that.

Sorry, I forgot about this pr. I have no free time anymore so I likely won't get around to working on this again.

As for the pausing, there should be an option in the menu to set a global default for all apps (including the home menu). If you set that to paused, then the music will be paused by default when you first launch any app. You can then change the config per game.

In your case, I think you'd want to set the global default to pause, then make the home menu play music. If this doesn't work then let me know. I won't be at my pc to fix stuff but I can still read code on my breaks 😄

@carr654
Copy link

carr654 commented Aug 21, 2023

Any update to this PR and if it's getting merged? I've been running it on my Switch and it works great and autoplays the music whenever I close an app/game or wake it from sleep. I noticed it doesn't pause the music when I resume the app/game though so I have to manually pause it through the menu. But it works well aside from that.

as an average user how would i go about using this as i was the one who put the request in with many and still looking forward to it. its a shame ijustice has no time now. just dont want this project to not have an outcome as it really would make the modding scene happy

@amitkulk123
Copy link

Any update to this PR and if it's getting merged? I've been running it on my Switch and it works great and autoplays the music whenever I close an app/game or wake it from sleep. I noticed it doesn't pause the music when I resume the app/game though so I have to manually pause it through the menu. But it works well aside from that.

as an average user how would i go about using this as i was the one who put the request in with many and still looking forward to it. its a shame ijustice has no time now. just dont want this project to not have an outcome as it really would make the modding scene happy

Same this is one of my most wanted features too because the Switch menu feels so odd without some music since I'm used to the Wii and 3DS menus.

So if you want to get the latest build from ITotalJustice, you can go here: https://github.com/ITotalJustice/sys-tune/actions and then click on the latest commit. From there, just download the sys-tune file under Artifacts and then put it on your Switch.

@carr654
Copy link

carr654 commented Aug 21, 2023

Any update to this PR and if it's getting merged? I've been running it on my Switch and it works great and autoplays the music whenever I close an app/game or wake it from sleep. I noticed it doesn't pause the music when I resume the app/game though so I have to manually pause it through the menu. But it works well aside from that.

as an average user how would i go about using this as i was the one who put the request in with many and still looking forward to it. its a shame ijustice has no time now. just dont want this project to not have an outcome as it really would make the modding scene happy

Same this is one of my most wanted features too because the Switch menu feels so odd without some music since I'm used to the Wii and 3DS menus.

So if you want to get the latest build from ITotalJustice, you can go here: https://github.com/ITotalJustice/sys-tune/actions and then click on the latest commit. From there, just download the sys-tune file under Artifacts and then put it on your Switch.

awesome thank you, how do i go about assigning music to the home menu or is it pretty self explanatory once i got it on my switch

@amitkulk123
Copy link

Any update to this PR and if it's getting merged? I've been running it on my Switch and it works great and autoplays the music whenever I close an app/game or wake it from sleep. I noticed it doesn't pause the music when I resume the app/game though so I have to manually pause it through the menu. But it works well aside from that.

as an average user how would i go about using this as i was the one who put the request in with many and still looking forward to it. its a shame ijustice has no time now. just dont want this project to not have an outcome as it really would make the modding scene happy

Same this is one of my most wanted features too because the Switch menu feels so odd without some music since I'm used to the Wii and 3DS menus.
So if you want to get the latest build from ITotalJustice, you can go here: https://github.com/ITotalJustice/sys-tune/actions and then click on the latest commit. From there, just download the sys-tune file under Artifacts and then put it on your Switch.

awesome thank you, how do i go about assigning music to the home menu or is it pretty self explanatory once i got it on my switch

So you just need to put all your music on the /music on your sd card and then you can add it to your playlist and play it by opening the tesla menu

@carr654
Copy link

carr654 commented Aug 21, 2023

So you just need to put all your music on the /music on your sd card and then you can add it to your playlist and play it by opening the tesla menu

okay thank you. just done that but it plays during game which i dont want it to. im guessing thats because its not a finished build. or i might be missing something to assign it just to the home menu.

edit: nvm i did it yay hello menu music

@amitkulk123
Copy link

So you just need to put all your music on the /music on your sd card and then you can add it to your playlist and play it by opening the tesla menu

okay thank you. just done that but it plays during game which i dont want it to. im guessing thats because its not a finished build. or i might be missing something to assign it just to the home menu.

Same thing happens for me. I just manually pause when in-game. I’ll try to see if I can fix it so that it pauses when in-game but I’m not that experienced with this stuff.

@carr654
Copy link

carr654 commented Aug 21, 2023

Same thing happens for me. I just manually pause when in-game. I’ll try to see if I can fix it so that it pauses when in-game but I’m not that experienced with this stuff.

i did what i justice said turn default to tune default to pause. and it pauses th music. im messing with the sounds now to get the song length correct

@ITotalJustice
Copy link
Collaborator Author

Any update to this PR and if it's getting merged? I've been running it on my Switch and it works great and autoplays the music whenever I close an app/game or wake it from sleep. I noticed it doesn't pause the music when I resume the app/game though so I have to manually pause it through the menu. But it works well aside from that.

Sorry, I forgot about this pr. I have no free time anymore so I likely won't get around to working on this again.

As for the pausing, there should be an option in the menu to set a global default for all apps (including the home menu). If you set that to paused, then the music will be paused by default when you first launch any app. You can then change the config per game.

In your case, I think you'd want to set the global default to pause, then make the home menu play music. If this doesn't work then let me know. I won't be at my pc to fix stuff but I can still read code on my breaks 😄

Please follow the steps here to have it so that it doesn't play music by default. Then you can enable music on a per title basis, including the home menu

@carr654
Copy link

carr654 commented Aug 21, 2023

Please follow the steps here to have it so that it doesn't play music by default. Then you can enable music on a per title basis, including the home menu

sorry to bother you and i know this is not technically a release and your not working on it now. how would i go about it always being sucessful for menu music for example i have the zelda song thats 2 mins ish. once i first play the song and then enter a game it stops which is good. but when its near the middle of the song it doesnt do that. would i just have to trim down the song and put it on loop if i can? for it to always be successful in stopping when in game

edit: again nvm it just needs time to recognise. thank you for just getting a temp one done to experiment with its works good :)

only 2 months late :sanic:
@HookedBehemoth HookedBehemoth merged commit 650a857 into HookedBehemoth:master Aug 23, 2023
@HookedBehemoth
Copy link
Owner

Thank you very much <3

@HookedBehemoth
Copy link
Owner

Was there a blacklist.ini you had prepared so I can throw that into a release?

@ITotalJustice
Copy link
Collaborator Author

Was there a blacklist.ini you had prepared so I can throw that into a release?

No, I embedded the games TID into the app itself

const u64 blacklist[] = {
though maybe I should've added that list to the ini.

Iirc I was worried about the ini not being read fast enough before the fatal would occur, so I first tested using a lut. I'm pretty sure I did test reading from an ini file and it was fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants