provide a means for cores to coordinate with the frontend when shutting down multiple threads gracefully

This commit is contained in:
Sven 2018-09-11 13:29:20 -04:00
parent 5d8c268afc
commit d8796732aa
3 changed files with 32 additions and 5 deletions

View File

@ -1042,6 +1042,16 @@ static void core_performance_counter_stop(struct retro_perf_counter *perf)
perf->total += cpu_features_get_perf_counter() - perf->start;
}
bool rarch_clear_all_thread_waits(unsigned clear_threads, void *data)
{
if ( clear_threads > 0)
audio_driver_start(false) ;
else
audio_driver_stop() ;
return true ;
}
/**
* rarch_environment_cb:
* @cmd : Identifier of command.
@ -1833,8 +1843,8 @@ bool rarch_environment_cb(unsigned cmd, void *data)
int* result_p = (int*)data;
*result_p = result;
}
break;
}
break;
case RETRO_ENVIRONMENT_GET_MIDI_INTERFACE:
{
@ -1849,16 +1859,21 @@ bool rarch_environment_cb(unsigned cmd, void *data)
midi_interface->write = midi_driver_write;
midi_interface->flush = midi_driver_flush;
}
break;
}
break;
case RETRO_ENVIRONMENT_GET_FASTFORWARDING:
{
extern bool runloop_fastmotion;
*(bool *)data = runloop_fastmotion;
break;
}
break;
case RETRO_ENVIRONMENT_GET_CLEAR_ALL_THREAD_WAITS_CB:
{
*(retro_environment_t *)data = rarch_clear_all_thread_waits;
break;
}
default:
RARCH_LOG("Environ UNSUPPORTED (#%u).\n", cmd);

View File

@ -1195,6 +1195,20 @@ struct retro_led_interface
* fastforwarding mode.
*/
#define RETRO_ENVIRONMENT_SET_SAVE_STATE_IN_BACKGROUND (50 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* bool * --
* Boolean value that tells the front end to save states in the
* background or not.
*/
#define RETRO_ENVIRONMENT_GET_CLEAR_ALL_THREAD_WAITS_CB (51 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* retro_environment_t * --
* Provides the callback to the frontend method which will cancel
* all currently waiting threads. Used when coordination is needed
* between the core and the frontend to gracefully stop all threads.
*/
/* Retrieves the current state of the MIDI input.
* Returns true if it's enabled, false otherwise. */
typedef bool (RETRO_CALLCONV *retro_midi_input_enabled_t)(void);

View File

@ -33,8 +33,6 @@
RETRO_BEGIN_DECLS
#define RETRO_ENVIRONMENT_SET_SAVE_STATE_IN_BACKGROUND RETRO_ENVIRONMENT_PRIVATE+1
enum rarch_ctl_state
{
RARCH_CTL_NONE = 0,