[svn r363] Optimizations on the GnomeVFS internal buffer filling. trunk
authorrosfran
Wed Feb 14 21:35:23 2007 +0000 (2007-02-14)
branchtrunk
changeset 3617140b2c2e63c
parent 360 6d5596b9eb95
child 362 6d7b5baf170b
[svn r363] Optimizations on the GnomeVFS internal buffer filling.
libgnomevfs2-mythtv/modules/mythtv-method.c
     1.1 --- a/libgnomevfs2-mythtv/modules/mythtv-method.c	Wed Feb 14 21:28:49 2007 +0000
     1.2 +++ b/libgnomevfs2-mythtv/modules/mythtv-method.c	Wed Feb 14 21:35:23 2007 +0000
     1.3 @@ -41,8 +41,11 @@
     1.4  #define MYTHTV_VERSION_DEFAULT          30
     1.5  #define MYTHTV_TRANSFER_MAX_WAITS       100
     1.6  
     1.7 -#define MYTHTV_BUFFER_SIZE							1024*140
     1.8 +/* internal GnomeVFS plug-in buffer size ( 120 Kbytes ) */
     1.9 +#define MYTHTV_BUFFER_SIZE							1024*120
    1.10 +/* internally sized GnomeVFS plug-in buffer ( 4 Kbytes ) */
    1.11  #define MYTHTV_MAX_VFS_BUFFER_SIZE			4096
    1.12 +/* maximum number of bytes to be requested to the MythTV backend ( 64 Kbytes ) */
    1.13  #define MYTHTV_MAX_REQUEST_SIZE					1024*64
    1.14  
    1.15  static GnomeVFSResult do_read (GnomeVFSMethod *method,
    1.16 @@ -231,42 +234,27 @@
    1.17  {
    1.18    MythtvHandle *myth_handle = (MythtvHandle *) method_handle;
    1.19    GnomeVFSFileSize bytes_to_read = num_bytes;
    1.20 -  gint64 size_stream = *bytes_read;
    1.21 -
    1.22 -  //*bytes_read = 0;
    1.23 -  
    1.24 -  g_debug ("XXXXXXXXXX Requested %llu bytes (remains %d bytes on buffer...) file_size = %lld\n", 
    1.25 -  		(guint64)num_bytes, myth_handle->buffer->len, *bytes_read );
    1.26  
    1.27    if ( !myth_handle->is_livetv && ( myth_handle->bytes_read >= myth_handle->content_size ) )
    1.28        return GNOME_VFS_ERROR_EOF;
    1.29  
    1.30 -  // fixme: change this to min math function
    1.31 +  /* fixme: change this to min math function */
    1.32    if (( myth_handle->content_size > 0 ) ) 
    1.33    {
    1.34    	if ( !myth_handle->is_livetv && 
    1.35    				( num_bytes > ( myth_handle->content_size - myth_handle->bytes_read ) ) )
    1.36    	{
    1.37      	bytes_to_read = myth_handle->content_size - myth_handle->bytes_read;
    1.38 -  	} else {
    1.39 -    	size_stream = gmyth_recorder_get_file_position(myth_handle->livetv->recorder);
    1.40 -    	if ( size_stream > myth_handle->content_size ) {
    1.41 -    		g_debug( "New file size %lld, old size = %lld.", size_stream, myth_handle->content_size );    		
    1.42 -    		myth_handle->content_size = size_stream;
    1.43 -    		num_bytes = ( myth_handle->content_size - myth_handle->bytes_read );
    1.44 -    	} else if ( num_bytes > ( myth_handle->content_size - myth_handle->bytes_read ) )
    1.45 -    		num_bytes = MYTHTV_MAX_VFS_BUFFER_SIZE;
    1.46 -    }
    1.47 +  	}
    1.48    }
    1.49  
    1.50    /* Loop sending the Myth File Transfer request:
    1.51     * Retry whilst authentication fails and we supply it. */
    1.52 -  /* if (myth_handle->buffer_remain  < MYTHTV_BUFFER_SIZE) { */
    1.53    if ( ( myth_handle->buffer_remain = myth_handle->buffer->len ) < bytes_to_read ) 
    1.54    {
    1.55    	gint buffer_size;
    1.56    	
    1.57 -  	//while ( MYTHTV_BUFFER_SIZE != myth_handle->buffer_remain ) {
    1.58 +  	while ( MYTHTV_BUFFER_SIZE != myth_handle->buffer_remain ) {
    1.59    		
    1.60  	  	/* resize buffer length request to no more than MYTHTV_MAX_REQUEST_SIZE */
    1.61  	  	if ( ( MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain ) <= MYTHTV_MAX_REQUEST_SIZE )
    1.62 @@ -302,7 +290,7 @@
    1.63  	      g_byte_array_free ( tmp_buffer, TRUE );
    1.64  	    	tmp_buffer = NULL;
    1.65  			}
    1.66 -  	//} /* while - iterates until fills the internal buffer */
    1.67 +  	} /* while - iterates until fills the internal buffer */
    1.68    	
    1.69    } /* if - got from the network, or not */
    1.70