Prevent bad noise when dragging volume slider

This commit is contained in:
Henrik Rydgård committed 2026-02-06 14:45:23 +01:00
1 parent b1fa6b4671
commit e0a09a8733
2 files changed
+10 -3

No files matched your search

+3 -3
View File
@@ -150,7 +150,7 @@ FILE *OpenCFile(const Path &path, const char *mode) {
case PathType::CONTENT_URI:
// We're gonna need some error codes..
if (!strcmp(mode, "r") || !strcmp(mode, "rb") || !strcmp(mode, "rt")) {
INFO_LOG(Log::IO, "Opening content file for read: '%s'", path.c_str());
DEBUG_LOG(Log::IO, "Opening content file for read: '%s'", path.c_str());
// Read, let's support this - easy one.
int descriptor = Android_OpenContentUriFd(path.ToString(), Android_OpenContentUriMode::READ);
if (descriptor < 0) {
@@ -163,7 +163,7 @@ FILE *OpenCFile(const Path &path, const char *mode) {
// This is also a terrible possible data race, ugh. Anyway...
// Not exactly sure which abstractions are best, let's start simple.
if (!File::Exists(path)) {
INFO_LOG(Log::IO, "OpenCFile(%s): Opening content file for write. Doesn't exist, creating empty and reopening.", path.c_str());
DEBUG_LOG(Log::IO, "OpenCFile(%s): Opening content file for write. Doesn't exist, creating empty and reopening.", path.c_str());
std::string name = path.GetFilename();
if (path.CanNavigateUp()) {
Path parent = path.NavigateUp();
@@ -176,7 +176,7 @@ FILE *OpenCFile(const Path &path, const char *mode) {
return nullptr;
}
} else {
INFO_LOG(Log::IO, "OpenCFile(%s): Opening existing content file for write (truncating). Requested mode: '%s'", path.c_str(), mode);
DEBUG_LOG(Log::IO, "OpenCFile(%s): Opening existing content file for write (truncating). Requested mode: '%s'", path.c_str(), mode);
}
// TODO: Support append modes and stuff... For now let's go with the most common one.
+7
View File
@@ -737,9 +737,16 @@ void GameSettingsScreen::CreateAudioSettings(UI::ViewGroup *audioSettings) {
uiVolume->SetZeroLabel(a->T("Mute"));
uiVolume->SetLiveUpdate(true);
uiVolume->OnChange.Add([](UI::EventParams &e) {
static double lastTimePlayed = 0.0;
double now = time_now_d();
if (now - lastTimePlayed < 0.1) {
return; // Don't play if we just played one, to avoid spamming when dragging.
}
lastTimePlayed = now;
// Audio preview
PlayUISound(UI::UISound::CONFIRM);
});
uiVolume->SetEnabledPtr(&g_Config.iUIVolume);
PopupSliderChoice *gamePreviewVolume = audioSettings->Add(new PopupSliderChoice(&g_Config.iGamePreviewVolume, VOLUME_OFF, VOLUMEHI_FULL, Config::GetDefaultValueInt(&g_Config.iGamePreviewVolume), a->T("Game preview volume"), screenManager()));
gamePreviewVolume->SetFormat("%d%%");