File tree Expand file tree Collapse file tree 3 files changed +20
-32
lines changed
Expand file tree Collapse file tree 3 files changed +20
-32
lines changed Original file line number Diff line number Diff line change @@ -117,36 +117,6 @@ void emu_destroy(void)
117117 SafeDeleteArray (emu_savestates_screenshots[i].data );
118118}
119119
120- bool emu_load_media (const char * file_path)
121- {
122- if (loading_state.load () != Loading_State_None)
123- return false ;
124-
125- emu_debug_command = Debug_Command_None;
126- reset_buffers ();
127-
128- save_ram ();
129- save_mb128 ();
130-
131- loading_state.store (Loading_State_Loading);
132- bool success = geargrafx->LoadMedia (file_path);
133- loading_state.store (Loading_State_None);
134-
135- if (!success)
136- return false ;
137-
138- emu_audio_reset ();
139- load_ram ();
140- load_mb128 ();
141-
142- if (config_debug.debug && (config_debug.dis_look_ahead_count > 0 ))
143- geargrafx->GetHuC6280 ()->DisassembleAhead (config_debug.dis_look_ahead_count );
144-
145- update_savestates_data ();
146-
147- return true ;
148- }
149-
150120static void load_media_thread_func (void )
151121{
152122 loading_result = geargrafx->LoadMedia (loading_file_path);
Original file line number Diff line number Diff line change @@ -65,7 +65,6 @@ EXTERN bool emu_debug_irq_breakpoints;
6565EXTERN bool emu_init (GG_Input_Pump_Fn input_pump_fn );
6666EXTERN void emu_destroy (void );
6767EXTERN void emu_update (void );
68- EXTERN bool emu_load_media (const char * file_path );
6968EXTERN void emu_load_media_async (const char * file_path );
7069EXTERN bool emu_is_media_loading (void );
7170EXTERN bool emu_finish_media_loading (void );
Original file line number Diff line number Diff line change 3232#include < iomanip>
3333#include < vector>
3434#include < algorithm>
35+ #include < thread>
36+ #include < chrono>
3537
3638struct DisassemblerBookmark
3739{
@@ -1326,7 +1328,24 @@ json DebugAdapter::LoadMedia(const std::string& file_path)
13261328 return result;
13271329 }
13281330
1329- if (!emu_load_media (file_path.c_str ()) || !m_core || !m_core->GetMedia ()->IsReady ())
1331+ emu_load_media_async (file_path.c_str ());
1332+
1333+ int timeout_ms = 180000 ;
1334+ int elapsed_ms = 0 ;
1335+ while (emu_is_media_loading () && elapsed_ms < timeout_ms)
1336+ {
1337+ std::this_thread::sleep_for (std::chrono::milliseconds (500 ));
1338+ elapsed_ms += 500 ;
1339+ }
1340+
1341+ if (emu_is_media_loading ())
1342+ {
1343+ result[" error" ] = " Loading timed out" ;
1344+ Log (" [MCP] LoadMedia timed out: %s" , file_path.c_str ());
1345+ return result;
1346+ }
1347+
1348+ if (!emu_finish_media_loading () || !m_core || !m_core->GetMedia ()->IsReady ())
13301349 {
13311350 result[" error" ] = " Failed to load media file" ;
13321351 Log (" [MCP] LoadMedia failed: %s" , file_path.c_str ());
You can’t perform that action at this time.
0 commit comments