1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-22 06:42:03 +00:00

input: remove some unneeded things

Wakeup FDs are not needed anymore (this code exists only for libwaio
usage by now), and 2 other functions can be made private.
This commit is contained in:
wm4 2015-05-26 22:00:25 +02:00
parent 51654d2ad5
commit 39a339c813
2 changed files with 5 additions and 34 deletions

View File

@ -1331,7 +1331,6 @@ void mp_input_run_cmd(struct input_ctx *ictx, const char **cmd)
struct mp_input_src_internal {
pthread_t thread;
bool thread_running;
int wakeup[2];
bool init_done;
char *cmd_buffer;
@ -1339,7 +1338,7 @@ struct mp_input_src_internal {
bool drop;
};
struct mp_input_src *mp_input_add_src(struct input_ctx *ictx)
static struct mp_input_src *mp_input_add_src(struct input_ctx *ictx)
{
input_lock(ictx);
if (ictx->num_sources == MP_MAX_SOURCES) {
@ -1354,10 +1353,7 @@ struct mp_input_src *mp_input_add_src(struct input_ctx *ictx)
.global = ictx->global,
.log = mp_log_new(src, ictx->log, name),
.input_ctx = ictx,
.in = talloc(src, struct mp_input_src_internal),
};
*src->in = (struct mp_input_src_internal){
.wakeup = {-1, -1},
.in = talloc_zero(src, struct mp_input_src_internal),
};
ictx->sources[ictx->num_sources++] = src;
@ -1366,6 +1362,8 @@ struct mp_input_src *mp_input_add_src(struct input_ctx *ictx)
return src;
}
static void mp_input_src_kill(struct mp_input_src *src);
static void close_input_sources(struct input_ctx *ictx)
{
// To avoid lock-order issues, we first remove each source from the context,
@ -1380,7 +1378,7 @@ static void close_input_sources(struct input_ctx *ictx)
}
}
void mp_input_src_kill(struct mp_input_src *src)
static void mp_input_src_kill(struct mp_input_src *src)
{
if (!src)
return;
@ -1390,7 +1388,6 @@ void mp_input_src_kill(struct mp_input_src *src)
if (ictx->sources[n] == src) {
MP_TARRAY_REMOVE_AT(ictx->sources, ictx->num_sources, n);
input_unlock(ictx);
write(src->in->wakeup[1], &(char){0}, 1);
if (src->cancel)
src->cancel(src);
if (src->in->thread_running)
@ -1439,14 +1436,6 @@ int mp_input_add_thread_src(struct input_ctx *ictx, void *ctx,
if (!src)
return -1;
#ifndef __MINGW32__
// Always create for convenience.
if (mp_make_wakeup_pipe(src->in->wakeup) < 0) {
mp_input_src_kill(src);
return -1;
}
#endif
void *args[] = {src, loop_fn, ctx};
if (pthread_create(&src->in->thread, NULL, input_src_thread, args)) {
mp_input_src_kill(src);
@ -1459,11 +1448,6 @@ int mp_input_add_thread_src(struct input_ctx *ictx, void *ctx,
return 0;
}
int mp_input_src_get_wakeup_fd(struct mp_input_src *src)
{
return src->in->wakeup[0];
}
#define CMD_BUFFER (4 * 4096)
void mp_input_src_feed_cmd_text(struct mp_input_src *src, char *buf, size_t len)

View File

@ -106,11 +106,6 @@ struct mp_input_src {
void *priv;
};
// Add a new input source. The input code can create a new thread, which feeds
// keys or commands to input_ctx. mp_input_src.uninit must be set.
// mp_input_src_kill() must not be called by anything after init.
struct mp_input_src *mp_input_add_src(struct input_ctx *ictx);
// Add an input source that runs on a thread. The source is automatically
// removed if the thread loop exits.
// ctx: this is passed to loop_fn.
@ -129,14 +124,6 @@ int mp_input_add_thread_src(struct input_ctx *ictx, void *ctx,
// Set src->cancel and src->uninit (if needed) before calling this.
void mp_input_src_init_done(struct mp_input_src *src);
// Currently only with mp_input_add_thread_src().
int mp_input_src_get_wakeup_fd(struct mp_input_src *src);
// Remove and free the source. You can call this only while the input_ctx
// exists; otherwise there would be a race condition when another thread
// destroys input_ctx.
void mp_input_src_kill(struct mp_input_src *src);
// Feed text data, which will be split into lines of commands.
void mp_input_src_feed_cmd_text(struct mp_input_src *src, char *buf, size_t len);