summaryrefslogtreecommitdiffstats
path: root/stream/stream.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-04-25 19:12:24 +0200
committerwm4 <wm4@nowhere>2014-04-25 19:12:24 +0200
commite0cf983e53afa6a524821265c7547c11f5c79551 (patch)
tree4ea1c5f0b17464e6b503c23be14b935cba0090d4 /stream/stream.c
parent3d51ef3dc83ea59a47c0eccf4ae93ae2a441ceb7 (diff)
downloadmpv-e0cf983e53afa6a524821265c7547c11f5c79551.tar.bz2
mpv-e0cf983e53afa6a524821265c7547c11f5c79551.tar.xz
stream: remove interrupt callback global variables
This used global variables for the asynchronous interrupt callback. Pick the simple and dumb solution and stuff the callback into mpv_global. Do this because interrupt checking should also work in the connect phase, and currently stream creation equates connecting. Ideally, this would be passed to the stream on creation instead, or connecting would be separated from creation. But since I don't know yet which is better, and since moving stream/demuxer into their own thread is something that will happen later, go with the mpv_global solution.
Diffstat (limited to 'stream/stream.c')
-rw-r--r--stream/stream.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/stream/stream.c b/stream/stream.c
index 5eee953bf6..59cd2f7763 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -56,10 +56,6 @@ char *cdrom_device = NULL;
char *dvd_device = NULL;
int dvd_title = 0;
-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;
extern const stream_info_t stream_info_dvb;
@@ -409,7 +405,7 @@ static int stream_reconnect(stream_t *s)
sleep_ms = MPMIN(sleep_ms * 2, RECONNECT_SLEEP_MAX_MS);
}
- if (stream_check_interrupt(0))
+ if (stream_check_interrupt(s))
return 0;
s->eof = 1;
@@ -757,20 +753,11 @@ void free_stream(stream_t *s)
talloc_free(s);
}
-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)
+bool stream_check_interrupt(struct stream *s)
{
- if (!stream_check_interrupt_cb) {
- mp_sleep_us(time * 1000);
- return 0;
- }
- return stream_check_interrupt_cb(stream_check_interrupt_ctx, time);
+ if (!s->global || !s->global->stream_interrupt_cb)
+ return false;
+ return s->global->stream_interrupt_cb(s->global->stream_interrupt_cb_ctx);
}
stream_t *open_memory_stream(void *data, int len)