[svn r104] Allows to receive buffers with unlimited size when reading data from backend.
1.1 --- a/gmyth/src/gmyth_file_transfer.c Wed Nov 22 20:21:46 2006 +0000
1.2 +++ b/gmyth/src/gmyth_file_transfer.c Wed Nov 22 20:23:03 2006 +0000
1.3 @@ -58,7 +58,7 @@
1.4 #define GMYTHTV_RETRIES -1
1.5 #define GMYTHTV_FILE_SIZE 0
1.6
1.7 -#define GMYTHTV_BUFFER_SIZE 16*1024
1.8 +#define GMYTHTV_BUFFER_SIZE 128*1024
1.9
1.10 #define GMYTHTV_VERSION 30
1.11
1.12 @@ -886,7 +886,7 @@
1.13 }
1.14
1.15 gint
1.16 -gmyth_file_transfer_read(GMythFileTransfer *transfer, void *data, gint size, gboolean read_unlimited)
1.17 +gmyth_file_transfer_read(GMythFileTransfer *transfer, GByteArray *data, gint size, gboolean read_unlimited)
1.18 {
1.19 gint recv = 0;
1.20 gsize bytes_read = 0;
1.21 @@ -903,6 +903,8 @@
1.22
1.23 GMythStringList *strlist = NULL;
1.24 GError *error = NULL;
1.25 +
1.26 + gchar *data_buffer = NULL;
1.27
1.28 gchar *trash = g_strdup("");
1.29
1.30 @@ -991,8 +993,10 @@
1.31 guint count_bytes = 0;
1.32
1.33 bytes_read = 0;
1.34 +
1.35 + data_buffer = g_new0( gchar, remaining );
1.36
1.37 - io_status = g_io_channel_read_chars( io_channel, data + recv,
1.38 + io_status = g_io_channel_read_chars( io_channel, data_buffer,
1.39 remaining, &bytes_read, &error );
1.40
1.41 if ( bytes_read > 0 )
1.42 @@ -1000,6 +1004,10 @@
1.43 recv += bytes_read;
1.44 count_bytes += bytes_read;
1.45 remaining -= bytes_read;
1.46 +
1.47 + /* append new data to the increasing byte array */
1.48 + data = g_byte_array_append ( data, g_memdup( data_buffer, bytes_read ), bytes_read );
1.49 +
1.50 g_print( "[%s] Reading buffer (bytes read = %d, remaining = %d)\n", __FUNCTION__, bytes_read, remaining );
1.51 if ( remaining == 0 ) {
1.52 response = TRUE;
1.53 @@ -1038,6 +1046,9 @@
1.54 cleanup:
1.55 myth_control_release_context (mutex);
1.56
1.57 + if ( data_buffer != NULL )
1.58 + g_free( data_buffer );
1.59 +
1.60 if ( trash != NULL )
1.61 g_free( trash );
1.62
2.1 --- a/gmyth/src/gmyth_file_transfer.h Wed Nov 22 20:21:46 2006 +0000
2.2 +++ b/gmyth/src/gmyth_file_transfer.h Wed Nov 22 20:23:03 2006 +0000
2.3 @@ -104,7 +104,7 @@
2.4
2.5 GMythFileTransfer* gmyth_file_transfer_new (gint num, GString *hostname, gshort port, gint mythtv_version );
2.6
2.7 -gint gmyth_file_transfer_read(GMythFileTransfer *transfer, void *data, gint size, gboolean read_unlimited);
2.8 +gint gmyth_file_transfer_read(GMythFileTransfer *transfer, GByteArray *data, gint size, gboolean read_unlimited);
2.9
2.10 gint64 gmyth_file_transfer_seek(GMythFileTransfer *transfer, guint64 pos, gint whence);
2.11