4343#include " VideoDecoder.h"
4444#include " VideoRenderer.h"
4545#include " DebugHud.h"
46+ #include " NotificationManager.h"
4647
4748Console::Console ()
4849{
@@ -57,6 +58,7 @@ Console::~Console()
5758
5859void Console::Init ()
5960{
61+ _notificationManager.reset (new NotificationManager ());
6062 _saveStateManager.reset (new SaveStateManager (shared_from_this ()));
6163 _videoRenderer.reset (new VideoRenderer (shared_from_this ()));
6264 _videoDecoder.reset (new VideoDecoder (shared_from_this ()));
@@ -235,7 +237,7 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile)
235237 }
236238
237239 // Send notification only if a game was already running and we successfully loaded the new one
238- MessageManager:: SendNotification (ConsoleNotificationType::GameStopped, (void *)1 );
240+ _notificationManager-> SendNotification (ConsoleNotificationType::GameStopped, (void *)1 );
239241 }
240242
241243 if (isDifferentGame) {
@@ -321,7 +323,7 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile)
321323 ResetComponents (false );
322324
323325 _rewindManager.reset (new RewindManager (shared_from_this ()));
324- MessageManager:: RegisterNotificationListener (_rewindManager);
326+ _notificationManager-> RegisterNotificationListener (_rewindManager);
325327
326328 _videoDecoder->StartThread ();
327329
@@ -377,6 +379,11 @@ shared_ptr<SoundMixer> Console::GetSoundMixer()
377379 return _soundMixer;
378380}
379381
382+ shared_ptr<NotificationManager> Console::GetNotificationManager ()
383+ {
384+ return _notificationManager;
385+ }
386+
380387BaseMapper* Console::GetMapper ()
381388{
382389 return _mapper.get ();
@@ -473,7 +480,8 @@ void Console::ResetComponents(bool softReset)
473480
474481 KeyManager::UpdateDevices ();
475482
476- MessageManager::SendNotification (softReset ? ConsoleNotificationType::GameReset : ConsoleNotificationType::GameLoaded);
483+ // This notification MUST be sent before the UpdateInputState() below to allow MovieRecorder to grab the first frame's worth of inputs
484+ _notificationManager->SendNotification (softReset ? ConsoleNotificationType::GameReset : ConsoleNotificationType::GameLoaded);
477485
478486 if (softReset) {
479487 shared_ptr<Debugger> debugger = _debugger;
@@ -603,7 +611,7 @@ void Console::Run()
603611
604612 bool paused = EmulationSettings::IsPaused ();
605613 if (paused && !_stop) {
606- MessageManager:: SendNotification (ConsoleNotificationType::GamePaused);
614+ _notificationManager-> SendNotification (ConsoleNotificationType::GamePaused);
607615
608616 // Prevent audio from looping endlessly while game is paused
609617 _soundMixer->StopAudio ();
@@ -625,7 +633,7 @@ void Console::Run()
625633
626634 PlatformUtilities::DisableScreensaver ();
627635 _runLock.Acquire ();
628- MessageManager:: SendNotification (ConsoleNotificationType::GameResumed);
636+ _notificationManager-> SendNotification (ConsoleNotificationType::GameResumed);
629637 lastFrameTimer.Reset ();
630638 }
631639
@@ -668,7 +676,7 @@ void Console::Run()
668676
669677 _running = false ;
670678
671- MessageManager:: SendNotification (ConsoleNotificationType::BeforeEmulationStop);
679+ _notificationManager-> SendNotification (ConsoleNotificationType::BeforeEmulationStop);
672680
673681 if (!crashed) {
674682 _saveStateManager->SaveRecentGame (GetMapperInfo ().RomName , _romFilepath, _patchFilename);
@@ -703,8 +711,8 @@ void Console::Run()
703711
704712 _emulationThreadId = std::thread::id ();
705713
706- MessageManager:: SendNotification (ConsoleNotificationType::GameStopped);
707- MessageManager:: SendNotification (ConsoleNotificationType::EmulationStopped);
714+ _notificationManager-> SendNotification (ConsoleNotificationType::GameStopped);
715+ _notificationManager-> SendNotification (ConsoleNotificationType::EmulationStopped);
708716}
709717
710718bool Console::IsRunning ()
@@ -747,7 +755,7 @@ void Console::UpdateNesModel(bool sendNotification)
747755 _apu->SetNesModel (model);
748756
749757 if (configChanged && sendNotification) {
750- MessageManager:: SendNotification (ConsoleNotificationType::ConfigChanged);
758+ _notificationManager-> SendNotification (ConsoleNotificationType::ConfigChanged);
751759 }
752760}
753761
@@ -813,7 +821,7 @@ void Console::LoadState(istream &loadStream, uint32_t stateVersion)
813821 debugger->ResetCounters ();
814822 }
815823
816- MessageManager:: SendNotification (ConsoleNotificationType::StateLoaded);
824+ _notificationManager-> SendNotification (ConsoleNotificationType::StateLoaded);
817825 }
818826}
819827
0 commit comments