From f481e7870b0fcb7fec1614efab4fc7baf380bf1c Mon Sep 17 00:00:00 2001 From: albeu Date: Wed, 9 Apr 2008 00:36:28 +0000 Subject: Remove the need for code using stream to export an mp_input_check_interrupt() function. It also removes the compile-time dependency on input. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26358 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mplayer.c | 2 ++ stream/cache2.c | 3 +-- stream/stream.c | 11 +++++++++++ stream/stream.h | 5 +++++ stream/tcp.c | 3 +-- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/mplayer.c b/mplayer.c index 1a03616d14..810e4d8041 100644 --- a/mplayer.c +++ b/mplayer.c @@ -2855,6 +2855,8 @@ if(slave_mode) mp_input_add_cmd_fd(0,USE_SELECT,MP_INPUT_SLAVE_CMD_FUNC,NULL); else if(!noconsolecontrols) mp_input_add_event_fd(0, getch2); +// Set the libstream interrupt callback +stream_set_interrupt_callback(mp_input_check_interrupt); #ifdef HAVE_MENU if(use_menu) { diff --git a/stream/cache2.c b/stream/cache2.c index 7781ba1eb0..84a58272df 100644 --- a/stream/cache2.c +++ b/stream/cache2.c @@ -32,7 +32,6 @@ static void ThreadProc( void *s ); #include "help_mp.h" #include "stream.h" -#include "input/input.h" extern int use_gui; int stream_fill_buffer(stream_t *s); @@ -307,7 +306,7 @@ int stream_enable_cache(stream_t *stream,int size,int min,int seek_limit){ (int64_t)s->max_filepos-s->read_filepos ); if(s->eof) break; // file is smaller than prefill size - if(mp_input_check_interrupt(PREFILL_SLEEP_TIME)) + if(stream_check_interrupt(PREFILL_SLEEP_TIME)) return 0; } mp_msg(MSGT_CACHE,MSGL_STATUS,"\n"); diff --git a/stream/stream.c b/stream/stream.c index 9c1fb8b0b4..42ceff1934 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -34,6 +34,8 @@ //#include "vcd_read_bincue.h" +static int (*stream_check_interrupt_cb)(int time) = NULL; + extern const stream_info_t stream_info_vcd; extern const stream_info_t stream_info_cdda; extern const stream_info_t stream_info_netstream; @@ -455,3 +457,12 @@ stream_t* new_ds_stream(demux_stream_t *ds) { s->priv = ds; return s; } + +void stream_set_interrupt_callback(int (*cb)(int)) { + stream_check_interrupt_cb = cb; +} + +int stream_check_interrupt(int time) { + if(!stream_check_interrupt_cb) return 0; + return stream_check_interrupt_cb(time); +} diff --git a/stream/stream.h b/stream/stream.h index 5ef7df5fa0..e53d0f971b 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -296,6 +296,11 @@ stream_t* new_memory_stream(unsigned char* data,int len); stream_t* open_stream(char* filename,char** options,int* file_format); stream_t* open_stream_full(char* filename,int mode, char** options, int* file_format); stream_t* open_output_stream(char* filename,char** 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)); +/// Call the interrupt checking callback if there is one. +int stream_check_interrupt(int time); extern int dvd_title; extern int dvd_chapter; diff --git a/stream/tcp.c b/stream/tcp.c index 5759108ec7..769a8669d8 100644 --- a/stream/tcp.c +++ b/stream/tcp.c @@ -19,7 +19,6 @@ #include "mp_msg.h" #include "help_mp.h" -#include "input/input.h" #ifndef HAVE_WINSOCK2 #include @@ -195,7 +194,7 @@ connect2Server_with_af(char *host, int port, int af,int verb) { FD_SET( socket_server_fd, &set ); // When the connection will be made, we will have a writeable fd while((ret = select(socket_server_fd+1, NULL, &set, NULL, &tv)) == 0) { - if(count > 30 || mp_input_check_interrupt(500)) { + if(count > 30 || stream_check_interrupt(500)) { if(count > 30) mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_NW_ConnTimeout); else -- cgit v1.2.3