changeset 26326:5bfc1d8bece9

Remove the need for code using stream to export an mp_input_check_interrupt() function. It also removes the compile-time dependency on input.
author albeu
date Wed, 09 Apr 2008 00:36:28 +0000
parents 890180cde40f
children fa91545f01bb
files mplayer.c stream/cache2.c stream/stream.c stream/stream.h stream/tcp.c
diffstat 5 files changed, 20 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mplayer.c	Wed Apr 09 00:32:35 2008 +0000
+++ b/mplayer.c	Wed Apr 09 00:36:28 2008 +0000
@@ -2855,6 +2855,8 @@
   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) {
--- a/stream/cache2.c	Wed Apr 09 00:32:35 2008 +0000
+++ b/stream/cache2.c	Wed Apr 09 00:36:28 2008 +0000
@@ -32,7 +32,6 @@
 #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 @@
 	    (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");
--- a/stream/stream.c	Wed Apr 09 00:32:35 2008 +0000
+++ b/stream/stream.c	Wed Apr 09 00:36:28 2008 +0000
@@ -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 @@
   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);
+}
--- a/stream/stream.h	Wed Apr 09 00:32:35 2008 +0000
+++ b/stream/stream.h	Wed Apr 09 00:36:28 2008 +0000
@@ -296,6 +296,11 @@
 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;
--- a/stream/tcp.c	Wed Apr 09 00:32:35 2008 +0000
+++ b/stream/tcp.c	Wed Apr 09 00:36:28 2008 +0000
@@ -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 @@
 	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