From 86094c2c5ae634b9ff02a85e51c33955b31babfa Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 11 Apr 2014 01:23:32 +0200 Subject: client API: include the reason in MPV_EVENT_END_FILE Otherwise, the client API user could not know why playback was stopped. Regarding the fact that 0 is used both for normal EOF and EOF on error: this is because mplayer traditionally did not distinguish these, and in general it's hard to tell the real reason. (There are various weird corner cases which make it hard.) --- player/client.c | 3 +++ player/loadfile.c | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'player') diff --git a/player/client.c b/player/client.c index 2347f19fbd..642937421d 100644 --- a/player/client.c +++ b/player/client.c @@ -393,6 +393,9 @@ static void dup_event_data(struct mpv_event *ev) ev->data = msg; break; } + case MPV_EVENT_END_FILE: + ev->data = talloc_memdup(NULL, ev->data, sizeof(mpv_event_end_file)); + break; default: // Doesn't use events with memory allocation. if (ev->data) diff --git a/player/loadfile.c b/player/loadfile.c index 95cc871e42..ee3deed4a8 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -1421,7 +1421,18 @@ terminate_playback: // don't jump here after ao/vo/getch initialization! } mp_notify(mpctx, MPV_EVENT_TRACKS_CHANGED, NULL); - mp_notify(mpctx, MPV_EVENT_END_FILE, NULL); + struct mpv_event_end_file end_event = {0}; + switch (mpctx->stop_play) { + case AT_END_OF_FILE: end_event.reason = 0; break; + case PT_RESTART: + case PT_RELOAD_DEMUXER: end_event.reason = 1; break; + case PT_NEXT_ENTRY: + case PT_CURRENT_ENTRY: + case PT_STOP: end_event.reason = 2; break; + case PT_QUIT: end_event.reason = 3; break; + default: end_event.reason = -1; break; + }; + mp_notify(mpctx, MPV_EVENT_END_FILE, &end_event); } // Determine the next file to play. Note that if this function returns non-NULL, -- cgit v1.2.3