Merge pull request #7209 from RetroSven/master

provide a means for cores to coordinate with the frontend when shutting down multiple threads gracefully
This commit is contained in:
Twinaphex 2018-09-12 00:54:04 +02:00 committed by GitHub
commit 9bf2fb8f79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 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; 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: * rarch_environment_cb:
* @cmd : Identifier of command. * @cmd : Identifier of command.
@ -1833,8 +1843,8 @@ bool rarch_environment_cb(unsigned cmd, void *data)
int* result_p = (int*)data; int* result_p = (int*)data;
*result_p = result; *result_p = result;
} }
break;
} }
break;
case RETRO_ENVIRONMENT_GET_MIDI_INTERFACE: 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->write = midi_driver_write;
midi_interface->flush = midi_driver_flush; midi_interface->flush = midi_driver_flush;
} }
break;
} }
break;
case RETRO_ENVIRONMENT_GET_FASTFORWARDING: case RETRO_ENVIRONMENT_GET_FASTFORWARDING:
{ {
extern bool runloop_fastmotion; extern bool runloop_fastmotion;
*(bool *)data = 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: default:
RARCH_LOG("Environ UNSUPPORTED (#%u).\n", cmd); RARCH_LOG("Environ UNSUPPORTED (#%u).\n", cmd);

View File

@ -1191,10 +1191,12 @@ struct retro_led_interface
#define RETRO_ENVIRONMENT_GET_FASTFORWARDING (49 | RETRO_ENVIRONMENT_EXPERIMENTAL) #define RETRO_ENVIRONMENT_GET_FASTFORWARDING (49 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* bool * -- /* bool * --
* Boolean value that indicates whether or not the frontend is in * Boolean value that indicates whether or not the frontend is in
* fastforwarding mode. * fastforwarding mode.
*/ */
/* Retrieves the current state of the MIDI input. /* Retrieves the current state of the MIDI input.
* Returns true if it's enabled, false otherwise. */ * Returns true if it's enabled, false otherwise. */
typedef bool (RETRO_CALLCONV *retro_midi_input_enabled_t)(void); typedef bool (RETRO_CALLCONV *retro_midi_input_enabled_t)(void);

View File

@ -33,7 +33,21 @@
RETRO_BEGIN_DECLS RETRO_BEGIN_DECLS
#define RETRO_ENVIRONMENT_SET_SAVE_STATE_IN_BACKGROUND RETRO_ENVIRONMENT_PRIVATE+1 #define RETRO_ENVIRONMENT_RETROARCH_START_BLOCK 0x800000
#define RETRO_ENVIRONMENT_SET_SAVE_STATE_IN_BACKGROUND (2 | RETRO_ENVIRONMENT_RETROARCH_START_BLOCK)
/* 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 (3 | RETRO_ENVIRONMENT_RETROARCH_START_BLOCK)
/* 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.
*/
enum rarch_ctl_state enum rarch_ctl_state
{ {