BIOS: Make GetInfoForHash() public

And it should take a const span.
This commit is contained in:
Stenzek 2024-10-01 21:13:36 +10:00
parent 08fe20ad76
commit 45c8f6ea56
No known key found for this signature in database
11 changed files with 20 additions and 19 deletions

View File

@ -184,7 +184,7 @@ void CrashHandler::WriteDumpForCaller()
WriteMinidumpAndCallstack(nullptr); WriteMinidumpAndCallstack(nullptr);
} }
#elif !defined(__APPLE__) #elif !defined(__APPLE__) && !defined(__ANDROID__)
#include <backtrace.h> #include <backtrace.h>
#include <cstdarg> #include <cstdarg>

View File

@ -27,7 +27,7 @@
#include <mach/mach_vm.h> #include <mach/mach_vm.h>
#include <mach/vm_map.h> #include <mach/vm_map.h>
#include <sys/mman.h> #include <sys/mman.h>
#elif !defined(__ANDROID__) #else
#include <cerrno> #include <cerrno>
#include <dlfcn.h> #include <dlfcn.h>
#include <fcntl.h> #include <fcntl.h>
@ -598,7 +598,7 @@ void MemMap::EndCodeWrite()
#endif #endif
#elif !defined(__ANDROID__) #else
bool MemMap::MemProtect(void* baseaddr, size_t size, PageProtect mode) bool MemMap::MemProtect(void* baseaddr, size_t size, PageProtect mode)
{ {
@ -625,6 +625,8 @@ std::string MemMap::GetFileMappingName(const char* prefix)
#endif #endif
} }
#ifndef __ANDROID__
void* MemMap::CreateSharedMemory(const char* name, size_t size, Error* error) void* MemMap::CreateSharedMemory(const char* name, size_t size, Error* error)
{ {
const bool is_anonymous = (!name || *name == 0); const bool is_anonymous = (!name || *name == 0);
@ -683,6 +685,8 @@ void MemMap::DeleteSharedMemory(const char* name)
shm_unlink(name); shm_unlink(name);
} }
#endif
void* MemMap::MapSharedMemory(void* handle, size_t offset, void* baseaddr, size_t size, PageProtect mode) void* MemMap::MapSharedMemory(void* handle, size_t offset, void* baseaddr, size_t size, PageProtect mode)
{ {
const int flags = (baseaddr != nullptr) ? (MAP_SHARED | MAP_FIXED) : MAP_SHARED; const int flags = (baseaddr != nullptr) ? (MAP_SHARED | MAP_FIXED) : MAP_SHARED;

View File

@ -18,7 +18,6 @@
LOG_CHANNEL(BIOS); LOG_CHANNEL(BIOS);
namespace BIOS { namespace BIOS {
static const ImageInfo* GetInfoForHash(const std::span<u8> image, const ImageInfo::Hash& hash);
static constexpr ImageInfo::Hash MakeHashFromString(const char str[]) static constexpr ImageInfo::Hash MakeHashFromString(const char str[])
{ {
@ -206,7 +205,7 @@ std::optional<BIOS::Image> BIOS::LoadImageFromFile(const char* filename, Error*
return ret; return ret;
} }
const BIOS::ImageInfo* BIOS::GetInfoForHash(const std::span<u8> image, const ImageInfo::Hash& hash) const BIOS::ImageInfo* BIOS::GetInfoForHash(const std::span<const u8> image, const ImageInfo::Hash& hash)
{ {
// check for openbios // check for openbios
if (image.size() >= (s_openbios_signature_offset + std::size(s_openbios_signature)) && if (image.size() >= (s_openbios_signature_offset + std::size(s_openbios_signature)) &&

View File

@ -79,6 +79,8 @@ static_assert(sizeof(PSEXEHeader) == 0x800);
std::optional<Image> LoadImageFromFile(const char* filename, Error* error); std::optional<Image> LoadImageFromFile(const char* filename, Error* error);
const ImageInfo* GetInfoForHash(const std::span<const u8> image, const ImageInfo::Hash& hash);
bool IsValidBIOSForRegion(ConsoleRegion console_region, ConsoleRegion bios_region); bool IsValidBIOSForRegion(ConsoleRegion console_region, ConsoleRegion bios_region);
bool PatchBIOSFastBoot(u8* image, u32 image_size, ImageInfo::FastBootPatch type); bool PatchBIOSFastBoot(u8* image, u32 image_size, ImageInfo::FastBootPatch type);

View File

@ -140,9 +140,9 @@ public:
/// List of controller indices in the order that they should be displayed. /// List of controller indices in the order that they should be displayed.
static const std::array<u32, NUM_CONTROLLER_AND_CARD_PORTS> PortDisplayOrder; static const std::array<u32, NUM_CONTROLLER_AND_CARD_PORTS> PortDisplayOrder;
protected:
/// Returns true if automatic analog mode can be used. /// Returns true if automatic analog mode can be used.
static bool CanStartInAnalogMode(ControllerType ctype); static bool CanStartInAnalogMode(ControllerType ctype);
protected:
u32 m_index; u32 m_index;
}; };

View File

@ -89,6 +89,8 @@ float SettingInfo::FloatStepValue() const
const MediaCaptureBackend Settings::DEFAULT_MEDIA_CAPTURE_BACKEND = MediaCaptureBackend::MediaFoundation; const MediaCaptureBackend Settings::DEFAULT_MEDIA_CAPTURE_BACKEND = MediaCaptureBackend::MediaFoundation;
#elif !defined(__ANDROID__) #elif !defined(__ANDROID__)
const MediaCaptureBackend Settings::DEFAULT_MEDIA_CAPTURE_BACKEND = MediaCaptureBackend::FFmpeg; const MediaCaptureBackend Settings::DEFAULT_MEDIA_CAPTURE_BACKEND = MediaCaptureBackend::FFmpeg;
#else
const MediaCaptureBackend Settings::DEFAULT_MEDIA_CAPTURE_BACKEND = MediaCaptureBackend::MaxCount;
#endif #endif
Settings::Settings() Settings::Settings()

View File

@ -542,14 +542,12 @@ struct Settings
static constexpr SaveStateCompressionMode DEFAULT_SAVE_STATE_COMPRESSION_MODE = SaveStateCompressionMode::ZstDefault; static constexpr SaveStateCompressionMode DEFAULT_SAVE_STATE_COMPRESSION_MODE = SaveStateCompressionMode::ZstDefault;
#ifndef __ANDROID__
static const MediaCaptureBackend DEFAULT_MEDIA_CAPTURE_BACKEND; static const MediaCaptureBackend DEFAULT_MEDIA_CAPTURE_BACKEND;
static constexpr const char* DEFAULT_MEDIA_CAPTURE_CONTAINER = "mp4"; static constexpr const char* DEFAULT_MEDIA_CAPTURE_CONTAINER = "mp4";
static constexpr u32 DEFAULT_MEDIA_CAPTURE_VIDEO_WIDTH = 640; static constexpr u32 DEFAULT_MEDIA_CAPTURE_VIDEO_WIDTH = 640;
static constexpr u32 DEFAULT_MEDIA_CAPTURE_VIDEO_HEIGHT = 480; static constexpr u32 DEFAULT_MEDIA_CAPTURE_VIDEO_HEIGHT = 480;
static constexpr u32 DEFAULT_MEDIA_CAPTURE_VIDEO_BITRATE = 6000; static constexpr u32 DEFAULT_MEDIA_CAPTURE_VIDEO_BITRATE = 6000;
static constexpr u32 DEFAULT_MEDIA_CAPTURE_AUDIO_BITRATE = 128; static constexpr u32 DEFAULT_MEDIA_CAPTURE_AUDIO_BITRATE = 128;
#endif
// Android doesn't create settings until they're first opened, so we have to override the defaults here. // Android doesn't create settings until they're first opened, so we have to override the defaults here.
#ifndef __ANDROID__ #ifndef __ANDROID__

View File

@ -160,9 +160,6 @@ static bool CreateGPU(GPURenderer renderer, bool is_switching, Error* error);
static bool RecreateGPU(GPURenderer renderer, bool force_recreate_device = false, bool update_display = true); static bool RecreateGPU(GPURenderer renderer, bool force_recreate_device = false, bool update_display = true);
static void HandleHostGPUDeviceLost(); static void HandleHostGPUDeviceLost();
/// Returns true if fast forwarding or slow motion is currently active.
static bool IsRunningAtNonStandardSpeed();
/// Returns true if boot is being fast forwarded. /// Returns true if boot is being fast forwarded.
static bool IsFastForwardingBoot(); static bool IsFastForwardingBoot();
@ -4136,7 +4133,7 @@ bool System::CheckForSBIFile(CDImage* image, Error* error)
s_running_game_serial, s_running_game_title); s_running_game_serial, s_running_game_title);
#else #else
// Shorter because no confirm messages. // Shorter because no confirm messages.
Error::SetStringView(error, "Missing SBI file.", "The selected game requires a SBI file to run properly."); Error::SetStringView(error, "The selected game requires a SBI file to run properly.");
#endif #endif
return false; return false;

View File

@ -268,6 +268,9 @@ void SingleStepCPU();
float GetTargetSpeed(); float GetTargetSpeed();
float GetAudioNominalRate(); float GetAudioNominalRate();
/// Returns true if fast forwarding or slow motion is currently active.
bool IsRunningAtNonStandardSpeed();
/// Adjusts the throttle frequency, i.e. how many times we should sleep per second. /// Adjusts the throttle frequency, i.e. how many times we should sleep per second.
void SetThrottleFrequency(float frequency); void SetThrottleFrequency(float frequency);
@ -391,8 +394,6 @@ bool SaveScreenshot(const char* filename = nullptr, DisplayScreenshotMode mode =
DisplayScreenshotFormat format = g_settings.display_screenshot_format, DisplayScreenshotFormat format = g_settings.display_screenshot_format,
u8 quality = g_settings.display_screenshot_quality, bool compress_on_thread = true); u8 quality = g_settings.display_screenshot_quality, bool compress_on_thread = true);
#ifndef __ANDROID__
/// Returns the path that a new media capture would be saved to by default. Safe to call from any thread. /// Returns the path that a new media capture would be saved to by default. Safe to call from any thread.
std::string GetNewMediaCapturePath(const std::string_view title, const std::string_view container); std::string GetNewMediaCapturePath(const std::string_view title, const std::string_view container);
@ -404,8 +405,6 @@ bool StartMediaCapture(std::string path = {});
bool StartMediaCapture(std::string path, bool capture_video, bool capture_audio); bool StartMediaCapture(std::string path, bool capture_video, bool capture_audio);
void StopMediaCapture(); void StopMediaCapture();
#endif
/// Loads the cheat list for the current game title from the user directory. /// Loads the cheat list for the current game title from the user directory.
bool LoadCheatList(); bool LoadCheatList();

View File

@ -2875,7 +2875,7 @@ MediaCapture::CodecList MediaCaptureFFmpeg::GetAudioCodecList(const char* contai
} // namespace } // namespace
static constexpr const std::array s_backend_names = { static constexpr const std::array<const char*, static_cast<size_t>(MediaCaptureBackend::MaxCount)> s_backend_names = {
#ifdef _WIN32 #ifdef _WIN32
"MediaFoundation", "MediaFoundation",
#endif #endif
@ -2883,7 +2883,7 @@ static constexpr const std::array s_backend_names = {
"FFmpeg", "FFmpeg",
#endif #endif
}; };
static constexpr const std::array s_backend_display_names = { static constexpr const std::array<const char*, static_cast<size_t>(MediaCaptureBackend::MaxCount)> s_backend_display_names = {
#ifdef _WIN32 #ifdef _WIN32
TRANSLATE_DISAMBIG_NOOP("Settings", "Media Foundation", "MediaCaptureBackend"), TRANSLATE_DISAMBIG_NOOP("Settings", "Media Foundation", "MediaCaptureBackend"),
#endif #endif

View File

@ -153,7 +153,7 @@ std::unique_ptr<OpenGLContext> OpenGLContext::Create(const WindowInfo& wi, Error
#elif defined(__APPLE__) #elif defined(__APPLE__)
context = OpenGLContextAGL::Create(wi, versions_to_try, error); context = OpenGLContextAGL::Create(wi, versions_to_try, error);
#elif defined(__ANDROID__) #elif defined(__ANDROID__)
context = ContextEGLAndroid::Create(wi, versions_to_try, error); context = OpenGLContextEGLAndroid::Create(wi, versions_to_try, error);
#else #else
#if defined(ENABLE_X11) #if defined(ENABLE_X11)
if (wi.type == WindowInfo::Type::X11) if (wi.type == WindowInfo::Type::X11)