diff --git a/src/common/timer.cpp b/src/common/timer.cpp index 79b49684..92eea500 100644 --- a/src/common/timer.cpp +++ b/src/common/timer.cpp @@ -17,24 +17,20 @@ namespace Common { static double s_counter_frequency; static bool s_counter_initialized = false; -// This gets leaked... oh well. -static thread_local HANDLE s_sleep_timer; -static thread_local bool s_sleep_timer_created = false; - -static HANDLE GetSleepTimer() +static HANDLE GetSleepTimer(void) { + // This gets leaked... oh well. + static thread_local HANDLE s_sleep_timer; + static thread_local bool s_sleep_timer_created = false; if (s_sleep_timer_created) return s_sleep_timer; s_sleep_timer_created = true; s_sleep_timer = CreateWaitableTimer(nullptr, TRUE, nullptr); - if (!s_sleep_timer) - std::fprintf(stderr, "CreateWaitableTimer() failed, falling back to Sleep()\n"); - return s_sleep_timer; } -Timer::Value Timer::GetValue() +Timer::Value Timer::GetValue(void) { // even if this races, it should still result in the same value.. if (!s_counter_initialized) @@ -120,7 +116,7 @@ void Timer::SleepUntil(Value value, bool exact) #else -Timer::Value Timer::GetValue() +Timer::Value Timer::GetValue(void) { struct timespec tv; clock_gettime(CLOCK_MONOTONIC, &tv); @@ -208,72 +204,4 @@ double Timer::GetTimeMilliseconds() const return ConvertValueToMilliseconds(GetValue() - m_tvStartValue); } -double Timer::GetTimeNanoseconds() const -{ - return ConvertValueToNanoseconds(GetValue() - m_tvStartValue); -} - -void Timer::BusyWait(std::uint64_t ns) -{ - const Value start = GetValue(); - const Value end = start + ConvertNanosecondsToValue(static_cast(ns)); - if (end < start) - { - // overflow, unlikely - while (GetValue() > end) - ; - } - - while (GetValue() < end) - ; -} - -void Timer::HybridSleep(std::uint64_t ns, std::uint64_t min_sleep_time) -{ - const std::uint64_t start = GetValue(); - const std::uint64_t end = start + ConvertNanosecondsToValue(static_cast(ns)); - if (end < start) - { - // overflow, unlikely - while (GetValue() > end) - ; - } - - std::uint64_t current = GetValue(); - while (current < end) - { - const std::uint64_t remaining = end - current; - if (remaining >= min_sleep_time) - NanoSleep(min_sleep_time); - - current = GetValue(); - } -} - -void Timer::NanoSleep(std::uint64_t ns) -{ -#if defined(_WIN32) - HANDLE timer = GetSleepTimer(); - if (timer) - { - LARGE_INTEGER due_time; - due_time.QuadPart = -static_cast(static_cast(ns) / 100u); - if (SetWaitableTimer(timer, &due_time, 0, nullptr, nullptr, FALSE)) - WaitForSingleObject(timer, INFINITE); - else - std::fprintf(stderr, "SetWaitableTimer() failed: %08X\n", GetLastError()); - } - else - { - Sleep(static_cast(ns / 1000000)); - } -#elif defined(__ANDROID__) - // Round down to the next millisecond. - usleep(static_cast((ns / 1000000) * 1000)); -#else - const struct timespec ts = {0, static_cast(ns)}; - nanosleep(&ts, nullptr); -#endif -} - } // namespace Common diff --git a/src/common/timer.h b/src/common/timer.h index c105f3d5..4ee3d67f 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -10,26 +10,22 @@ public: Timer(); - static Value GetValue(); + static Value GetValue(void); static double ConvertValueToSeconds(Value value); static double ConvertValueToMilliseconds(Value value); static double ConvertValueToNanoseconds(Value value); static Value ConvertSecondsToValue(double s); static Value ConvertMillisecondsToValue(double s); static Value ConvertNanosecondsToValue(double ns); - static void BusyWait(std::uint64_t ns); - static void HybridSleep(std::uint64_t ns, std::uint64_t min_sleep_time = UINT64_C(2000000)); - static void NanoSleep(std::uint64_t ns); static void SleepUntil(Value value, bool exact); - void Reset(); + void Reset(void); - double GetTimeSeconds() const; - double GetTimeMilliseconds() const; - double GetTimeNanoseconds() const; + double GetTimeSeconds(void) const; + double GetTimeMilliseconds(void) const; private: Value m_tvStartValue; }; -} // namespace Common \ No newline at end of file +} // namespace Common diff --git a/src/core/host_interface.cpp b/src/core/host_interface.cpp index 7f10e9b6..0a7fab73 100644 --- a/src/core/host_interface.cpp +++ b/src/core/host_interface.cpp @@ -469,21 +469,6 @@ void HostInterface::CheckForSettingsChanges(const Settings& old_settings) System::UpdateOverclock(); } - if (g_settings.audio_backend != old_settings.audio_backend || - g_settings.audio_buffer_size != old_settings.audio_buffer_size) - { - if (g_settings.audio_backend != old_settings.audio_backend) - { - AddFormattedOSDMessage(5.0f, TranslateString("OSDMessage", "Switching to %s audio backend."), - Settings::GetAudioBackendName(g_settings.audio_backend)); - } - DebugAssert(m_audio_stream); - m_audio_stream.reset(); - m_audio_stream = CreateAudioStream(); - m_audio_stream->Reconfigure(AUDIO_SAMPLE_RATE, AUDIO_SAMPLE_RATE, AUDIO_CHANNELS, g_settings.audio_buffer_size); - m_audio_stream->PauseOutput(System::IsPaused()); - } - if (g_settings.cpu_execution_mode != old_settings.cpu_execution_mode || g_settings.cpu_fastmem_mode != old_settings.cpu_fastmem_mode || g_settings.cpu_fastmem_rewrite != old_settings.cpu_fastmem_rewrite) diff --git a/src/core/settings.cpp b/src/core/settings.cpp index a866012c..18cd9023 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -142,18 +142,8 @@ void Settings::Load(SettingsInterface& si) .value_or(DEFAULT_CONSOLE_REGION); enable_8mb_ram = si.GetBoolValue("Console", "Enable8MBRAM", false); - emulation_speed = si.GetFloatValue("Main", "EmulationSpeed", 1.0f); - fast_forward_speed = si.GetFloatValue("Main", "FastForwardSpeed", 0.0f); - turbo_speed = si.GetFloatValue("Main", "TurboSpeed", 0.0f); - sync_to_host_refresh_rate = si.GetBoolValue("Main", "SyncToHostRefreshRate", false); - increase_timer_resolution = si.GetBoolValue("Main", "IncreaseTimerResolution", true); - inhibit_screensaver = si.GetBoolValue("Main", "InhibitScreensaver", true); start_paused = si.GetBoolValue("Main", "StartPaused", false); start_fullscreen = si.GetBoolValue("Main", "StartFullscreen", false); - pause_on_focus_loss = si.GetBoolValue("Main", "PauseOnFocusLoss", false); - pause_on_menu = si.GetBoolValue("Main", "PauseOnMenu", true); - save_state_on_exit = si.GetBoolValue("Main", "SaveStateOnExit", true); - confim_power_off = si.GetBoolValue("Main", "ConfirmPowerOff", true); load_devices_from_save_states = si.GetBoolValue("Main", "LoadDevicesFromSaveStates", false); apply_game_settings = si.GetBoolValue("Main", "ApplyGameSettings", true); auto_load_cheats = si.GetBoolValue("Main", "AutoLoadCheats", true); @@ -233,17 +223,10 @@ void Settings::Load(SettingsInterface& si) display_linear_filtering = si.GetBoolValue("Display", "LinearFiltering", false); display_integer_scaling = si.GetBoolValue("Display", "IntegerScaling", false); display_stretch = si.GetBoolValue("Display", "Stretch", false); - display_post_processing = si.GetBoolValue("Display", "PostProcessing", false); display_show_osd_messages = si.GetBoolValue("Display", "ShowOSDMessages", true); - display_show_vps = si.GetBoolValue("Display", "ShowVPS", false); - display_show_speed = si.GetBoolValue("Display", "ShowSpeed", false); display_show_resolution = si.GetBoolValue("Display", "ShowResolution", false); display_show_status_indicators = si.GetBoolValue("Display", "ShowStatusIndicators", true); display_show_enhancements = si.GetBoolValue("Display", "ShowEnhancements", false); - display_all_frames = si.GetBoolValue("Display", "DisplayAllFrames", false); - video_sync_enabled = si.GetBoolValue("Display", "VSync", DEFAULT_VSYNC_VALUE); - display_post_process_chain = si.GetStringValue("Display", "PostProcessChain", ""); - display_max_fps = si.GetFloatValue("Display", "MaxFPS", DEFAULT_DISPLAY_MAX_FPS); cdrom_readahead_sectors = static_cast(si.GetIntValue("CDROM", "ReadaheadSectors", DEFAULT_CDROM_READAHEAD_SECTORS)); cdrom_region_check = si.GetBoolValue("CDROM", "RegionCheck", false); @@ -253,16 +236,9 @@ void Settings::Load(SettingsInterface& si) cdrom_read_speedup = si.GetIntValue("CDROM", "ReadSpeedup", 1); cdrom_seek_speedup = si.GetIntValue("CDROM", "SeekSpeedup", 1); - audio_backend = - ParseAudioBackend(si.GetStringValue("Audio", "Backend", GetAudioBackendName(DEFAULT_AUDIO_BACKEND)).c_str()) - .value_or(DEFAULT_AUDIO_BACKEND); audio_output_volume = si.GetIntValue("Audio", "OutputVolume", 100); audio_fast_forward_volume = si.GetIntValue("Audio", "FastForwardVolume", 100); audio_buffer_size = si.GetIntValue("Audio", "BufferSize", HostInterface::DEFAULT_AUDIO_BUFFER_SIZE); - audio_resampling = si.GetBoolValue("Audio", "Resampling", true); - audio_output_muted = si.GetBoolValue("Audio", "OutputMuted", false); - audio_sync_enabled = si.GetBoolValue("Audio", "Sync", true); - audio_dump_on_boot = si.GetBoolValue("Audio", "DumpOnBoot", false); dma_max_slice_ticks = si.GetIntValue("Hacks", "DMAMaxSliceTicks", DEFAULT_DMA_MAX_SLICE_TICKS); dma_halt_ticks = si.GetIntValue("Hacks", "DMAHaltTicks", DEFAULT_DMA_HALT_TICKS); @@ -306,11 +282,6 @@ void Settings::Load(SettingsInterface& si) log_level = ParseLogLevelName(si.GetStringValue("Logging", "LogLevel", GetLogLevelName(DEFAULT_LOG_LEVEL)).c_str()) .value_or(DEFAULT_LOG_LEVEL); - log_filter = si.GetStringValue("Logging", "LogFilter", ""); - log_to_console = si.GetBoolValue("Logging", "LogToConsole", DEFAULT_LOG_TO_CONSOLE); - log_to_debug = si.GetBoolValue("Logging", "LogToDebug", false); - log_to_window = si.GetBoolValue("Logging", "LogToWindow", false); - log_to_file = si.GetBoolValue("Logging", "LogToFile", false); texture_replacements.enable_vram_write_replacements = si.GetBoolValue("TextureReplacements", "EnableVRAMWriteReplacements", false); @@ -660,58 +631,6 @@ float Settings::GetDisplayAspectRatioValue() const } } -static const auto s_audio_backend_names = make_array("Null", "Cubeb" -#ifdef _WIN32 - , - "XAudio2" -#endif -#ifndef ANDROID - , - "SDL" -#else - , - "OpenSLES" -#endif -); -static const auto s_audio_backend_display_names = - make_array(TRANSLATABLE("AudioBackend", "Null (No Output)"), TRANSLATABLE("AudioBackend", "Cubeb") -#ifdef _WIN32 - , - TRANSLATABLE("AudioBackend", "XAudio2") -#endif -#ifndef ANDROID - , - TRANSLATABLE("AudioBackend", "SDL") -#else - , - TRANSLATABLE("AudioBackend", "OpenSL ES") -#endif - ); - -std::optional Settings::ParseAudioBackend(const char* str) -{ - int index = 0; - for (const char* name : s_audio_backend_names) - { - if (StringUtil::Strcasecmp(name, str) == 0) - return static_cast(index); - - index++; - } - - return std::nullopt; -} - -const char* Settings::GetAudioBackendName(AudioBackend backend) -{ - return s_audio_backend_names[static_cast(backend)]; -} - -const char* Settings::GetAudioBackendDisplayName(AudioBackend backend) -{ - return s_audio_backend_display_names[static_cast(backend)]; -} - static std::array s_controller_type_names = { {"None", "DigitalController", "AnalogController", "AnalogJoystick", "NamcoGunCon", "PlayStationMouse", "NeGcon"}}; static std::array s_controller_display_names = { diff --git a/src/core/settings.h b/src/core/settings.h index 814014c4..6f1a22ba 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -69,18 +69,8 @@ struct Settings CPUFastmemMode cpu_fastmem_mode = CPUFastmemMode::Disabled; bool cpu_fastmem_rewrite = false; - float emulation_speed = 1.0f; - float fast_forward_speed = 0.0f; - float turbo_speed = 0.0f; - bool sync_to_host_refresh_rate = true; - bool increase_timer_resolution = true; - bool inhibit_screensaver = false; bool start_paused = false; bool start_fullscreen = false; - bool pause_on_focus_loss = false; - bool pause_on_menu = true; - bool save_state_on_exit = true; - bool confim_power_off = true; bool load_devices_from_save_states = false; bool apply_game_settings = true; bool auto_load_cheats = false; @@ -93,7 +83,6 @@ struct Settings GPURenderer gpu_renderer = GPURenderer::Software; std::string gpu_adapter; - std::string display_post_process_chain; u32 gpu_resolution_scale = 1; u32 gpu_multisamples = 1; bool gpu_use_thread = true; @@ -128,16 +117,10 @@ struct Settings bool display_linear_filtering = true; bool display_integer_scaling = false; bool display_stretch = false; - bool display_post_processing = false; bool display_show_osd_messages = true; - bool display_show_vps = false; - bool display_show_speed = false; bool display_show_resolution = false; bool display_show_status_indicators = true; bool display_show_enhancements = false; - bool display_all_frames = false; - bool video_sync_enabled = DEFAULT_VSYNC_VALUE; - float display_max_fps = DEFAULT_DISPLAY_MAX_FPS; float gpu_pgxp_tolerance = -1.0f; float gpu_pgxp_depth_clear_threshold = 300.0f / 4096.0f; @@ -149,14 +132,9 @@ struct Settings u32 cdrom_read_speedup = 1; u32 cdrom_seek_speedup = 1; - AudioBackend audio_backend = AudioBackend::Cubeb; s32 audio_output_volume = 100; s32 audio_fast_forward_volume = 100; u32 audio_buffer_size = 2048; - bool audio_resampling = false; - bool audio_output_muted = false; - bool audio_sync_enabled = true; - bool audio_dump_on_boot = true; // timing hacks section TickCount dma_max_slice_ticks = 1000; @@ -202,11 +180,6 @@ struct Settings std::array GeneratePortLabels() const; LOGLEVEL log_level = LOGLEVEL_INFO; - std::string log_filter; - bool log_to_console = false; - bool log_to_debug = false; - bool log_to_window = false; - bool log_to_file = false; ALWAYS_INLINE bool IsUsingCodeCache() const { return (cpu_execution_mode != CPUExecutionMode::Interpreter); } ALWAYS_INLINE bool IsUsingRecompiler() const { return (cpu_execution_mode == CPUExecutionMode::Recompiler); } @@ -296,10 +269,6 @@ struct Settings static std::optional ParseDisplayAspectRatio(const char* str); static const char* GetDisplayAspectRatioName(DisplayAspectRatio ar); - static std::optional ParseAudioBackend(const char* str); - static const char* GetAudioBackendName(AudioBackend backend); - static const char* GetAudioBackendDisplayName(AudioBackend backend); - static std::optional ParseControllerTypeName(const char* str); static const char* GetControllerTypeName(ControllerType type); static const char* GetControllerTypeDisplayName(ControllerType type); @@ -335,14 +304,6 @@ struct Settings static constexpr CPUFastmemMode DEFAULT_CPU_FASTMEM_MODE = CPUFastmemMode::Disabled; #endif -#if defined(__ANDROID__) - static constexpr AudioBackend DEFAULT_AUDIO_BACKEND = AudioBackend::OpenSLES; -#elif defined(_UWP) - static constexpr AudioBackend DEFAULT_AUDIO_BACKEND = AudioBackend::XAudio2; -#else - static constexpr AudioBackend DEFAULT_AUDIO_BACKEND = AudioBackend::Cubeb; -#endif - static constexpr DisplayCropMode DEFAULT_DISPLAY_CROP_MODE = DisplayCropMode::Overscan; static constexpr DisplayAspectRatio DEFAULT_DISPLAY_ASPECT_RATIO = DisplayAspectRatio::Auto;