Skip to content

Commit

Permalink
resolve review
Browse files Browse the repository at this point in the history
only 2 months late :sanic:
  • Loading branch information
ITotalJustice authored and HookedBehemoth committed Aug 23, 2023
1 parent ecd6627 commit 650a857
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 34 deletions.
2 changes: 0 additions & 2 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"${DEVKITPRO}/libnx/include/",
"${DEVKITPRO}/portlibs/switch/include/",
"${workspaceFolder}/sys-tune/nxExt/include/",
"${workspaceFolder}/sys-tune/source/",
"${workspaceFolder}/overlay/lib/include/",
"${workspaceFolder}/overlay/source/",
"${workspaceFolder}/ipc/",
"${workspaceFolder}/common/"
],
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export GITHASH := $(shell git rev-parse --short HEAD)
export VERSION := 2.0.0
export API_VERSION := 3
export API_VERSION := 4
export WANT_FLAC := 1
export WANT_MP3 := 1
export WANT_WAV := 1
Expand All @@ -11,8 +11,8 @@ clean:
$(MAKE) -C sys-tune/nxExt clean
$(MAKE) -C overlay clean
$(MAKE) -C sys-tune clean
rm -rf dist
rm -f sys-tune-*-*.zip
-rm -r dist
-rm sys-tune-*-*.zip

overlay:
$(MAKE) -C overlay
Expand All @@ -30,6 +30,6 @@ dist: all
cp overlay/sys-tune-overlay.ovl dist/switch/.overlays/
cp sys-tune/toolbox.json dist/atmosphere/contents/4200000000000000/
cd dist; zip -r sys-tune-$(VERSION)-$(GITHASH).zip ./**/; cd ../;
hactool -t nso sys-tune/sys-tune.nso
-hactool -t nso sys-tune/sys-tune.nso

.PHONY: all overlay module
4 changes: 2 additions & 2 deletions common/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ auto get_tid_str(u64 tid) -> const char* {
return buf;
}

} // namespace
}

auto get_shuffle() -> bool {
return ini_getbool("config", "shuffle", false, CONFIG_PATH);
Expand Down Expand Up @@ -111,4 +111,4 @@ void set_title_blacklist(u64 tid, bool value) {
ini_putl("blacklist", get_tid_str(tid), value, BLACKLIST_PATH);
}

} // namespace config
}
2 changes: 1 addition & 1 deletion common/config/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ void set_default_title_volume(float value);
auto get_title_blacklist(u64 tid) -> bool;
void set_title_blacklist(u64 tid, bool value);

} // namespace config
}
22 changes: 11 additions & 11 deletions common/pm/pm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace {
constexpr u64 QLAUNCH_TITLE_ID{0x0100000000001000ULL};
u64 CURRENT_TITLE_ID{};

} // namespace
}

namespace pm {

Expand All @@ -24,28 +24,28 @@ void Exit() {
}

// SOURCE: https://github.com/retronx-team/sys-clk/blob/570f1e5fe10b253eff0c8fda1bb893bb620af052/sysmodule/src/process_management.cpp#L37
void getCurrentPidTid(u64& pid_out, u64& tid_out) {
void getCurrentPidTid(u64* pid_out, u64* tid_out) {
Result rc{};
if (R_SUCCEEDED(rc = pmdmntGetApplicationProcessId(&pid_out))) {
if (0x20f == pminfoGetProgramId(&tid_out, pid_out)){
tid_out = QLAUNCH_TITLE_ID;
if (R_SUCCEEDED(rc = pmdmntGetApplicationProcessId(pid_out))) {
if (0x20f == pminfoGetProgramId(tid_out, *pid_out)){
*tid_out = QLAUNCH_TITLE_ID;
}
} else if (rc == 0x20f) {
tid_out = QLAUNCH_TITLE_ID;
*tid_out = QLAUNCH_TITLE_ID;
} else {
tid_out = CURRENT_TITLE_ID;
*tid_out = CURRENT_TITLE_ID;
}
}

auto PollCurrentPidTid(u64& pid_out, u64& tid_out) -> bool {
auto PollCurrentPidTid(u64* pid_out, u64* tid_out) -> bool {
getCurrentPidTid(pid_out, tid_out);

if (tid_out != CURRENT_TITLE_ID) {
CURRENT_TITLE_ID = tid_out;
if (*tid_out != CURRENT_TITLE_ID) {
CURRENT_TITLE_ID = *tid_out;
return true;
}

return false;
}

} // namespace pm
}
6 changes: 3 additions & 3 deletions common/pm/pm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace pm {

auto Initialize() -> Result;
void Exit();
void getCurrentPidTid(u64& pid_out, u64& tid_out);
auto PollCurrentPidTid(u64& pid_out, u64& tid_out) -> bool;
void getCurrentPidTid(u64* pid_out, u64* tid_out);
auto PollCurrentPidTid(u64* pid_out, u64* tid_out) -> bool;

} // namespace pm
}
2 changes: 1 addition & 1 deletion overlay/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ CFLAGS := -g -Wall -Wno-format-truncation -O2 -ffunction-sections \
CFLAGS += $(INCLUDE) -DVERSION=\"v$(APP_VERSION)\" -DTUNE_API_VERSION=$(API_VERSION) \
$(WANT_FLAGS)

CXXFLAGS := $(CFLAGS) -fno-exceptions -std=gnu++23
CXXFLAGS := $(CFLAGS) -fno-exceptions -std=c++23

ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
Expand Down
2 changes: 1 addition & 1 deletion overlay/source/gui_browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace {

char path_buffer[FS_MAX_PATH];

} // namespace
}


BrowserGui::BrowserGui()
Expand Down
2 changes: 1 addition & 1 deletion overlay/source/gui_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace {

char result_buffer[10];

} // namespace
}

ErrorGui::ErrorGui(const char *msg, Result rc) : m_msg(msg) {
if (rc) {
Expand Down
2 changes: 1 addition & 1 deletion overlay/source/gui_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tsl::elm::Element *MainGui::createUI() {
auto list = new tsl::elm::List();

u64 pid{}, tid{};
pm::getCurrentPidTid(pid, tid);
pm::getCurrentPidTid(&pid, &tid);

/* Current track. */
list->addItem(this->m_status_bar, tsl::style::ListItemDefaultHeight * 2);
Expand Down
6 changes: 4 additions & 2 deletions overlay/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SysTuneOverlay final : public tsl::Overlay {

// don't open sys-tune if blacklisted title is active!
u64 pid{}, tid{};
pm::getCurrentPidTid(pid, tid);
pm::getCurrentPidTid(&pid, &tid);

if (config::get_title_blacklist(tid)) {
this->msg =
Expand All @@ -33,7 +33,9 @@ class SysTuneOverlay final : public tsl::Overlay {

Result rc = tuneInitialize();

if (R_VALUE(rc) == KERNELRESULT(NotFound)) {
// 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)) {
u64 pid = 0;
const NcmProgramLocation programLocation{
.program_id = 0x4200000000000000,
Expand Down
2 changes: 1 addition & 1 deletion sys-tune/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ CFLAGS := -g -Wall -O2 -ffunction-sections \
CFLAGS += $(INCLUDE) -DTUNE_API_VERSION=$(API_VERSION) \
$(WANT_FLAGS)

CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++23
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=c++23

ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
Expand Down
11 changes: 10 additions & 1 deletion sys-tune/nxExt/src/ipc_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ Result ipcServerInit(IpcServer* server, const char* name, u32 max_sessions)
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;
Expand Down Expand Up @@ -201,4 +211,3 @@ Result ipcServerProcess(IpcServer* server, IpcServerRequestHandler handler, void

return rc;
}

4 changes: 2 additions & 2 deletions sys-tune/source/impl/music_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ namespace tune::impl {
return 0;
}

} // namespace
}

Result Initialize(std::vector<PlaylistEntry>* playlist, std::vector<PlaylistID>* shuffle, PlaylistEntry* current) {
g_playlist = playlist;
Expand Down Expand Up @@ -444,7 +444,7 @@ namespace tune::impl {

while (g_should_run) {
u64 pid{}, new_tid{};
if (pm::PollCurrentPidTid(pid, new_tid)) {
if (pm::PollCurrentPidTid(&pid, &new_tid)) {
// check if title is blacklisted
g_close_audren = config::get_title_blacklist(new_tid);

Expand Down
2 changes: 1 addition & 1 deletion sys-tune/toolbox.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name" : "sys-tune",
"tid" : "4200000000000000",
"requires_reboot": true
"requires_reboot": false
}

0 comments on commit 650a857

Please sign in to comment.