gst-plugins-mythtv/src/gstmythtvsrc.c
branchtrunk
changeset 503 b0e8a532e882
parent 448 1eff6a1f7263
child 506 4fcd764b21a6
     1.1 --- a/gst-plugins-mythtv/src/gstmythtvsrc.c	Mon Mar 26 16:04:46 2007 +0100
     1.2 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c	Wed Apr 04 22:11:50 2007 +0100
     1.3 @@ -336,6 +336,7 @@
     1.4    gint read = 0;
     1.5    guint sizetoread = size;
     1.6    gint max_iters = GMYTHTV_TRANSFER_MAX_RESENDS;
     1.7 +  GMythFileTransferReadResult result;
     1.8  
     1.9    GST_LOG_OBJECT (src, "Starting: Reading %d bytes...", sizetoread);
    1.10  
    1.11 @@ -345,22 +346,22 @@
    1.12  
    1.13    while (sizetoread == size && --max_iters > 0) {
    1.14  
    1.15 -    len = gmyth_file_transfer_read (src->file_transfer,
    1.16 +    result = gmyth_file_transfer_read (src->file_transfer,
    1.17          data_ptr, sizetoread, src->live_tv);
    1.18  
    1.19      if (len > 0) {
    1.20 -      read += len;
    1.21 -      sizetoread -= len;
    1.22 +      read += data_ptr->len;
    1.23 +      sizetoread -= data_ptr->len;
    1.24      } else if (len < 0) {
    1.25  
    1.26        if (src->live_tv == FALSE) {
    1.27          read = -1;
    1.28          goto eos;
    1.29        } else {
    1.30 -        if (len == GMYTHTV_FILE_TRANSFER_READ_ERROR) {  /* -314 */
    1.31 +        if (result == GMYTH_FILE_TRANSFER_READ_ERROR) {  /* -314 */
    1.32            GST_INFO_OBJECT (src, "[LiveTV] FileTransfer READ_ERROR!");
    1.33            goto done;
    1.34 -        } else if (len == GMYTHTV_FILE_TRANSFER_NEXT_PROG_CHAIN) {      /* -315 */
    1.35 +        } else if (result == GMYTH_FILE_TRANSFER_READ_NEXT_PROG_CHAIN) {      /* -315 */
    1.36            GST_INFO_OBJECT (src,
    1.37                "[LiveTV] FileTransfer - Go to the next program chain!");
    1.38            continue;
    1.39 @@ -368,7 +369,7 @@
    1.40          goto done;
    1.41        }
    1.42  
    1.43 -    } else if (len == 0)
    1.44 +    } else if (data_ptr->len == 0)
    1.45        goto done;
    1.46  
    1.47      if (read == sizetoread)
    1.48 @@ -392,7 +393,6 @@
    1.49  {
    1.50    GstMythtvSrc *src;
    1.51    GstFlowReturn ret = GST_FLOW_OK;
    1.52 -  gint read = -1;
    1.53  
    1.54    src = GST_MYTHTV_SRC (psrc);
    1.55  
    1.56 @@ -412,6 +412,7 @@
    1.57    /* just get from the byte array, no network effort... */
    1.58    if ((src->buffer_remain = src->bytes_queue->len) < MAX_READ_SIZE) {
    1.59    	GByteArray *buffer;
    1.60 +    GMythFileTransferReadResult result = GMYTH_FILE_TRANSFER_READ_OK;
    1.61    	
    1.62      buffer = NULL;
    1.63      guint buffer_size_inter = (INTERNAL_BUFFER_SIZE - src->buffer_remain);
    1.64 @@ -421,16 +422,16 @@
    1.65  
    1.66      buffer = g_byte_array_new ();
    1.67  
    1.68 -    read = do_read_request_response (src, buffer_size_inter, buffer);
    1.69 +    result = do_read_request_response (src, buffer_size_inter, buffer);
    1.70  
    1.71 -    if (G_UNLIKELY (read < 0)) {
    1.72 +    if (G_UNLIKELY (buffer->len < 0)) {
    1.73      	
    1.74      	if (buffer != NULL) {
    1.75  	      g_byte_array_free (buffer, TRUE);
    1.76  	      buffer = NULL;
    1.77  	    }
    1.78  	    
    1.79 -      if (src->live_tv || ( read == GMYTHTV_FILE_TRANSFER_NEXT_PROG_CHAIN ))
    1.80 +      if (src->live_tv || ( result == GMYTH_FILE_TRANSFER_READ_NEXT_PROG_CHAIN ))
    1.81          goto change_progchain;
    1.82        else
    1.83          goto read_error;
    1.84 @@ -457,13 +458,13 @@
    1.85      }
    1.86  
    1.87      src->bytes_queue =
    1.88 -        g_byte_array_append (src->bytes_queue, buffer->data, read);
    1.89 -    if (read > buffer_size_inter)
    1.90 +        g_byte_array_append (src->bytes_queue, buffer->data, buffer->len);
    1.91 +    if (buffer->len > buffer_size_inter)
    1.92        GST_WARNING_OBJECT (src,
    1.93            "INCREASED buffer size! Backend sent more than we ask him... (%d)",
    1.94            abs (read - buffer_size_inter));
    1.95  
    1.96 -    src->buffer_remain += read;
    1.97 +    src->buffer_remain += buffer->len;
    1.98  
    1.99      if (buffer != NULL) {
   1.100        g_byte_array_free (buffer, TRUE);
   1.101 @@ -726,7 +727,7 @@
   1.102        "MythTV FileTransfer filesize = %lld, content_size = %lld!",
   1.103        src->file_transfer->filesize, src->content_size);
   1.104  
   1.105 -  src->content_size = src->file_transfer->filesize;
   1.106 +  src->content_size = gmyth_file_transfer_get_filesize (src->file_transfer);
   1.107  
   1.108    src->do_start = FALSE;
   1.109