# HG changeset patch # User rosfran # Date 1164226983 0 # Node ID c83e6f69f4683b2a28677c948bd7c19ec9e7efa4 # Parent 4f7789e3bfd4c14b9431a6edba5917ca77ebf603 [svn r104] Allows to receive buffers with unlimited size when reading data from backend. diff -r 4f7789e3bfd4 -r c83e6f69f468 gmyth/src/gmyth_file_transfer.c --- a/gmyth/src/gmyth_file_transfer.c Wed Nov 22 20:21:46 2006 +0000 +++ b/gmyth/src/gmyth_file_transfer.c Wed Nov 22 20:23:03 2006 +0000 @@ -58,7 +58,7 @@ #define GMYTHTV_RETRIES -1 #define GMYTHTV_FILE_SIZE 0 -#define GMYTHTV_BUFFER_SIZE 16*1024 +#define GMYTHTV_BUFFER_SIZE 128*1024 #define GMYTHTV_VERSION 30 @@ -886,7 +886,7 @@ } gint -gmyth_file_transfer_read(GMythFileTransfer *transfer, void *data, gint size, gboolean read_unlimited) +gmyth_file_transfer_read(GMythFileTransfer *transfer, GByteArray *data, gint size, gboolean read_unlimited) { gint recv = 0; gsize bytes_read = 0; @@ -903,6 +903,8 @@ GMythStringList *strlist = NULL; GError *error = NULL; + + gchar *data_buffer = NULL; gchar *trash = g_strdup(""); @@ -991,8 +993,10 @@ guint count_bytes = 0; bytes_read = 0; + + data_buffer = g_new0( gchar, remaining ); - io_status = g_io_channel_read_chars( io_channel, data + recv, + io_status = g_io_channel_read_chars( io_channel, data_buffer, remaining, &bytes_read, &error ); if ( bytes_read > 0 ) @@ -1000,6 +1004,10 @@ recv += bytes_read; count_bytes += bytes_read; remaining -= bytes_read; + + /* append new data to the increasing byte array */ + data = g_byte_array_append ( data, g_memdup( data_buffer, bytes_read ), bytes_read ); + g_print( "[%s] Reading buffer (bytes read = %d, remaining = %d)\n", __FUNCTION__, bytes_read, remaining ); if ( remaining == 0 ) { response = TRUE; @@ -1038,6 +1046,9 @@ cleanup: myth_control_release_context (mutex); + if ( data_buffer != NULL ) + g_free( data_buffer ); + if ( trash != NULL ) g_free( trash ); diff -r 4f7789e3bfd4 -r c83e6f69f468 gmyth/src/gmyth_file_transfer.h --- a/gmyth/src/gmyth_file_transfer.h Wed Nov 22 20:21:46 2006 +0000 +++ b/gmyth/src/gmyth_file_transfer.h Wed Nov 22 20:23:03 2006 +0000 @@ -104,7 +104,7 @@ GMythFileTransfer* gmyth_file_transfer_new (gint num, GString *hostname, gshort port, gint mythtv_version ); -gint gmyth_file_transfer_read(GMythFileTransfer *transfer, void *data, gint size, gboolean read_unlimited); +gint gmyth_file_transfer_read(GMythFileTransfer *transfer, GByteArray *data, gint size, gboolean read_unlimited); gint64 gmyth_file_transfer_seek(GMythFileTransfer *transfer, guint64 pos, gint whence);