diff -r abe0ee48d78b -r 6b9c77b9817e gst-plugins-mythtv/src/myth_file_transfer.c --- a/gst-plugins-mythtv/src/myth_file_transfer.c Thu Oct 12 01:50:27 2006 +0100 +++ b/gst-plugins-mythtv/src/myth_file_transfer.c Wed Oct 18 20:38:47 2006 +0100 @@ -784,20 +784,21 @@ //g_static_mutex_lock (&mutex); //strlist = gmyth_string_list_new(); - g_string_printf ( transfer->query, "%s %d", /*transfer->live_tv ? MYTHTV_RECORDER_HEADER :*/ MYTHTV_QUERY_HEADER, + g_string_printf ( transfer->query, "%s %d", + /*transfer->live_tv ? MYTHTV_RECORDER_HEADER :*/ MYTHTV_QUERY_HEADER, /* transfer->live_tv ? transfer->card_id :*/ transfer->recordernum ); // transfer->recordernum g_print( "\t[%s] Transfer_query = %s\n", __FUNCTION__, transfer->query->str ); strlist = gmyth_string_list_new(); gmyth_string_list_append_char_array( strlist, transfer->query->str ); - gmyth_string_list_append_char_array( strlist, /*transfer->live_tv ? "REQUEST_BLOCK_RINGBUF" :*/ "REQUEST_BLOCK" ); + gmyth_string_list_append_char_array( strlist, + /*transfer->live_tv ? "REQUEST_BLOCK_RINGBUF" :*/ "REQUEST_BLOCK" ); gmyth_string_list_append_int( strlist, size ); gmyth_socket_write_stringlist( transfer->control_sock, strlist ); sent = size; //g_static_mutex_unlock( &mutex ); - //data = (void*)g_new0( gchar, size ); g_io_channel_flush( io_channel_control, NULL ); @@ -815,12 +816,14 @@ //usleep(200); // //io_cond = g_io_channel_get_buffer_condition( io_channel ); - // + //g_static_mutex_lock( &mutex ); buf_len = ( sent - recv ) > MYTHTV_BUFFER_SIZE ? MYTHTV_BUFFER_SIZE : ( sent - recv ); io_status = g_io_channel_read_chars( io_channel, data + recv, buf_len, &bytes_read, &error ); + + //g_static_mutex_unlock( &mutex ); /* GString *sss = g_string_new(""); sss = g_string_append_len( sss, (gchar*)data+recv, bytes_read ); @@ -863,8 +866,9 @@ gmyth_socket_read_stringlist( transfer->control_sock, strlist ); sent = gmyth_string_list_get_int( strlist, 0 ); // -1 on backend error g_print( "[%s]\t sent = %d, io_cond %s prepared for reading! (G_IO_IN) !!!\n\n", __FUNCTION__, - sent, ( ( io_cond & G_IO_IN ) != 0 ) ? "IS" : "IS NOT" ); + sent, ( ( io_cond & G_IO_IN ) != 0 ) ? "IS" : "IS NOT" ); response = TRUE; + break; } } @@ -875,24 +879,23 @@ { if ( strlist != NULL && gmyth_string_list_length(strlist) > 0 ) { sent = gmyth_string_list_get_int( strlist, 0 ); // -1 on backend error - g_print( "[%s]\t sent = %d, io_cond %s prepared for reading! (G_IO_IN) !!!\n\n", __FUNCTION__, + g_print( "[%s]\t sent = %d, raw buffer I/O socket %s prepared for reading! (G_IO_IN) !!!\n\n", __FUNCTION__, sent, ( ( io_cond & G_IO_IN ) != 0 ) ? "IS" : "IS NOT" ); } } else { g_printerr ( "myth_file_transfer_read(): No response from control socket."); - sent = -1; + recv = -1; + } + + } else if ( error!=NULL ) { + g_printerr( "[%s] Error occurred: (%d, %s)\n", __FUNCTION__, error->code, error->message ); + //g_error_free( error ); } - if ( error!=NULL ) { - g_printerr( "[%s] Error occurred: (%d, %s)\n", __FUNCTION__, error->code, error->message ); - g_error_free( error ); - } - } - //g_static_mutex_unlock( &mutex ); - cleanup: + g_static_mutex_unlock (&mutex); if ( trash != NULL ) g_free( trash ); @@ -900,8 +903,6 @@ if ( strlist != NULL ) g_object_unref( strlist ); - g_static_mutex_unlock (&mutex); - g_print( "myth_file_transfer_read(): reqd=%d, rcvd=%d, rept=%d, "\ "(rcvd and rept MUST be the same!)\n", size, recv, sent ); @@ -911,7 +912,7 @@ //} if ( error != NULL ) { - g_printerr( "ERROR: %s [msg = %s, code = %d]\n", __FUNCTION__, error->message, + g_printerr( "Cleaning-up ERROR: %s [msg = %s, code = %d]\n", __FUNCTION__, error->message, error->code ); g_error_free( error ); } @@ -919,7 +920,7 @@ return recv; } - void +void myth_file_transfer_settimeout( MythFileTransfer *transfer, gboolean fast ) {