client API: add MPV_END_FILE_REASON_REDIRECT

Requested. Minor incompatible behavior change, as it was signalling
MPV_END_FILE_REASON_EOF previously.
This commit is contained in:
wm4 2015-06-11 21:39:48 +02:00
parent 87b60ded88
commit e53cb0890e
3 changed files with 17 additions and 3 deletions

View File

@ -32,6 +32,9 @@ API changes
::
1.18 - add MPV_END_FILE_REASON_REDIRECT, and change behavior of
MPV_EVENT_END_FILE accordingly
- a bunch of interface-changes.rst changes
1.17 - mpv_initialize() now blocks SIGPIPE (details see client.h)
--- mpv 0.9.0 is released ---
1.16 - add mpv_opengl_cb_report_flip()

View File

@ -198,7 +198,7 @@ extern "C" {
* relational operators (<, >, <=, >=).
*/
#define MPV_MAKE_VERSION(major, minor) (((major) << 16) | (minor) | 0UL)
#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(1, 17)
#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(1, 18)
/**
* Return the MPV_CLIENT_API_VERSION the mpv source has been compiled with.
@ -1307,6 +1307,15 @@ typedef enum mpv_end_file_reason {
* mpv_event_end_file.error will be set.
*/
MPV_END_FILE_REASON_ERROR = 4,
/**
* The file was a playlist or similar. When the playlist is read, its
* entries will be appended to the playlist after the entry of the current
* file, the entry of the current file is removed, and a MPV_EVENT_END_FILE
* event is sent with reason set to MPV_END_FILE_REASON_REDIRECT. Then
* playback continues with the playlist contents.
* Since API version 1.18.
*/
MPV_END_FILE_REASON_REDIRECT = 5,
} mpv_end_file_reason;
typedef struct mpv_event_end_file {

View File

@ -1130,7 +1130,7 @@ goto_reopen_demuxer: ;
e->stream_flags |= entry_stream_flags;
transfer_playlist(mpctx, pl);
mp_notify_property(mpctx, "playlist");
mpctx->error_playing = 1;
mpctx->error_playing = 2;
goto terminate_playback;
}
@ -1300,11 +1300,13 @@ terminate_playback:
case PT_ERROR:
case AT_END_OF_FILE:
{
if (mpctx->error_playing >= 0 && nothing_played)
if (mpctx->error_playing == 0 && nothing_played)
mpctx->error_playing = MPV_ERROR_NOTHING_TO_PLAY;
if (mpctx->error_playing < 0) {
end_event.error = mpctx->error_playing;
end_event.reason = MPV_END_FILE_REASON_ERROR;
} else if (mpctx->error_playing == 2) {
end_event.reason = MPV_END_FILE_REASON_REDIRECT;
} else {
end_event.reason = MPV_END_FILE_REASON_EOF;
}