Shutdown core after eof reached

Signed-off-by: Mahyar Koshkouei <mahyar.koshkouei@gmail.com>
This commit is contained in:
Mahyar Koshkouei 2018-01-15 22:48:42 +00:00
parent 262eaf1882
commit a4fb27346f
1 changed files with 19 additions and 1 deletions

View File

@ -449,7 +449,6 @@ void retro_run(void)
if(mp_event->event_id == MPV_EVENT_NONE)
break;
log_cb(RETRO_LOG_INFO, "mpv: ");
if(mp_event->event_id == MPV_EVENT_LOG_MESSAGE)
{
struct mpv_event_log_message *msg =
@ -457,6 +456,25 @@ void retro_run(void)
log_cb(RETRO_LOG_INFO, "[%s] %s: %s",
msg->prefix, msg->level, msg->text);
}
else if(mp_event->event_id == MPV_EVENT_END_FILE)
{
struct mpv_event_end_file *eof =
(struct mpv_event_end_file *)mp_event->data;
if(eof->reason == MPV_END_FILE_REASON_EOF)
environ_cb(RETRO_ENVIRONMENT_SHUTDOWN, NULL);
#if 0
/* The following could be done instead if the file was not
* closed once the end was reached - allowing the user to seek
* back without reopening the file.
*/
struct retro_message ra_msg = {
"Finished playing file", 60 * 5, /* 5 seconds */
};
environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, &ra_msg);RETRO_ENVIRONMENT_SHUTDOWN
#endif
}
else
log_cb(RETRO_LOG_INFO, "%s\n", mpv_event_name(mp_event->event_id));
}