gst-plugins-mythtv/src/myth_file_transfer.c
branchtrunk
changeset 32 6b9c77b9817e
parent 30 abe0ee48d78b
child 34 c71d37b93734
     1.1 --- a/gst-plugins-mythtv/src/myth_file_transfer.c	Thu Oct 12 01:50:27 2006 +0100
     1.2 +++ b/gst-plugins-mythtv/src/myth_file_transfer.c	Wed Oct 18 20:38:47 2006 +0100
     1.3 @@ -784,20 +784,21 @@
     1.4    //g_static_mutex_lock (&mutex);
     1.5    //strlist = gmyth_string_list_new();
     1.6  
     1.7 -  g_string_printf ( transfer->query, "%s %d", /*transfer->live_tv ? MYTHTV_RECORDER_HEADER :*/  MYTHTV_QUERY_HEADER, 
     1.8 +  g_string_printf ( transfer->query, "%s %d",
     1.9 +  	  /*transfer->live_tv ? MYTHTV_RECORDER_HEADER :*/  MYTHTV_QUERY_HEADER, 
    1.10        /* transfer->live_tv ? transfer->card_id :*/ transfer->recordernum ); // transfer->recordernum
    1.11    g_print( "\t[%s] Transfer_query = %s\n", __FUNCTION__, transfer->query->str );
    1.12    
    1.13    strlist = gmyth_string_list_new();
    1.14  
    1.15    gmyth_string_list_append_char_array( strlist, transfer->query->str );
    1.16 -  gmyth_string_list_append_char_array( strlist, /*transfer->live_tv ? "REQUEST_BLOCK_RINGBUF" :*/ "REQUEST_BLOCK" );
    1.17 +  gmyth_string_list_append_char_array( strlist, 
    1.18 +  		/*transfer->live_tv ? "REQUEST_BLOCK_RINGBUF" :*/ "REQUEST_BLOCK" );
    1.19    gmyth_string_list_append_int( strlist, size );
    1.20  
    1.21    gmyth_socket_write_stringlist( transfer->control_sock, strlist );
    1.22    sent = size;
    1.23    //g_static_mutex_unlock( &mutex );
    1.24 -
    1.25    //data = (void*)g_new0( gchar, size );
    1.26  
    1.27    g_io_channel_flush( io_channel_control, NULL );
    1.28 @@ -815,12 +816,14 @@
    1.29        //usleep(200);
    1.30        //
    1.31        //io_cond = g_io_channel_get_buffer_condition( io_channel );
    1.32 -      //
    1.33 +      //g_static_mutex_lock( &mutex );
    1.34  
    1.35        buf_len = ( sent - recv ) > MYTHTV_BUFFER_SIZE ? MYTHTV_BUFFER_SIZE : ( sent - recv );
    1.36  
    1.37        io_status = g_io_channel_read_chars( io_channel, data + recv, 
    1.38  	  		buf_len, &bytes_read, &error );
    1.39 +	  
    1.40 +	  //g_static_mutex_unlock( &mutex );
    1.41        /*
    1.42  	 GString *sss = g_string_new("");
    1.43  	 sss = g_string_append_len( sss, (gchar*)data+recv, bytes_read );
    1.44 @@ -863,8 +866,9 @@
    1.45        gmyth_socket_read_stringlist( transfer->control_sock, strlist );
    1.46        sent = gmyth_string_list_get_int( strlist,  0 ); // -1 on backend error      
    1.47        g_print( "[%s]\t sent = %d, io_cond %s prepared for reading! (G_IO_IN) !!!\n\n", __FUNCTION__, 
    1.48 -	  sent, ( ( io_cond & G_IO_IN ) != 0 ) ? "IS" : "IS NOT" );
    1.49 +	  		sent, ( ( io_cond & G_IO_IN ) != 0 ) ? "IS" : "IS NOT" );
    1.50        response = TRUE;
    1.51 +      break;
    1.52      }
    1.53    }
    1.54  
    1.55 @@ -875,24 +879,23 @@
    1.56      {
    1.57        if ( strlist != NULL && gmyth_string_list_length(strlist) > 0 ) {
    1.58  	sent = gmyth_string_list_get_int( strlist, 0 ); // -1 on backend error
    1.59 -	g_print( "[%s]\t sent = %d, io_cond %s prepared for reading! (G_IO_IN) !!!\n\n", __FUNCTION__, 
    1.60 +	g_print( "[%s]\t sent = %d, raw buffer I/O socket %s prepared for reading! (G_IO_IN) !!!\n\n", __FUNCTION__, 
    1.61  	    sent, ( ( io_cond & G_IO_IN ) != 0 ) ? "IS" : "IS NOT" );
    1.62        }
    1.63      }
    1.64      else
    1.65      {
    1.66        g_printerr ( "myth_file_transfer_read(): No response from control socket.");
    1.67 -      sent = -1;
    1.68 +      recv = -1;
    1.69 +    }
    1.70 +    
    1.71 +  } else if ( error!=NULL ) {
    1.72 +      g_printerr( "[%s] Error occurred: (%d, %s)\n", __FUNCTION__, error->code, error->message );
    1.73 +      //g_error_free( error );
    1.74      }
    1.75  
    1.76 -    if ( error!=NULL ) {
    1.77 -      g_printerr( "[%s] Error occurred: (%d, %s)\n", __FUNCTION__, error->code, error->message );
    1.78 -      g_error_free( error );
    1.79 -    }
    1.80 -  }
    1.81 -  //g_static_mutex_unlock( &mutex );
    1.82 -
    1.83  cleanup:
    1.84 +  g_static_mutex_unlock (&mutex);
    1.85  
    1.86    if ( trash != NULL )
    1.87      g_free( trash );
    1.88 @@ -900,8 +903,6 @@
    1.89    if ( strlist != NULL )
    1.90      g_object_unref( strlist );
    1.91  
    1.92 -  g_static_mutex_unlock (&mutex);
    1.93 -  
    1.94    g_print( "myth_file_transfer_read(): reqd=%d, rcvd=%d, rept=%d, "\
    1.95        "(rcvd and rept MUST be the same!)\n", size, 
    1.96        recv, sent );
    1.97 @@ -911,7 +912,7 @@
    1.98    //}
    1.99  
   1.100    if ( error != NULL ) {
   1.101 -    g_printerr( "ERROR: %s [msg = %s, code = %d]\n", __FUNCTION__, error->message, 
   1.102 +    g_printerr( "Cleaning-up ERROR: %s [msg = %s, code = %d]\n", __FUNCTION__, error->message, 
   1.103  	error->code );
   1.104  	g_error_free( error );
   1.105    }
   1.106 @@ -919,7 +920,7 @@
   1.107    return recv;
   1.108  }
   1.109  
   1.110 -  void 
   1.111 +void 
   1.112  myth_file_transfer_settimeout( MythFileTransfer *transfer, gboolean fast )
   1.113  {
   1.114