# HG changeset patch # User rosfran # Date 1162941083 0 # Node ID 04a6aeac87b05555526c6ac6e59c3278d3c5624f # Parent 55c7f31b85aa1b937302fe7efde62582e1c91bbd [svn r73] Deals with another kind of MythTV backend messages (changing TV chain). diff -r 55c7f31b85aa -r 04a6aeac87b0 gmyth/src/gmyth_file_transfer.c --- a/gmyth/src/gmyth_file_transfer.c Tue Nov 07 22:53:53 2006 +0000 +++ b/gmyth/src/gmyth_file_transfer.c Tue Nov 07 23:11:23 2006 +0000 @@ -57,7 +57,7 @@ #define GMYTHTV_RETRIES 1 #define GMYTHTV_FILE_SIZE 0 -#define GMYTHTV_BUFFER_SIZE 8*1024 +#define GMYTHTV_BUFFER_SIZE 16*1024 #define GMYTHTV_VERSION 30 @@ -868,15 +868,15 @@ //g_static_mutex_unlock( &mutex ); //data = (void*)g_new0( gchar, size ); - //g_io_channel_flush( io_channel, NULL ); + g_io_channel_flush( io_channel_control, NULL ); - //g_static_mutex_lock( &mutex ); + g_static_mutex_lock( &mutex ); io_cond = g_io_channel_get_buffer_condition( io_channel ); while ( recv < size && !response )//&& ( io_cond & G_IO_IN ) != 0 ) { - g_io_channel_flush( io_channel_control, NULL ); + //g_io_channel_flush( io_channel_control, NULL ); strlist = gmyth_string_list_new(); gmyth_string_list_append_char_array( strlist, transfer->query->str ); @@ -885,7 +885,7 @@ gmyth_string_list_append_int( strlist, remaining ); gmyth_socket_write_stringlist( transfer->control_sock, strlist ); - gint backend_msg_count = 2; + gint backend_msg_count = 1; /* iterates until find some non-MythTV backend message */ do { @@ -898,7 +898,8 @@ sent = 0; response = FALSE; found_backend_msg = TRUE; - } + goto clean_up; + } else { sent = gmyth_string_list_get_int( strlist, 0 ); // -1 on backend error @@ -909,19 +910,19 @@ "io_cond %s prepared for reading! (G_IO_IN) !!!\n\n", __FUNCTION__, recv, sent, ( ( io_cond & G_IO_IN ) != 0 ) ? "IS" : "IS NOT" ); - if ( sent == remaining ) - { - //response = ( recv == size ); - g_print( "[%s]\t\tsent %d, which is equals to requested size = %d\n\n", - __FUNCTION__, sent, remaining ); - } - else - { - g_print( "[%s]\t\tsent %d, which is NOT equals to requested size = %d\n\n", - __FUNCTION__, sent, remaining ); - goto cleanup; - - } + if ( sent == remaining ) + { + //response = ( recv == size ); + g_print( "[%s]\t\tsent %d, which is equals to requested size = %d\n\n", + __FUNCTION__, sent, remaining ); + } + else + { + g_print( "[%s]\t\tsent %d, which is NOT equals to requested size = %d\n\n", + __FUNCTION__, sent, remaining ); + goto cleanup; + + } } else { break; //goto cleanup; @@ -957,11 +958,9 @@ count_bytes += bytes_read; remaining -= bytes_read; g_print( "[%s] Reading buffer (bytes read = %d, remaining = %d)\n", __FUNCTION__, bytes_read, remaining ); - /* - if ( remaining == 0 ) { + if ( remaining == 0 ) break; - } - */ + } else { break; } @@ -980,14 +979,14 @@ } /* verify if the input (read) buffer is ready to receive data */ - io_cond = g_io_channel_get_buffer_condition( io_channel ); + //io_cond = g_io_channel_get_buffer_condition( io_channel ); g_print( "[%s]\t io_cond %s prepared for reading! (G_IO_IN) !!!\n\n", __FUNCTION__, ( ( io_cond & G_IO_IN ) != 0 ) ? "IS" : "IS NOT" ); } while ( remaining > 0 );//&& ( io_status == G_IO_STATUS_NORMAL ) ); - io_cond_control = g_io_channel_get_buffer_condition( io_channel_control ); + //io_cond_control = g_io_channel_get_buffer_condition( io_channel_control ); if ( remaining == 0 )//( io_cond_control & G_IO_IN ) != 0 ) { response = TRUE; @@ -996,7 +995,7 @@ } // while - io_cond_control = g_io_channel_get_buffer_condition( io_channel_control ); + //io_cond_control = g_io_channel_get_buffer_condition( io_channel_control ); if ( ( ( io_cond_control & G_IO_IN ) != 0 ) /*&& ( response || ( recv == size ) ) ) @@ -1015,8 +1014,8 @@ } cleanup: - //g_static_mutex_unlock (&mutex); - g_io_channel_flush( io_channel_control, NULL ); + g_static_mutex_unlock (&mutex); + //g_io_channel_flush( io_channel_control, NULL ); if ( trash != NULL ) g_free( trash );