summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authoralbeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-04-09 00:36:28 +0000
committeralbeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-04-09 00:36:28 +0000
commitf481e7870b0fcb7fec1614efab4fc7baf380bf1c (patch)
treeb5cbdd1b187650efb3bea73bb69c862fdfae74ba /stream
parent64868a36cd8113336745f5baf336ae76553de9ab (diff)
downloadmpv-f481e7870b0fcb7fec1614efab4fc7baf380bf1c.tar.bz2
mpv-f481e7870b0fcb7fec1614efab4fc7baf380bf1c.tar.xz
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
Diffstat (limited to 'stream')
-rw-r--r--stream/cache2.c3
-rw-r--r--stream/stream.c11
-rw-r--r--stream/stream.h5
-rw-r--r--stream/tcp.c3
4 files changed, 18 insertions, 4 deletions
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 <netdb.h>
@@ -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