[MPlayer-cvslog] r26358 - in trunk: mplayer.c stream/cache2.c stream/stream.c stream/stream.h stream/tcp.c

albeu subversion at mplayerhq.hu
Wed Apr 9 02:36:28 CEST 2008


Author: albeu
Date: Wed Apr  9 02:36:28 2008
New Revision: 26358

Log:
Remove the need for code using stream to export a mp_input_check_interrupt()
function. It also remove the compile time dependency on input.



Modified:
   trunk/mplayer.c
   trunk/stream/cache2.c
   trunk/stream/stream.c
   trunk/stream/stream.h
   trunk/stream/tcp.c

Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c	(original)
+++ trunk/mplayer.c	Wed Apr  9 02:36:28 2008
@@ -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) {

Modified: trunk/stream/cache2.c
==============================================================================
--- trunk/stream/cache2.c	(original)
+++ trunk/stream/cache2.c	Wed Apr  9 02:36:28 2008
@@ -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
 	    (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");

Modified: trunk/stream/stream.c
==============================================================================
--- trunk/stream/stream.c	(original)
+++ trunk/stream/stream.c	Wed Apr  9 02:36:28 2008
@@ -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 *
   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);
+}

Modified: trunk/stream/stream.h
==============================================================================
--- trunk/stream/stream.h	(original)
+++ trunk/stream/stream.h	Wed Apr  9 02:36:28 2008
@@ -296,6 +296,11 @@ stream_t* new_memory_stream(unsigned cha
 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;

Modified: trunk/stream/tcp.c
==============================================================================
--- trunk/stream/tcp.c	(original)
+++ trunk/stream/tcp.c	Wed Apr  9 02:36:28 2008
@@ -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 p
 	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



More information about the MPlayer-cvslog mailing list