# HG changeset patch # User rosfran # Date 1171488923 0 # Node ID 7140b2c2e63cfd431cf7a99b5c67bb3b106dd129 # Parent 6d5596b9eb95e98273d4e6b9b4b57300fe46a740 [svn r363] Optimizations on the GnomeVFS internal buffer filling. diff -r 6d5596b9eb95 -r 7140b2c2e63c libgnomevfs2-mythtv/modules/mythtv-method.c --- a/libgnomevfs2-mythtv/modules/mythtv-method.c Wed Feb 14 21:28:49 2007 +0000 +++ b/libgnomevfs2-mythtv/modules/mythtv-method.c Wed Feb 14 21:35:23 2007 +0000 @@ -41,8 +41,11 @@ #define MYTHTV_VERSION_DEFAULT 30 #define MYTHTV_TRANSFER_MAX_WAITS 100 -#define MYTHTV_BUFFER_SIZE 1024*140 +/* internal GnomeVFS plug-in buffer size ( 120 Kbytes ) */ +#define MYTHTV_BUFFER_SIZE 1024*120 +/* internally sized GnomeVFS plug-in buffer ( 4 Kbytes ) */ #define MYTHTV_MAX_VFS_BUFFER_SIZE 4096 +/* maximum number of bytes to be requested to the MythTV backend ( 64 Kbytes ) */ #define MYTHTV_MAX_REQUEST_SIZE 1024*64 static GnomeVFSResult do_read (GnomeVFSMethod *method, @@ -231,42 +234,27 @@ { MythtvHandle *myth_handle = (MythtvHandle *) method_handle; GnomeVFSFileSize bytes_to_read = num_bytes; - gint64 size_stream = *bytes_read; - - //*bytes_read = 0; - - g_debug ("XXXXXXXXXX Requested %llu bytes (remains %d bytes on buffer...) file_size = %lld\n", - (guint64)num_bytes, myth_handle->buffer->len, *bytes_read ); if ( !myth_handle->is_livetv && ( myth_handle->bytes_read >= myth_handle->content_size ) ) return GNOME_VFS_ERROR_EOF; - // fixme: change this to min math function + /* fixme: change this to min math function */ if (( myth_handle->content_size > 0 ) ) { if ( !myth_handle->is_livetv && ( num_bytes > ( myth_handle->content_size - myth_handle->bytes_read ) ) ) { bytes_to_read = myth_handle->content_size - myth_handle->bytes_read; - } else { - size_stream = gmyth_recorder_get_file_position(myth_handle->livetv->recorder); - if ( size_stream > myth_handle->content_size ) { - g_debug( "New file size %lld, old size = %lld.", size_stream, myth_handle->content_size ); - myth_handle->content_size = size_stream; - num_bytes = ( myth_handle->content_size - myth_handle->bytes_read ); - } else if ( num_bytes > ( myth_handle->content_size - myth_handle->bytes_read ) ) - num_bytes = MYTHTV_MAX_VFS_BUFFER_SIZE; - } + } } /* Loop sending the Myth File Transfer request: * Retry whilst authentication fails and we supply it. */ - /* if (myth_handle->buffer_remain < MYTHTV_BUFFER_SIZE) { */ if ( ( myth_handle->buffer_remain = myth_handle->buffer->len ) < bytes_to_read ) { gint buffer_size; - //while ( MYTHTV_BUFFER_SIZE != myth_handle->buffer_remain ) { + while ( MYTHTV_BUFFER_SIZE != myth_handle->buffer_remain ) { /* resize buffer length request to no more than MYTHTV_MAX_REQUEST_SIZE */ if ( ( MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain ) <= MYTHTV_MAX_REQUEST_SIZE ) @@ -302,7 +290,7 @@ g_byte_array_free ( tmp_buffer, TRUE ); tmp_buffer = NULL; } - //} /* while - iterates until fills the internal buffer */ + } /* while - iterates until fills the internal buffer */ } /* if - got from the network, or not */