Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Data/Xips/default.xip
Binary file not shown.
43 changes: 33 additions & 10 deletions theseus/desktop/audio_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <sys/stat.h>
#include "host.h"

Expand Down Expand Up @@ -819,7 +820,13 @@ static bool ProbeSong(mpv_handle* h, const std::string& path, Song& out)
mpv_event* ev = mpv_wait_event(h, 5.0);
if (!ev) break;
if (ev->event_id == MPV_EVENT_FILE_LOADED) break;
if (ev->event_id == MPV_EVENT_END_FILE) return false;
// "replace" ends the previous probe's file first. That one's a stop,
// not this file failing.
if (ev->event_id == MPV_EVENT_END_FILE) {
mpv_event_end_file* ef = (mpv_event_end_file*)ev->data;
if (ef && ef->reason == MPV_END_FILE_REASON_STOP) continue;
return false;
}
if (ev->event_id == MPV_EVENT_SHUTDOWN) return false;
if (ev->event_id == MPV_EVENT_NONE) return false;
}
Expand Down Expand Up @@ -867,7 +874,7 @@ struct DBEntry {
typedef std::map<std::string, DBEntry> DBMap;

static const uint32_t kMusicDBMagic = 0x42444D54; // 'TMDB'
static const uint32_t kMusicDBVersion = 2;
static const uint32_t kMusicDBVersion = 3; // 3: drops entries a broken probe left without tags

static void DB_WriteU32(FILE* fp, uint32_t v) { fwrite(&v, 4, 1, fp); }
static void DB_WriteI32(FILE* fp, int32_t v) { fwrite(&v, 4, 1, fp); }
Expand Down Expand Up @@ -1075,17 +1082,23 @@ int DashMusic_Scan(const char* musicRoot)
if (probeMpv && ProbeSong(probeMpv, fullPath, song))
probedCount++;
}
DBEntry e;
SongToDB(song, e);
newDb[fullPath] = e;
// A failed probe isn't cached, so it gets another try next scan.
if (song.probed) {
DBEntry e;
SongToDB(song, e);
newDb[fullPath] = e;
}
return song;
};

int nextID = 1;

auto ProcessSoundtrackDir = [&](const char* dirName) {
// A folder of songs is a soundtrack. A folder of folders (Artist/Album)
// makes each album one, one level down.
std::function<void(const std::string&, const char*, bool)> ProcessSoundtrackDir =
[&](const std::string& parent, const char* dirName, bool topLevel) {
if (dirName[0] == '.') return;
std::string stPath = std::string(musicRoot) + "/" + dirName;
std::string stPath = parent + "/" + dirName;
struct stat st;
if (stat(stPath.c_str(), &st) != 0 || !S_ISDIR(st.st_mode)) return;

Expand All @@ -1110,12 +1123,22 @@ int DashMusic_Scan(const char* musicRoot)
soundtrack.songs.push_back(BuildSong(full, StripExtension(songName)));
};

std::vector<std::string> subDirs;
HostDir* stDir = Host_OpenDir(stPath.c_str());
if (stDir) {
char songName[260];
while (Host_ReadDir(stDir, songName, sizeof(songName), NULL)) ProcessSongFile(songName);
bool subIsDir = false;
while (Host_ReadDirType(stDir, songName, sizeof(songName), &subIsDir)) {
if (subIsDir) { if (songName[0] != '.') subDirs.push_back(songName); }
else ProcessSongFile(songName);
}
Host_CloseDir(stDir);
}
if (soundtrack.songs.empty() && topLevel) {
for (size_t i = 0; i < subDirs.size(); i++)
ProcessSoundtrackDir(stPath, subDirs[i].c_str(), false);
return;
}

if (!soundtrack.songs.empty()) {
if (soundtrack.albumPath.empty() && !fallbackArt.empty())
Expand Down Expand Up @@ -1178,7 +1201,7 @@ int DashMusic_Scan(const char* musicRoot)
bool isDir;
while (Host_ReadDirType(rootDir, entryName, sizeof(entryName), &isDir)) {
if (entryName[0] == '.') continue;
if (isDir) ProcessSoundtrackDir(entryName);
if (isDir) ProcessSoundtrackDir(musicRoot, entryName, true);
else if (IsM3UFile(entryName)) ProcessM3UFile(entryName);
else ProcessLooseFile(entryName);
}
Expand Down Expand Up @@ -1209,7 +1232,7 @@ int DashMusic_Scan(const char* musicRoot)
DB_Save(DB_GetPath().c_str(), newDb);

std::sort(s_soundtracks.begin(), s_soundtracks.end(),
[](const Soundtrack& a, const Soundtrack& b) { return a.name < b.name; });
[](const Soundtrack& a, const Soundtrack& b) { return strcasecmp(a.name.c_str(), b.name.c_str()) < 0; });

if (s_soundtracks.size() > 0)
fprintf(stderr, "[Audio] %zu soundtracks loaded (%d cached, %d probed)\n",
Expand Down
13 changes: 9 additions & 4 deletions theseus/desktop/cdaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,26 +148,31 @@ static int s_pendingChapter = -1;
static double s_timePos = 0.0;
static double s_chapterStart = 0.0;

static void CdBack_Init()
// Most sessions never play a disc, so the handle waits for the first one.
static void CdBack_Init() {}

static bool CdBack_Open()
{
if (s_mpv) return true;
s_mpv = mpv_create();
if (!s_mpv) { fprintf(stderr, "[CdAudio] mpv_create failed\n"); return; }
if (!s_mpv) { fprintf(stderr, "[CdAudio] mpv_create failed\n"); return false; }
mpv_set_option_string(s_mpv, "video", "no");
mpv_set_option_string(s_mpv, "audio-display", "no");
mpv_set_option_string(s_mpv, "keep-open", "yes");
mpv_set_option_string(s_mpv, "terminal", "no");
if (mpv_initialize(s_mpv) < 0) {
fprintf(stderr, "[CdAudio] mpv_initialize failed\n");
mpv_destroy(s_mpv); s_mpv = nullptr; return;
mpv_destroy(s_mpv); s_mpv = nullptr; return false;
}
mpv_observe_property(s_mpv, 0, "time-pos", MPV_FORMAT_DOUBLE);
return true;
}

static void CdBack_Shutdown() { if (s_mpv) { mpv_destroy(s_mpv); s_mpv = nullptr; } }

bool CdAudio_Play(int track)
{
if (!s_mpv || track < 1) return false;
if (track < 1 || !CdBack_Open()) return false;
s_pendingChapter = track - 1;
s_playing = true; s_paused = false; s_timePos = 0.0; s_chapterStart = 0.0;
for (int i = 0; i < track - 1 && i < s_trackCount; ++i) s_chapterStart += s_trackDurations[i];
Expand Down
1 change: 0 additions & 1 deletion theseus/desktop/dashapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,6 @@ bool InitApp()
CallFunction(g_pObject, "initialize");
PreloadSkinTextures();

fprintf(stdout, "[InitApp] Done!\n");
fflush(stdout);
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions theseus/desktop/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include "dashapp.h"
#include "node.h"

// Prints like printf to stderr. A leading \001 (the Xbox's severity mark)
// is dropped; messages past 511 characters are cut.
// Prints like printf to stderr. A leading \001 or \007 (the Xbox's severity
// marks) is dropped; messages past 511 characters are cut.
extern "C" void Trace(const char* szMsg, ...)
{
char text[512];
Expand All @@ -16,7 +16,7 @@ extern "C" void Trace(const char* szMsg, ...)
vsnprintf(text, sizeof(text), szMsg, args);
va_end(args);

fputs(text[0] == '\001' ? text + 1 : text, stderr);
fputs(text[0] == '\001' || text[0] == '\007' ? text + 1 : text, stderr);
}

void TheseusGetErrorString(HRESULT hr, char* szErrorBuf, int cchErrorBuf)
Expand Down
6 changes: 3 additions & 3 deletions theseus/desktop/desktop_nodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,7 @@ static void EnumerateTitles()
};

HostDir* dir = Host_OpenDir(udataPath);
if (!dir) { fprintf(stderr, "[SavedGameGrid] Cannot open %s\n", udataPath); return; }
if (!dir) return; // no saves yet
char entry[260];
while (Host_ReadDir(dir, entry, sizeof(entry), NULL)) ProcessTitleEntry(entry);
Host_CloseDir(dir);
Expand Down Expand Up @@ -4131,7 +4131,7 @@ class CPlexLibrary : public CNode

std::string StatusFor(int view)
{
if (!Plex_HasToken()) return "Sign in to Plex in Settings";
if (!Plex_HasToken()) return "Sign in from Settings";
if (!Plex_SyncReady()) return "Loading...";
if (view == 0) {
if (Plex_GetActiveServerUri().empty()) return Unreachable();
Expand Down Expand Up @@ -4883,7 +4883,7 @@ class CJellyfinLibrary : public CNode

std::string StatusFor(int view)
{
if (!Jellyfin_HasToken()) return "Sign in to Jellyfin in Settings";
if (!Jellyfin_HasToken()) return "Sign in from Settings";
if (!Jellyfin_SyncReady()) return "Loading...";
if (view == 0) {
if (Jellyfin_SyncFailed()) return Unreachable();
Expand Down
14 changes: 7 additions & 7 deletions theseus/desktop/desktop_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static void ApplyVolume()
}

static const int kStartupVals[] = { 0, 1, 2 };
static const char* kStartupLbl[] = { "Ask on launch", "Dashboard", "Development" };
static const char* kStartupLbl[] = { "Ask Each Time", "Dashboard", "Development" };
static const char* kStartupTok[] = { "", "dashboard", "development" };

// Turning it on buzzes once, so you know it works.
Expand Down Expand Up @@ -131,13 +131,13 @@ static const char* kModeLbl[] = { "Windowed", "Borderless", "Fullscreen" };
static const SettingDef kDefs[] = {
S_PATH("XemuPath", "Desktop", "Games", "xemu Path", s_xemuPath, 0),
S_PATH("Pcsx2Path", "Desktop", "Games", "PCSX2 Path", s_pcsx2Path, 0),
S_PATH("QcowPath", "Desktop", "General", "qcow2 HDD Image", g_qcowPath, 0),
S_PATH("QcowPath", "Desktop", "General", "xemu Hard Disk", g_qcowPath, 0),
S_PATH("SteamPath", "Desktop", "Games", "Steam Folder", s_steamPath, 0),
S_PATH("RetroArchPath", "Desktop", "Games", "RetroArch Folder", s_retroarchPath, 0),
S_PATH("EsdePath", "Desktop", "Games", "ES-DE Folder", s_esdePath, 0),
S_BOOL("ShowEsdeTab", "Desktop", "Games", "ES-DE Import Tab", g_showEsdeTab, "1", 0),
S_BOOL("ShowEsdeTab", "Desktop", "Games", "ES-DE Tab", g_showEsdeTab, "1", 0),
S_BOOL("RetroArchFullscreen", "Desktop", "Games", "RetroArch Fullscreen", g_retroarchFullscreen, "1", 0),
S_BOOL("ReturnAfterGame", "Desktop", "Games", "Back to UIX When a Game Closes", g_returnAfterGame, "1", 0),
S_BOOL("ReturnAfterGame", "Desktop", "Games", "Return After a Game", g_returnAfterGame, "1", 0),
{ "AudioBufferFrames", "Desktop", "Audio", "Audio Buffer", SK_INT, &g_audioBufferFrames, 0, "1024",
SF_RESTART | SF_HIDDEN, NOENUM, 0, 0, 256, NULL, NULL },
S_BOOL("ShowRetroArchTab", "Desktop", "Games", "RetroArch Tab", g_showRetroArchTab, "1", 0),
Expand All @@ -150,16 +150,16 @@ static const SettingDef kDefs[] = {
NOENUM, 0, 0, 0, NULL, ApplyStartAtLogin },
S_BOOL("UseOnScreenKeyboard", "Desktop", "General", "On-Screen Keyboard Only", g_bUseOnScreenKeyboard, "0", 0),
S_BOOL("ShowBootAnimation", "Desktop", "General", "Boot Animation", g_bShowBootAnimation, "1", 0),
{ "MSAA", "Desktop", "Display", "MSAA", SK_ENUM, &g_msaaSamples, 0, "4", SF_STRICT,
{ "MSAA", "Desktop", "Display", "Anti-Aliasing", SK_ENUM, &g_msaaSamples, 0, "4", SF_STRICT,
ENUM(kMsaaVals, kMsaaLbl, NULL), 0, 0, 0, NULL, ApplyMsaa },
{ "Vsync", "Desktop", "Display", "VSync", SK_ENUM, &g_vsyncMode, 0, "0", 0,
ENUM(kVsyncVals, kVsyncLbl, NULL), 0, 2, 0, NULL, ApplyVsync },
S_BOOL("MenuBarAutoHide", "Desktop", "General", "Auto-hide Menu Bar", g_menuBarAutoHide, "1", 0),
S_BOOL("MenuBarAutoHide", "Desktop", "General", "Auto-Hide Menu Bar", g_menuBarAutoHide, "1", 0),
S_BOOL("PadMode", "Desktop", "General", "Controller Tools", g_padModeEnabled, "1", SF_HIDDEN),
S_BOOL("WelcomeDone", "Desktop", "General", "Welcome Shown", g_welcomeDone, "0", SF_HIDDEN),
{ "EmulateXboxRes", "Desktop", "Display", "Emulate Xbox Resolution", SK_BOOL, &g_bEmulateXboxRes, 0, "1", 0,
NOENUM, 0, 0, 0, NULL, ApplyProjection },
{ "FpsCap", "Desktop", "Display", "FPS Cap", SK_ENUM, &g_fpsCap, 0, "0", 0,
{ "FpsCap", "Desktop", "Display", "Frame Rate Limit", SK_ENUM, &g_fpsCap, 0, "0", 0,
ENUM(kFpsVals, kFpsLbl, NULL), 0, 100000, 0, NULL, NULL },
S_BOOL("Hwdec", "Desktop", "Display", "Hardware Video Decode", g_hwdec, "0", 0),
{ "MasterVolume", "Desktop", "Audio", "Master Volume", SK_FLOAT, &g_masterVolume, 0, "1.000",
Expand Down
4 changes: 3 additions & 1 deletion theseus/desktop/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ void CFolder::Refresh(const char* szPath)
HANDLE hFind = TheseusFindFirstFile(szPatternA, &fd);
if (hFind == INVALID_HANDLE_VALUE)
{
TRACE("\001Cannot read directory: \"%s\" (%d)\n", szPath, GetLastError());
// A folder that isn't there is normal: most drives and launcher folders are optional.
if (TheseusGetFileAttributes(szPath) != (DWORD)-1)
TRACE("\001Cannot read directory: \"%s\" (%d)\n", szPath, GetLastError());
return;
}

Expand Down
Loading
Loading