mirror of
https://github.com/SourMesen/Mesen2.git
synced 2025-04-02 10:21:44 -04:00
Linux: Fixed compilation warnings and crash when closing emulator (EmuApi.Release was called too early and other threads/timer could call IsPaused after it was called)
This commit is contained in:
parent
b26c39a829
commit
948aec1d3a
21 changed files with 39 additions and 27 deletions
|
@ -57,7 +57,7 @@ private:
|
|||
|
||||
EmuSettings* _settings = nullptr;
|
||||
|
||||
CpuInfo _debuggers[(int)DebugUtilities::GetLastCpuType() + 1] = {};
|
||||
CpuInfo _debuggers[(int)DebugUtilities::GetLastCpuType() + 1];
|
||||
|
||||
CpuType _mainCpuType = CpuType::Snes;
|
||||
unordered_set<CpuType> _cpuTypes;
|
||||
|
|
|
@ -134,7 +134,7 @@ vector<DisassemblyResult> Disassembler::Disassemble(CpuType cpuType, uint16_t ba
|
|||
|
||||
AddressInfo addrInfo = {};
|
||||
|
||||
auto pushEndBlock = [&relAddress, &prevAddrInfo, &results, &inVerifiedBlock, &inUnknownBlock, &byteCounter, showData, showUnident, bytesPerRow]() {
|
||||
auto pushEndBlock = [&]() {
|
||||
if(inUnknownBlock || inVerifiedBlock) {
|
||||
int flags = LineFlags::BlockEnd;
|
||||
if(inVerifiedBlock) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#pragma once
|
||||
#include "stdafx.h"
|
||||
#include "Debugger/Disassembler.h"
|
||||
#include "Debugger/DisassemblySearch.h"
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
|
||||
void SaveRomToDisk(string filename, bool saveAsIps, CdlStripOption stripOption);
|
||||
|
||||
void ProcessInputOverrides(DebugControllerState inputOverrides[8]);
|
||||
void ProcessInputOverrides(DebugControllerState inputOverrides[8]) override;
|
||||
|
||||
void SetProgramCounter(uint32_t addr) override;
|
||||
uint32_t GetProgramCounter(bool getInstPc) override;
|
||||
|
|
|
@ -353,7 +353,7 @@ bool NesDebugger::IsRegister(MemoryOperationInfo& op)
|
|||
{
|
||||
if(op.Address >= 0x2000 && op.Address <= 0x3FFF) {
|
||||
return true;
|
||||
} else if(op.Address >= 0x4000 && op.Address <= 0x4015 || (op.Address == 0x4017 && op.Type == MemoryOperationType::Write)) {
|
||||
} else if((op.Address >= 0x4000 && op.Address <= 0x4015) || (op.Address == 0x4017 && op.Type == MemoryOperationType::Write)) {
|
||||
return true;
|
||||
} else if(op.Address == 0x4016 || (op.Address == 0x4017 && op.Type == MemoryOperationType::Read)) {
|
||||
return true;
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
|
||||
void Reset() override;
|
||||
|
||||
uint64_t GetCpuCycleCount();
|
||||
uint64_t GetCpuCycleCount() override;
|
||||
|
||||
void ProcessInstruction();
|
||||
void ProcessRead(uint32_t addr, uint8_t value, MemoryOperationType type);
|
||||
|
@ -76,7 +76,7 @@ public:
|
|||
void ProcessPpuWrite(uint16_t addr, uint8_t value, MemoryType memoryType);
|
||||
void ProcessPpuCycle();
|
||||
|
||||
void ProcessInputOverrides(DebugControllerState inputOverrides[8]);
|
||||
void ProcessInputOverrides(DebugControllerState inputOverrides[8]) override;
|
||||
|
||||
void Run() override;
|
||||
void Step(int32_t stepCount, StepType type) override;
|
||||
|
|
|
@ -154,7 +154,7 @@ EventViewerCategoryCfg NesEventManager::GetEventConfig(DebugEventInfo& evt)
|
|||
}
|
||||
} else if(addr >= 0x4018 && _mapper->IsWriteRegister(addr)) {
|
||||
return _config.MapperRegisterWrites;
|
||||
} else if(addr >= 0x4000 && addr <= 0x4015 || addr == 0x4017) {
|
||||
} else if((addr >= 0x4000 && addr <= 0x4015) || addr == 0x4017) {
|
||||
return _config.ApuRegisterWrites;
|
||||
} else if(addr == 0x4016) {
|
||||
return _config.ControlRegisterWrites;
|
||||
|
|
|
@ -78,9 +78,9 @@ public:
|
|||
|
||||
void ClearFrameEvents() override;
|
||||
|
||||
EventViewerCategoryCfg GetEventConfig(DebugEventInfo& evt);
|
||||
EventViewerCategoryCfg GetEventConfig(DebugEventInfo& evt) override;
|
||||
|
||||
uint32_t TakeEventSnapshot();
|
||||
uint32_t TakeEventSnapshot() override;
|
||||
|
||||
FrameInfo GetDisplayBufferSize() override;
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
|
||||
void Reset() override;
|
||||
|
||||
uint64_t GetCpuCycleCount();
|
||||
uint64_t GetCpuCycleCount() override;
|
||||
|
||||
void ProcessInstruction();
|
||||
void ProcessRead(uint32_t addr, uint8_t value, MemoryOperationType type);
|
||||
|
@ -90,7 +90,7 @@ public:
|
|||
ITraceLogger* GetTraceLogger() override;
|
||||
PpuTools* GetPpuTools() override;
|
||||
void SaveRomToDisk(string filename, bool saveAsIps, CdlStripOption stripOption);
|
||||
void ProcessInputOverrides(DebugControllerState inputOverrides[8]);
|
||||
void ProcessInputOverrides(DebugControllerState inputOverrides[8]) override;
|
||||
CallstackManager* GetCallstackManager() override;
|
||||
IAssembler* GetAssembler() override;
|
||||
BaseEventManager* GetEventManager() override;
|
||||
|
|
|
@ -84,7 +84,7 @@ void PceDisUtils::GetDisassembly(DisassemblyInfo& info, string& out, uint32_t me
|
|||
}
|
||||
};
|
||||
|
||||
auto writeZeroAddr = [&str, &info, &writeLabelOrAddr, labelManager](uint8_t zero) {
|
||||
auto writeZeroAddr = [&str](uint8_t zero) {
|
||||
str.WriteAll('$', HexUtilities::ToHex(zero));
|
||||
};
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
class IPceMapper
|
||||
{
|
||||
public:
|
||||
virtual ~IPceMapper() = default;
|
||||
|
||||
virtual uint8_t Read(uint8_t bank, uint16_t addr, uint8_t value) { return value; }
|
||||
virtual void Write(uint8_t bank, uint16_t addr, uint8_t value) {}
|
||||
};
|
||||
|
|
|
@ -11,7 +11,6 @@ private:
|
|||
uint16_t _scaler = 1024 * 3;
|
||||
bool _enabled = false;
|
||||
PceMemoryManager* _memoryManager = nullptr;
|
||||
uint64_t _lastClock = 0;
|
||||
|
||||
public:
|
||||
PceTimer(PceMemoryManager* memoryManager);
|
||||
|
|
|
@ -117,7 +117,7 @@ void SnesDebugger::ProcessConfigChange()
|
|||
|
||||
_runSpc = _spcTraceLogger->IsEnabled() || _settings->CheckDebuggerFlag(DebuggerFlags::SpcDebuggerEnabled);
|
||||
_runCoprocessors = (
|
||||
_dspTraceLogger && _dspTraceLogger->IsEnabled() ||
|
||||
(_dspTraceLogger && _dspTraceLogger->IsEnabled()) ||
|
||||
_settings->CheckDebuggerFlag(DebuggerFlags::NecDspDebuggerEnabled) ||
|
||||
_settings->CheckDebuggerFlag(DebuggerFlags::GbDebuggerEnabled)
|
||||
);
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
|
||||
void ProcessConfigChange() override;
|
||||
|
||||
uint64_t GetCpuCycleCount();
|
||||
uint64_t GetCpuCycleCount() override;
|
||||
|
||||
void ProcessInstruction();
|
||||
void ProcessRead(uint32_t addr, uint8_t value, MemoryOperationType type);
|
||||
|
@ -116,5 +116,5 @@ public:
|
|||
void GetPpuState(BaseState& state) override;
|
||||
void SetPpuState(BaseState& state) override;
|
||||
void SaveRomToDisk(string filename, bool saveAsIps, CdlStripOption stripOption);
|
||||
void ProcessInputOverrides(DebugControllerState inputOverrides[8]);
|
||||
void ProcessInputOverrides(DebugControllerState inputOverrides[8]) override;
|
||||
};
|
|
@ -6,6 +6,9 @@
|
|||
#pragma warning( disable : 4245 ) //conversion from 'x' to 'y', signed/unsigned mismatch
|
||||
#endif
|
||||
|
||||
//TODO, fix warnings and remove this
|
||||
#pragma clang diagnostic ignored "-Wswitch"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
|
|
@ -183,14 +183,15 @@ extern "C" {
|
|||
|
||||
DllExport bool __stdcall IsPaused()
|
||||
{
|
||||
//TODO sometimes crashes when called after refresh (e.g by timer, etc.)
|
||||
return _emu->IsPaused();
|
||||
}
|
||||
|
||||
DllExport void __stdcall Release()
|
||||
{
|
||||
_emu->Stop(true);
|
||||
_emu->Release();
|
||||
if(_emu) {
|
||||
_emu->Stop(true);
|
||||
_emu->Release();
|
||||
}
|
||||
|
||||
_renderer.reset();
|
||||
_soundManager.reset();
|
||||
|
|
|
@ -12,6 +12,7 @@ using System.Reflection;
|
|||
using System.Threading.Tasks;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Mesen.Interop;
|
||||
|
||||
namespace Mesen
|
||||
{
|
||||
|
@ -60,6 +61,7 @@ namespace Mesen
|
|||
Program.CommandLineArgs = (string[])args.Clone();
|
||||
bool useWgl = args.Any(arg => arg.ToLowerInvariant() == "-wgl");
|
||||
BuildAvaloniaApp(useWgl).StartWithClassicDesktopLifetime(args, ShutdownMode.OnMainWindowClose);
|
||||
EmuApi.Release();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Mesen.Utilities
|
||||
{
|
||||
public class MouseManager
|
||||
public class MouseManager : IDisposable
|
||||
{
|
||||
private const int LeftMouseButtonKeyCode = 0x200;
|
||||
private const int RightMouseButtonKeyCode = 0x201;
|
||||
|
@ -228,5 +228,12 @@ namespace Mesen.Utilities
|
|||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if(_timer is DispatcherTimer timer) {
|
||||
timer.Tick -= tmrProcessMouse;
|
||||
timer.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace Mesen.Windows
|
|||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
base.OnClosed(e);
|
||||
EmuApi.Release();
|
||||
_mouseManager.Dispose();
|
||||
}
|
||||
|
||||
protected override void OnDataContextChanged(EventArgs e)
|
||||
|
|
|
@ -77,13 +77,13 @@ uint32_t HermiteResampler::Resample(int16_t* in, uint32_t inSampleCount, int16_t
|
|||
_pendingSamples.clear();
|
||||
|
||||
if(_rateRatio == 1.0) {
|
||||
uint32_t count = std::min((uint32_t)maxOutSampleCount, inSampleCount * 2);
|
||||
memcpy(out, in, count * sizeof(int16_t));
|
||||
for(uint32_t i = count; count < inSampleCount * 2; i += 2) {
|
||||
uint32_t count = std::min((uint32_t)maxOutSampleCount - outPos, inSampleCount * 2);
|
||||
memcpy(out+outPos, in, count * sizeof(int16_t));
|
||||
for(uint32_t i = count; i < inSampleCount * 2; i += 2) {
|
||||
_pendingSamples.push_back(in[i]);
|
||||
_pendingSamples.push_back(in[i + 1]);
|
||||
}
|
||||
return count / 2;
|
||||
return (count + outPos) / 2;
|
||||
}
|
||||
|
||||
for(uint32_t i = 0; i < inSampleCount * 2; i += 2) {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
class WavReader
|
||||
{
|
||||
private:
|
||||
int16_t* _outputBuffer = nullptr;
|
||||
uint8_t* _fileData = nullptr;
|
||||
|
||||
uint32_t _fileOffset = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue