mirror of https://github.com/mpv-player/mpv
stream: reduce ifdeffery for win32 somewhat
Remove the ones which are not strictly needed.
This commit is contained in:
parent
c644178098
commit
1507ef05c2
|
@ -992,9 +992,8 @@ struct mp_cancel {
|
||||||
atomic_bool triggered;
|
atomic_bool triggered;
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
HANDLE event;
|
HANDLE event;
|
||||||
#else
|
|
||||||
int wakeup_pipe[2];
|
|
||||||
#endif
|
#endif
|
||||||
|
int wakeup_pipe[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
static void cancel_destroy(void *p)
|
static void cancel_destroy(void *p)
|
||||||
|
@ -1002,10 +1001,9 @@ static void cancel_destroy(void *p)
|
||||||
struct mp_cancel *c = p;
|
struct mp_cancel *c = p;
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
CloseHandle(c->event);
|
CloseHandle(c->event);
|
||||||
#else
|
#endif
|
||||||
close(c->wakeup_pipe[0]);
|
close(c->wakeup_pipe[0]);
|
||||||
close(c->wakeup_pipe[1]);
|
close(c->wakeup_pipe[1]);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mp_cancel *mp_cancel_new(void *talloc_ctx)
|
struct mp_cancel *mp_cancel_new(void *talloc_ctx)
|
||||||
|
@ -1015,9 +1013,8 @@ struct mp_cancel *mp_cancel_new(void *talloc_ctx)
|
||||||
*c = (struct mp_cancel){.triggered = ATOMIC_VAR_INIT(false)};
|
*c = (struct mp_cancel){.triggered = ATOMIC_VAR_INIT(false)};
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
c->event = CreateEventW(NULL, TRUE, FALSE, NULL);
|
c->event = CreateEventW(NULL, TRUE, FALSE, NULL);
|
||||||
#else
|
|
||||||
mp_make_wakeup_pipe(c->wakeup_pipe);
|
|
||||||
#endif
|
#endif
|
||||||
|
mp_make_wakeup_pipe(c->wakeup_pipe);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1027,9 +1024,8 @@ void mp_cancel_trigger(struct mp_cancel *c)
|
||||||
atomic_store(&c->triggered, true);
|
atomic_store(&c->triggered, true);
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
SetEvent(c->event);
|
SetEvent(c->event);
|
||||||
#else
|
|
||||||
write(c->wakeup_pipe[1], &(char){0}, 1);
|
|
||||||
#endif
|
#endif
|
||||||
|
write(c->wakeup_pipe[1], &(char){0}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore original state. (Allows reusing a mp_cancel.)
|
// Restore original state. (Allows reusing a mp_cancel.)
|
||||||
|
@ -1038,7 +1034,7 @@ void mp_cancel_reset(struct mp_cancel *c)
|
||||||
atomic_store(&c->triggered, false);
|
atomic_store(&c->triggered, false);
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
ResetEvent(c->event);
|
ResetEvent(c->event);
|
||||||
#else
|
#endif
|
||||||
// Flush it fully.
|
// Flush it fully.
|
||||||
while (1) {
|
while (1) {
|
||||||
int r = read(c->wakeup_pipe[0], &(char[256]){0}, 256);
|
int r = read(c->wakeup_pipe[0], &(char[256]){0}, 256);
|
||||||
|
@ -1047,7 +1043,6 @@ void mp_cancel_reset(struct mp_cancel *c)
|
||||||
if (r <= 0)
|
if (r <= 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return whether the caller should abort.
|
// Return whether the caller should abort.
|
||||||
|
@ -1062,14 +1057,14 @@ void *mp_cancel_get_event(struct mp_cancel *c)
|
||||||
{
|
{
|
||||||
return c->event;
|
return c->event;
|
||||||
}
|
}
|
||||||
#else
|
#endif
|
||||||
|
|
||||||
// The FD becomes readable if mp_cancel_test() would return true.
|
// The FD becomes readable if mp_cancel_test() would return true.
|
||||||
// Don't actually read from it, just use it for poll().
|
// Don't actually read from it, just use it for poll().
|
||||||
int mp_cancel_get_fd(struct mp_cancel *c)
|
int mp_cancel_get_fd(struct mp_cancel *c)
|
||||||
{
|
{
|
||||||
return c->wakeup_pipe[0];
|
return c->wakeup_pipe[0];
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void stream_print_proto_list(struct mp_log *log)
|
void stream_print_proto_list(struct mp_log *log)
|
||||||
{
|
{
|
||||||
|
|
|
@ -264,11 +264,8 @@ struct mp_cancel *mp_cancel_new(void *talloc_ctx);
|
||||||
void mp_cancel_trigger(struct mp_cancel *c);
|
void mp_cancel_trigger(struct mp_cancel *c);
|
||||||
bool mp_cancel_test(struct mp_cancel *c);
|
bool mp_cancel_test(struct mp_cancel *c);
|
||||||
void mp_cancel_reset(struct mp_cancel *c);
|
void mp_cancel_reset(struct mp_cancel *c);
|
||||||
#ifdef __MINGW32__
|
void *mp_cancel_get_event(struct mp_cancel *c); // win32 HANDLE
|
||||||
void *mp_cancel_get_event(struct mp_cancel *c);
|
|
||||||
#else
|
|
||||||
int mp_cancel_get_fd(struct mp_cancel *c);
|
int mp_cancel_get_fd(struct mp_cancel *c);
|
||||||
#endif
|
|
||||||
|
|
||||||
// stream_file.c
|
// stream_file.c
|
||||||
char *mp_file_url_to_filename(void *talloc_ctx, bstr url);
|
char *mp_file_url_to_filename(void *talloc_ctx, bstr url);
|
||||||
|
|
Loading…
Reference in New Issue