[Mplayer-cvslog] CVS: main/libmpdemux network.c,1.32,1.33

Bertrand Baudet bertrand at mplayer.dev.hu
Mon Feb 11 06:16:19 CET 2002


Update of /cvsroot/mplayer/main/libmpdemux
In directory mplayer:/var/tmp.root/cvs-serv23401

Modified Files:
	network.c 
Log Message:
Cleaned up the way proxies checking was done.


Index: network.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/network.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- network.c	6 Feb 2002 20:30:34 -0000	1.32
+++ network.c	11 Feb 2002 05:16:09 -0000	1.33
@@ -182,10 +182,12 @@
 
 URL_t*
 check4proxies( URL_t *url ) {
+	URL_t *url_out = NULL;
 	if( url==NULL ) return NULL;
+	url_out = url_new( url->url );
 	if( !strcasecmp(url->protocol, "http_proxy") ) {
-			printf("Using HTTP proxy: http://%s:%d\n", url->hostname, url->port );
-			return url;
+		printf("Using HTTP proxy: http://%s:%d\n", url->hostname, url->port );
+		return url_out;
 	}
 	// Check if the http_proxy environment variable is set.
 	if( !strcasecmp(url->protocol, "http") ) {
@@ -200,7 +202,7 @@
 
 			if( proxy_url==NULL ) {
 				printf("Invalid proxy setting...Trying without proxy.\n");
-				return url;
+				return url_out;
 			}
 
 			printf("Using HTTP proxy: %s\n", proxy_url->url );
@@ -208,20 +210,20 @@
 			new_url = malloc( len+1 );
 			if( new_url==NULL ) {
 				printf("Memory allocation failed\n");
-				return url;
+				return url_out;
 			}
-			sprintf( new_url, "http_proxy://%s:%d/%s", proxy_url->hostname, proxy_url->port, url->url);
+			sprintf( new_url, "http_proxy://%s:%d/%s", proxy_url->hostname, proxy_url->port, url->url );
 			tmp_url = url_new( new_url );
 			if( tmp_url==NULL ) {
-				return url;
+				return url_out;
 			}
-			url_free( url );
-			url = tmp_url;
+			url_free( url_out );
+			url_out = tmp_url;
 			free( new_url );
 			url_free( proxy_url );
 		}
 	}
-	return url;
+	return url_out;
 }
 
 int
@@ -311,13 +313,12 @@
 int
 autodetectProtocol(streaming_ctrl_t *streaming_ctrl, int *fd_out, int *file_format) {
 	HTTP_header_t *http_hdr;
+	unsigned int i;
 	int fd=-1;
-	int i;
 	int redirect;
 	char *extension;
 	char *content_type;
 	char *next_url;
-	char response[1024];
 
 	URL_t *url = streaming_ctrl->url;
 	*file_format = DEMUXER_TYPE_UNKNOWN;
@@ -665,7 +666,7 @@
 	if( stream->streaming_ctrl==NULL ) {
 		return -1;
 	}
-	stream->streaming_ctrl->url = check4proxies( url_copy(url) );
+	stream->streaming_ctrl->url = check4proxies( url );
 	ret = autodetectProtocol( stream->streaming_ctrl, &stream->fd, &demuxer_type );
 	if( ret<0 ) {
 		return -1;
@@ -712,7 +713,7 @@
 	if( ret<0 ) {
 		streaming_ctrl_free( stream->streaming_ctrl );
 		stream->streaming_ctrl = NULL;
-	} else if( stream->streaming_ctrl->buffering) {
+	} else if( stream->streaming_ctrl->buffering ) {
 		int cache_size = 0; 
 		int ret, val;
 		ret = m_config_is_option_set(mconfig,"cache");
@@ -722,6 +723,7 @@
 			// cache option not set, will use the our computed value.
 			// buffer in KBytes, *5 because the prefill is 20% of the buffer.
 			val = (stream->streaming_ctrl->prebuffer_size/1024)*5;
+			if( val<16 ) val = 16;	// 16KBytes min buffer
 			if( m_config_set_int( mconfig, "cache", val )<0 ) { 
 				printf("Unable to set the cache size option\n");
 			} else {




More information about the MPlayer-cvslog mailing list