mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-23 06:10:03 -06:00
attempting at fixing Stop function. also lay base for EmuThread command queue.
This commit is contained in:
@ -460,6 +460,8 @@ void EmuThread::run()
|
||||
ContextRequest = contextRequest_None;
|
||||
}
|
||||
}
|
||||
|
||||
handleMessages();
|
||||
}
|
||||
|
||||
file = Platform::OpenLocalFile("rtc.bin", Platform::FileMode::Write);
|
||||
@ -476,6 +478,45 @@ void EmuThread::run()
|
||||
NDS::Current = nullptr;
|
||||
}
|
||||
|
||||
void EmuThread::sendMessage(Message msg)
|
||||
{
|
||||
msgMutex.lock();
|
||||
msgQueue.enqueue(msg);
|
||||
msgMutex.unlock();
|
||||
}
|
||||
|
||||
void EmuThread::waitMessage()
|
||||
{
|
||||
msgSemaphore.acquire();
|
||||
}
|
||||
|
||||
void EmuThread::waitAllMessages()
|
||||
{
|
||||
msgSemaphore.acquire(msgSemaphore.available());
|
||||
}
|
||||
|
||||
void EmuThread::handleMessages()
|
||||
{
|
||||
msgMutex.lock();
|
||||
while (!msgQueue.empty())
|
||||
{
|
||||
Message msg = msgQueue.dequeue();
|
||||
switch (msg.type)
|
||||
{
|
||||
case msg_EmuStop:
|
||||
if (msg.stopExternal) emuInstance->nds->Stop();
|
||||
EmuRunning = emuStatus_Paused;
|
||||
emuActive = false;
|
||||
emuInstance->audioDisable();
|
||||
emit windowEmuStop();
|
||||
break;
|
||||
}
|
||||
|
||||
msgSemaphore.release();
|
||||
}
|
||||
msgMutex.unlock();
|
||||
}
|
||||
|
||||
void EmuThread::changeWindowTitle(char* title)
|
||||
{
|
||||
emit windowTitleChange(QString(title));
|
||||
@ -528,10 +569,9 @@ void EmuThread::emuUnpause()
|
||||
emuInstance->audioEnable();
|
||||
}
|
||||
|
||||
void EmuThread::emuStop()
|
||||
void EmuThread::emuStop(bool external)
|
||||
{
|
||||
emuPause();
|
||||
emuActive = false;
|
||||
sendMessage({.type = msg_EmuStop, .stopExternal = external});
|
||||
}
|
||||
|
||||
void EmuThread::emuExit()
|
||||
|
Reference in New Issue
Block a user