1.1 --- a/libgnomevfs2-mythtv/modules/mythtv-method.c Fri Feb 09 20:42:28 2007 +0000
1.2 +++ b/libgnomevfs2-mythtv/modules/mythtv-method.c Mon Feb 12 15:22:28 2007 +0000
1.3 @@ -40,7 +40,9 @@
1.4 #define MYTHTV_VERSION_DEFAULT 30
1.5 #define MYTHTV_TRANSFER_MAX_WAITS 100
1.6
1.7 -#define MYTHTV_BUFFER_SIZE 1024*64
1.8 +#define MYTHTV_BUFFER_SIZE 1024*80
1.9 +#define MYTHTV_MAX_VFS_BUFFER_SIZE 4096
1.10 +#define MYTHTV_MAX_REQUEST_SIZE 1024*64
1.11
1.12 static GnomeVFSResult do_read (GnomeVFSMethod *method,
1.13 GnomeVFSMethodHandle *method_handle,
1.14 @@ -211,6 +213,8 @@
1.15 GnomeVFSFileSize bytes_to_read;
1.16
1.17 *bytes_read = 0;
1.18 +
1.19 + g_debug ("XXXXXXXXXX Requested %llu bytes...\n", (guint64)num_bytes);
1.20
1.21 if ( !myth_handle->is_livetv && ( myth_handle->bytes_read >= myth_handle->content_size ) )
1.22 return GNOME_VFS_ERROR_EOF;
1.23 @@ -225,17 +229,23 @@
1.24 /* Loop sending the Myth File Transfer request:
1.25 * Retry whilst authentication fails and we supply it. */
1.26 //if (myth_handle->buffer_remain < MYTHTV_BUFFER_SIZE) {
1.27 - if ( ( myth_handle->buffer_remain = myth_handle->buffer->len ) < MYTHTV_BUFFER_SIZE ) {
1.28 + if ( ( myth_handle->buffer_remain = myth_handle->buffer->len ) < MYTHTV_MAX_VFS_BUFFER_SIZE ) {
1.29 + gint buffer_size = MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain;
1.30 +
1.31 + /* resize buffer length request to no more than MYTHTV_MAX_REQUEST_SIZE */
1.32 + if ( buffer_size > MYTHTV_MAX_REQUEST_SIZE )
1.33 + buffer_size = MYTHTV_MAX_REQUEST_SIZE;
1.34 +
1.35 GByteArray *tmp_buffer = g_byte_array_new();
1.36
1.37 - printf ("XXXXXXXXXXXXXX Pedindo %d %d\n", MYTHTV_BUFFER_SIZE, myth_handle->buffer_remain);
1.38 + g_debug ("XXXXXXXXXX Pedindo %d (restam apenas %d no buffer)\n", buffer_size, myth_handle->buffer_remain);
1.39
1.40 gint len = gmyth_file_transfer_read (myth_handle->file_transfer,
1.41 - tmp_buffer, MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain, TRUE);
1.42 + tmp_buffer, buffer_size, TRUE);
1.43
1.44 if (!myth_handle->is_livetv && len < 0) {
1.45 g_byte_array_free (tmp_buffer, TRUE);
1.46 - g_print ("Fail to read bytes");
1.47 + g_debug ("Fail to read bytes");
1.48 return GNOME_VFS_ERROR_IO;
1.49 } /*else if (len == 0) {
1.50 g_byte_array_free (tmp_buffer, TRUE);
1.51 @@ -248,9 +258,12 @@
1.52
1.53 myth_handle->buffer_remain += len;
1.54
1.55 - g_byte_array_free (tmp_buffer, TRUE);
1.56 - tmp_buffer = NULL;
1.57 - }
1.58 + if ( tmp_buffer != NULL )
1.59 + {
1.60 + g_byte_array_free (tmp_buffer, TRUE);
1.61 + tmp_buffer = NULL;
1.62 + }
1.63 + } /* if - got from the network, or not */
1.64
1.65 bytes_to_read = (bytes_to_read > myth_handle->buffer_remain) ? myth_handle->buffer_remain : bytes_to_read;
1.66 /* gets the first buffer_size bytes from the byte array buffer variable */
1.67 @@ -276,7 +289,6 @@
1.68 MythtvHandle *myth_handle = (MythtvHandle *) method_handle;
1.69
1.70 if (myth_handle->file_transfer != NULL) {
1.71 - //gmyth_file_transfer_close (myth_handle->file_transfer);
1.72 g_object_unref (myth_handle->file_transfer);
1.73 myth_handle->file_transfer = NULL;
1.74 }