From 9e9932d4d79fee2cd03ea8b88ee7281a7858837f Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Wed, 30 Apr 2008 07:15:52 +0300 Subject: Create a context for input.c state Start moving static variables to a context struct. Only autorepeat state is moved to the struct in this commit. mp_input_check_interrupt now requires the context variable. Change stream functions to pass it. It's still stored in a static variable in stream/. --- stream/stream.c | 11 ++++++++--- stream/stream.h | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'stream') diff --git a/stream/stream.c b/stream/stream.c index ded692eca0..e24237fa1d 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -34,7 +34,9 @@ //#include "vcd_read_bincue.h" -static int (*stream_check_interrupt_cb)(int time) = NULL; +struct input_ctx; +static int (*stream_check_interrupt_cb)(struct input_ctx *ctx, int time); +static struct input_ctx *stream_check_interrupt_ctx; extern const stream_info_t stream_info_vcd; extern const stream_info_t stream_info_cdda; @@ -454,11 +456,14 @@ stream_t* new_ds_stream(demux_stream_t *ds) { return s; } -void stream_set_interrupt_callback(int (*cb)(int)) { +void stream_set_interrupt_callback(int (*cb)(struct input_ctx *, int), + struct input_ctx *ctx) +{ stream_check_interrupt_cb = cb; + stream_check_interrupt_ctx = ctx; } int stream_check_interrupt(int time) { if(!stream_check_interrupt_cb) return 0; - return stream_check_interrupt_cb(time); + return stream_check_interrupt_cb(stream_check_interrupt_ctx, time); } diff --git a/stream/stream.h b/stream/stream.h index 50df5baa7e..71dbb99557 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -300,7 +300,9 @@ stream_t* open_stream_full(char* filename,int mode, struct MPOpts *options, int* stream_t* open_output_stream(char* filename,struct MPOpts *options); /// Set the callback to be used by libstream to check for user /// interruption during long blocking operations (cache filling, etc). -void stream_set_interrupt_callback(int (*cb)(int)); +struct input_ctx; +void stream_set_interrupt_callback(int (*cb)(struct input_ctx*, int), + struct input_ctx *ctx); /// Call the interrupt checking callback if there is one. int stream_check_interrupt(int time); -- cgit v1.2.3